GitHub REST API
Access repositories, issues, users, gists and almost everything on GitHub.
What it does
The GitHub REST API covers almost everything you can do on github.com — read and manage repositories, issues, pull requests, commits, releases, users, organisations, Actions workflows, gists and search. Responses are JSON; a parallel GraphQL API exists for precise queries.
Base URL
Authentication
Public read endpoints work with no auth but are limited to 60 requests/hour per IP. Create a personal access token (classic or fine-grained) and send it as Authorization: Bearer ghp_… to get 5,000 requests/hour. Also send X-GitHub-Api-Version: 2022-11-28 and a User-Agent.
Code examples
curl -H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/torvalds/linuximport requests
r = requests.get(
"https://api.github.com/repos/python/cpython/issues",
headers={"Authorization": f"Bearer {TOKEN}",
"X-GitHub-Api-Version": "2022-11-28"},
params={"state": "open", "per_page": 5},
timeout=10)
for issue in r.json():
print(issue["number"], issue["title"])Rate limits & quotas
Authenticated: 5,000 requests/hour (15,000 for GitHub Apps on an org). Unauthenticated: 60/hour per IP. Search has its own tighter limit of 30 requests/minute. Every response carries x-ratelimit-remaining and x-ratelimit-reset. Use conditional requests with ETag/If-None-Match — a 304 response does not count against your quota.
Key response fields
| full_name | owner/repo |
| stargazers_count / forks_count | Repo popularity counters |
| default_branch | Usually main |
| Link header | Pagination — rel="next" / rel="last" URLs |
| x-ratelimit-remaining | Calls left in the current hour window |
Common errors
| 401 | Bad or expired token. |
| 403 / 429 rate limit exceeded | Hourly or search limit hit — wait until x-ratelimit-reset. |
| 404 | Repo is private and your token lacks access, or the path is wrong. |
| 422 | Validation failed — the JSON errors array says which field. |
When to use it (and alternatives)
The default for anything GitHub. Use GraphQL (api.github.com/graphql) when you need many nested fields in one round trip. For GitLab-hosted projects see the GitLab API.
FAQ
How do I raise the 60/hour limit?
Authenticate. Any valid token — even one with no scopes — lifts you to 5,000 requests/hour. Never ship an unauthenticated integration that hits GitHub at scale.
REST or GraphQL?
REST is simpler and fully documented per resource. GraphQL is better when you would otherwise make many REST calls to assemble one view (e.g. a repo plus its last 20 PRs plus each PR’s reviews).
Do conditional requests really help?
Yes. Store the ETag from a response and send it back as If-None-Match. If nothing changed you get a 304 with an empty body that does not decrement your rate limit.
New to APIs?
Short guides for working with this API — and any other.