GitHub - Using custom queries
Default functions not working for you? Use custom queries!
The
HubAPI.custom_query()
function lets you specify a custom query!Here's an example:
GitHub uses GraphQL which is a type of API developed by Facebook Meta.
Learn more about GitHub and GraphQL here - https://docs.github.com/en/graphql/overview/about-the-graphql-api
main.py
from pygitapi import HubAPI
token = 'PERSONAL ACCESS TOKEN'
h = HubAPI(token)
query = """
query {
user(login: "DillonB07") {
name
}
}
"""
print(h.custom_query(query))
This will return:
{'user': {'name': 'Dillon Barnes'}}
Last modified 11mo ago