Quick Start
This quick start guide describes how to get your first response from the GitHub REST API using cURL and PowerShell. For more information, see Validation and Sources.
Prerequisites
- GitHub account.
- Personal Access Token (PAT).
- cURL or PowerShell.
Quick Start Overview
- Create a token.
- Make your first request.
- Read the response.
- Handle pagination.
Token Creation
This token will replace <TOKEN> from codes for authentication. For this quick start, use all default settings and values.
For additional information, see Authentication.
-
Sign in to your GitHub account at https://github.com/login.
-
In the upper-right corner, select your profile picture > Settings.
-
In the left sidebar, select Developer settings.
-
Select Personal access tokens > Fine-grained tokens > Generate new token.
First Request
- Choose between cURL or PowerShell.
- Bash (cURL)
- PowerShell
curl -i -H "Authorization: Bearer <TOKEN>" "https://api.github.com/repos/facebook/react/issues?per_page=1&page=1"
$headers = @{
Authorization = "Bearer <TOKEN>"
Accept = "application/vnd.github+json"
}
Invoke-RestMethod -Uri "https://api.github.com/repos/facebook/react/issues?per_page=1&page=1" -Headers $headers
-
Replace
<TOKEN>with a valid token. -
Run the request.
If it returns 200 OK, you confirmed that your authentication is working and that you can read responses from the GitHub REST API.
However, if it returns 401 Unauthorized, your token is invalid. Verify that you pasted the token correctly or if it's expired. See Errors and Status Codes for other issues.
Analyzing Response
A successful response will return a JSON with an array of issue objects and a status code. GitHub has many notable metadata, like id, title, state, created_at, and more.
The response includes an HTTP status code, followed by several metadata parameters and the array with the object from the request.
Understanding Pagination
GitHub REST API responses are paginated by default, even when requesting only one item.
For additional information, see Pagination.