Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ To set up a trial, you must be signed in to a personal account. If you don't hav
The trial lasts for **{% data reusables.enterprise.ghec-trial-length %} days** and includes the following features.

* Access to **most** {% data variables.product.prodname_ghe_cloud %} features.
* {% data variables.copilot.copilot_for_business %} ({% data variables.product.prodname_dotcom_the_website %} trials only)
* {% data variables.copilot.copilot_for_business %}
* {% data variables.product.prodname_GH_cs_and_sp %} ({% data variables.product.prodname_dotcom_the_website %} trials only)
* Access to the **new billing platform**.{% ifversion enhanced-billing-platform %} See [AUTOTITLE](/billing/using-the-new-billing-platform/about-the-new-billing-platform-for-enterprises).{% endif %}
* An **enterprise account**, which allows you to manage multiple organizations. See [AUTOTITLE](/enterprise-cloud@latest/get-started/learning-about-github/types-of-github-accounts).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ In this example, `pageInfo.startCursor` gives the cursor for the first item on t

## Changing the number of items per page

The `first` and `last` arguments control how many items are returned. The maximum number of items you can fetch using the `first` or `last` argument is 100. You may need to request fewer than 100 items if your query touches a lot of data in order to avoid hitting a rate or node limit. For more information, see [AUTOTITLE](/graphql/overview/rate-limits-and-node-limits-for-the-graphql-api).
The `first` and `last` arguments control how many items are returned. The maximum number of items you can fetch using the `first` or `last` argument is 100. You may need to request fewer than 100 items if your query touches a lot of data in order to avoid hitting a rate or node limit. For more information, see [AUTOTITLE](/graphql/overview/rate-limits-and-query-limits-for-the-graphql-api).

## Traversing the data set using pagination

Expand Down
2 changes: 1 addition & 1 deletion content/graphql/overview/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ children:
- /breaking-changes
- /changelog
- /explorer
- /rate-limits-and-node-limits-for-the-graphql-api
- /rate-limits-and-query-limits-for-the-graphql-api
---

Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
title: Rate limits and node limits for the GraphQL API
shortTitle: Rate and node limits
title: Rate limits and query limits for the GraphQL API
shortTitle: Rate and query limits
intro: 'The {% data variables.product.prodname_dotcom %} GraphQL API has limitations in place to protect against excessive or abusive calls to {% data variables.product.prodname_dotcom %}''s servers.'
redirect_from:
- /v4/guides/resource-limitations
- /graphql/overview/resource-limitations
- /graphql/overview/rate-limits-and-node-limits-for-the-graphql-api
versions:
fpt: '*'
ghec: '*'
Expand All @@ -13,122 +14,6 @@ topics:
- API
---

## Node limit

