Created
August 16, 2024 15:57
-
-
Save andrewpetrochenkov/f4cdc25b0d6eeae02282b9a95ade9302 to your computer and use it in GitHub Desktop.
github python GraphQL API example #github #graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import json | |
import os | |
import requests | |
URL = "https://api.github.com/graphql" | |
headers = { | |
"Accept": "application/vnd.github+json", | |
"Authorization": "Bearer %s" % os.getenv('GITHUB_TOKEN'), | |
"X-GitHub-Api-Version": "2022-11-28" | |
} | |
query=""" | |
query { | |
rateLimit { | |
limit | |
cost | |
remaining | |
resetAt | |
} | |
} | |
""" | |
r = requests.post(URL,headers=headers,data=json.dumps({'query':query})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment