Primary rate limit
Rate limits are disabled by default for GitHub Enterprise Server. Contact your site administrator to confirm the rate limits for your instance.
If you are a site administrator, you can set rate limits for your instance. For more information, see Configuring rate limits.
If you are developing an app for users or organizations outside of your instance, the standard GitHub rate limits apply. For more information, see Rate limits and query limits for the GraphQL API in the GitHub Free documentation.
Node limit
To pass schema validation, all GraphQL API calls must meet these standards:
- Clients must supply a
first
orlast
argument on any connection. - Values of
first
andlast
must be within 1-100. - Individual calls cannot request more than 500,000 total nodes.
Calculating nodes in a call
These two examples show how to calculate the total nodes in a call.
-
Simple query:
query { viewer { repositories(first: 50) { edges { repository:node { name issues(first: 10) { totalCount edges { node { title bodyHTML } } } } } } } }
Calculation:
50 = 50 repositories + 50 x 10 = 500 repository issues = 550 total nodes
-
Complex query:
query { viewer { repositories(first: 50) { edges { repository:node { name pullRequests(first: 20) { edges { pullRequest:node { title comments(first: 10) { edges { comment:node { bodyHTML } } } } } } issues(first: 20) { totalCount edges { issue:node { title bodyHTML comments(first: 10) { edges { comment:node { bodyHTML } } } } } } } } } followers(first: 10) { edges { follower:node { login } } } } }
Calculation:
50 = 50 repositories + 50 x 20 = 1,000 pullRequests + 50 x 20 x 10 = 10,000 pullRequest comments + 50 x 20 = 1,000 issues + 50 x 20 x 10 = 10,000 issue comments + 10 = 10 followers = 22,060 total nodes
Query optimization strategies
- Limit the number of objects: Use smaller values for
first
orlast
arguments and paginate through results. - Reduce query depth: Avoid requesting deeply nested objects unless necessary.
- Filter results: Use arguments to filter data and return only what you need.
- Split large queries: Break up complex queries into multiple simpler queries.
- Request only required fields: Select only the fields you need, rather than requesting all available fields.
By following these strategies, you can reduce the likelihood of hitting resource limits and improve the performance and reliability of your API requests.