Skip to content

Instantly share code, notes, and snippets.

@andrewpetrochenkov
Created August 16, 2024 15:57
Show Gist options
  • Save andrewpetrochenkov/f4cdc25b0d6eeae02282b9a95ade9302 to your computer and use it in GitHub Desktop.
Save andrewpetrochenkov/f4cdc25b0d6eeae02282b9a95ade9302 to your computer and use it in GitHub Desktop.
github python GraphQL API example #github #graphql
#!/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