To pass [schema](/graphql/guides/introduction-to-graphql#schema) validation, all GraphQL API [calls](/graphql/guides/forming-calls-with-graphql) must meet these standards:

* Clients must supply a `first` or `last` argument on any [connection](/graphql/guides/introduction-to-graphql#connection).
* Values of `first` and `last` must be within 1-100.
* Individual calls cannot request more than 500,000 total [nodes](/graphql/guides/introduction-to-graphql#node).

### Calculating nodes in a call

These two examples show how to calculate the total nodes in a call.

1. Simple query:

<pre>query {
viewer {
repositories(first: <span class="redbox">50</span>) {
edges {
repository:node {
name

issues(first: <span class="greenbox">10</span>) {
totalCount
edges {
node {
title
bodyHTML
}
}
}
}
}
}
}
}</pre>

Calculation:

<pre><span class="redbox">50</span> = 50 repositories
+
<span class="redbox">50</span> x <span class="greenbox">10</span> = 500 repository issues

= 550 total nodes</pre>

1. Complex query:

<pre>query {
viewer {
repositories(first: <span class="redbox">50</span>) {
edges {
repository:node {
name

pullRequests(first: <span class="greenbox">20</span>) {
edges {
pullRequest:node {
title

comments(first: <span class="bluebox">10</span>) {
edges {
comment:node {
bodyHTML
}
}
}
}
}
}

issues(first: <span class="greenbox">20</span>) {
totalCount
edges {
issue:node {
title
bodyHTML

comments(first: <span class="bluebox">10</span>) {
edges {
comment:node {
bodyHTML
}
}
}
}
}
}
}
}
}

followers(first: <span class="bluebox">10</span>) {
edges {
follower:node {
login
}
}
}
}
}</code></pre>

Calculation:

<pre><span class="redbox">50</span> = 50 repositories
+
<span class="redbox">50</span> x <span class="greenbox">20</span> = 1,000 pullRequests
+
<span class="redbox">50</span> x <span class="greenbox">20</span> x <span class="bluebox">10</span> = 10,000 pullRequest comments
+
<span class="redbox">50</span> x <span class="greenbox">20</span> = 1,000 issues
+
<span class="redbox">50</span> x <span class="greenbox">20</span> x <span class="bluebox">10</span> = 10,000 issue comments
+
<span class="bluebox">10</span> = 10 followers

= 22,060 total nodes</pre>

## Primary rate limit

{% ifversion ghes %}
Expand Down Expand Up @@ -278,6 +163,126 @@ You should also subscribe to webhook events instead of polling the API for data.

You can also stream the audit log in order to view API requests. This can help you troubleshoot integrations that are exceeding the rate limit. For more information, see [AUTOTITLE](/admin/monitoring-activity-in-your-enterprise/reviewing-audit-logs-for-your-enterprise/streaming-the-audit-log-for-your-enterprise).

{% endif %}

## Node limit

To pass [schema](/graphql/guides/introduction-to-graphql#schema) validation, all GraphQL API [calls](/graphql/guides/forming-calls-with-graphql) must meet these standards:

* Clients must supply a `first` or `last` argument on any [connection](/graphql/guides/introduction-to-graphql#connection).
* Values of `first` and `last` must be within 1-100.
* Individual calls cannot request more than 500,000 total [nodes](/graphql/guides/introduction-to-graphql#node).

### Calculating nodes in a call

These two examples show how to calculate the total nodes in a call.

1. Simple query:

<pre>query {
viewer {
repositories(first: <span class="redbox">50</span>) {
edges {
repository:node {
name

issues(first: <span class="greenbox">10</span>) {
totalCount
edges {
node {
title
bodyHTML
}
}
}
}
}
}
}
}</pre>

Calculation:

<pre><span class="redbox">50</span> = 50 repositories
+
<span class="redbox">50</span> x <span class="greenbox">10</span> = 500 repository issues

= 550 total nodes</pre>

1. Complex query:

<pre>query {
viewer {
repositories(first: <span class="redbox">50</span>) {
edges {
repository:node {
name

pullRequests(first: <span class="greenbox">20</span>) {
edges {
pullRequest:node {
title

comments(first: <span class="bluebox">10</span>) {
edges {
comment:node {
bodyHTML
}
}
}
}
}
}

issues(first: <span class="greenbox">20</span>) {
totalCount
edges {
issue:node {
title
bodyHTML

comments(first: <span class="bluebox">10</span>) {
edges {
comment:node {
bodyHTML
}
}
}
}
}
}
}
}
}

followers(first: <span class="bluebox">10</span>) {
edges {
follower:node {
login
}
}
}
}
}</code></pre>

Calculation:

<pre><span class="redbox">50</span> = 50 repositories
+
<span class="redbox">50</span> x <span class="greenbox">20</span> = 1,000 pullRequests
+
<span class="redbox">50</span> x <span class="greenbox">20</span> x <span class="bluebox">10</span> = 10,000 pullRequest comments
+
<span class="redbox">50</span> x <span class="greenbox">20</span> = 1,000 issues
+
<span class="redbox">50</span> x <span class="greenbox">20</span> x <span class="bluebox">10</span> = 10,000 issue comments
+
<span class="bluebox">10</span> = 10 followers

= 22,060 total nodes</pre>

{% ifversion not ghes %}

## Timeouts

If {% data variables.product.github %} takes more than 10 seconds to process an API request, {% data variables.product.github %} will terminate the request and you will receive a timeout response and a message reporting that "We couldn't respond to your request in time".
Expand All @@ -288,4 +293,24 @@ You can check the status of the GraphQL API at [githubstatus.com](https://www.gi

If a timeout occurs for any of your API requests, additional points will be deducted from your primary rate limit for the next hour to protect the speed and reliability of the API.

## Other resource limits

To protect the speed and reliability of the API, {% data variables.product.github %} also enforces other resource limitations. If your GraphQL query consumes too many resources, {% data variables.product.github %} will terminate the request and return partial results along with an error indicating that resource limits were exceeded.

**Examples of queries that may exceed resource limits:**

* Requesting thousands of objects or deeply nested relationships in a single query.
* Using large `first` or `last` arguments in multiple connections simultaneously.
* Fetching extensive details for each object, such as all comments, reactions, and related issues for every repository.

{% endif %}

## Query optimization strategies

* **Limit the number of objects**: Use smaller values for `first` or `last` 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.
2 changes: 1 addition & 1 deletion content/rest/copilot/copilot-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ redirect_from:

You can use these endpoints to get a breakdown of aggregated metrics for various {% data variables.product.prodname_copilot %} features. The API includes:

* Data for the last 28 days
* Data for the last 100 days
* Numbers of active users and engaged users
* Breakdowns by language and IDE
* The option to view metrics for an enterprise, organization, or team
Expand Down
2 changes: 1 addition & 1 deletion data/reusables/enterprise/emus-trial-content.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
If you choose an {% data variables.enterprise.prodname_emu_enterprise %}, you will also choose whether to create an enterprise on {% data variables.product.prodname_dotcom_the_website %} or in a specific data residency region on {% data variables.enterprise.data_residency_site %}.

* Trials on **{% data variables.product.prodname_dotcom_the_website %}** include free access to {% data variables.copilot.copilot_for_business %} and {% data variables.product.prodname_GHAS %} features. Your enterprise will be hosted in the US.
* Trials on **{% data variables.enterprise.data_residency_site %}** allow you to meet specific regulatory requirements and choose a unique subdomain for your enterprise. However, the trial won't include free access to {% data variables.copilot.copilot_for_business %} and {% data variables.product.prodname_GHAS %} features, or access to the currently unavailable features listed in [AUTOTITLE](/enterprise-cloud@latest/admin/data-residency/feature-overview-for-github-enterprise-cloud-with-data-residency#currently-unavailable-features).
* Trials on **{% data variables.enterprise.data_residency_site %}** allow you to meet specific regulatory requirements and choose a unique subdomain for your enterprise. However, there are some features that are not included in the trial. See [AUTOTITLE](/enterprise-cloud@latest/admin/data-residency/feature-overview-for-github-enterprise-cloud-with-data-residency#currently-unavailable-features).
Loading