Pagination and Limits

Pagination, Rate Limits and API Versioning

List endpoints return 30 items by default and at most 100 (per_page). The Link response header holds the URLs of the next and last pages; follow it rather than building page numbers yourself. gh 29 api --paginate does that and concatenates the results:

Following Link headers through BookNest's closed pull requestsShell
gh api -i 'repos/{owner}/{repo}/pulls?state=closed&per_page=10' | grep -i '^link'
gh api --paginate 'repos/{owner}/{repo}/pulls?state=closed&per_page=10' --jq '.[].number' \
  | wc -l
Output
Link: <https://api.github.com/repositories/1387250434/pulls?state=closed&per_page=10&page=2>;
rel="next",
<https://api.github.com/repositories/1387250434/pulls?state=closed&per_page=10&page=3>;
  rel="last"
23

The primary rate limit is 5,000 requests an hour for a personal token, 1,000 per repository for GITHUB_TOKEN, and 5,000 to 12,500 for a GitHub 29 App installation. Secondary limits stop bursts: 100 concurrent requests, 900 points a minute, 80 content-creating requests a minute. At x-ratelimit-remaining: 0 wait for x-ratelimit-reset (a Unix time); on 403 or 429 with retry-after, wait that long. Conditional requests (ETag) answered 304 are free.

Versions are dates in the X-GitHub-Api-Version header; without it you get 2022-11-28. 2026-03-10 removes deprecated fields (assignee, merge_commit_sha) and returns the new run from a workflow dispatch instead of

  1. Each version lives at least 24 months after its successor. The API lists what it accepts:

Which REST API versions GitHub supportsShell
gh api versions
gh api -H "X-GitHub-Api-Version: 2021-01-01" repos/{owner}/{repo} --jq .full_name
Output
["2026-03-10","2022-11-28"]{"message":"Bad Request","errors":"The version you specified in the
\"X-GitHub-API-Version\" request header, \"2021-01-01\", is not a supported version. The
following versions are currently supported: \"2026-03-10\" (most recent) and
  \"2022-11-28\".",...}
...