Module for consuming Github GraphQL API in Python.
pip install git+https://github.com/fer/github-graphql-client.git
Get your Personal access tokens from GitHub.
from github_graphql_client import GitHubGraphQLClient
ACCESS_TOKEN = '<your_access_token>'
gh_gql = GitHubGraphQLClient(ACCESS_TOKEN, './logs/GitHubGraphQLClient.log')
Query without pagination:
rate_limit = gh_gql.query(
'graphql/GitHub/get-ratelimit.graphql'
)['data']['rateLimit']
Query with pagination:
import pandas as pd
TERM = 'poc-'
print(f"Searching for '{TERM}' repos...")
repos = gh_gql.query_pagination(
'graphql/GitHub/search-repos-query.graphql',
{
'queryString': f'org:backbase-rnd {TERM}'
}
)
df = pd.DataFrame(repos)