GitHub REST API
GitHub · Company
Access GitHub data — repos, users, issues, pull requests, commits, and more. Many endpoints are public; authenticated requests get higher rate limits and private repo access.
Authentication
Sample Requests
Returns public profile information for any GitHub user. No auth required.
Hover any highlighted part to learn what it does
curl -X GET "https://api.github.com/users/octocat" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
headers = {
"Authorization": "Bearer YOUR_ACCESS_TOKEN"
}
response = requests.get(
"https://api.github.com/users/octocat",
headers=headers,
)
print(response.json())const url = 'https://api.github.com/users/octocat';
const response = await fetch(url, {
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
},
});
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
)
func main() {
targetURL := "https://api.github.com/users/octocat"
req, _ := http.NewRequest("GET", targetURL, nil)
req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.github.com/users/octocat")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer YOUR_ACCESS_TOKEN"
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.github.com/users/octocat";
$opts = ["http" => [
"method" => "GET",
"header" => implode("\r\n", [
"Authorization: Bearer YOUR_ACCESS_TOKEN"
]),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Returns a list of public repositories for the specified user.
Hover any highlighted part to learn what it does
curl -X GET "https://api.github.com/users/octocat/repos?sort=updated&per_page=5" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
params = {
"sort": "updated",
"per_page": "5"
}
headers = {
"Authorization": "Bearer YOUR_ACCESS_TOKEN"
}
response = requests.get(
"https://api.github.com/users/octocat/repos",
params=params,
headers=headers,
)
print(response.json())const url = new URL('https://api.github.com/users/octocat/repos');
url.searchParams.set('sort', 'updated');
url.searchParams.set('per_page', '5');
const response = await fetch(url, {
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
},
});
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.github.com/users/octocat/repos")
q := baseURL.Query()
q.Set("sort", "updated")
q.Set("per_page", "5")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.github.com/users/octocat/repos")
uri.query = URI.encode_www_form({
"sort" => "updated",
"per_page" => "5"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer YOUR_ACCESS_TOKEN"
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.github.com/users/octocat/repos?" . http_build_query([
"sort" => "updated",
"per_page" => "5"
]);
$opts = ["http" => [
"method" => "GET",
"header" => implode("\r\n", [
"Authorization: Bearer YOUR_ACCESS_TOKEN"
]),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Returns the profile of the authenticated user. Requires a valid PAT.
Hover any highlighted part to learn what it does
| Accept | application/vnd.github+json |
| Authorization | Bearer YOUR_TOKEN |
curl -X GET "https://api.github.com/user" \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
headers = {
"Accept": "application/vnd.github+json",
"Authorization": "Bearer YOUR_ACCESS_TOKEN"
}
response = requests.get(
"https://api.github.com/user",
headers=headers,
)
print(response.json())const url = 'https://api.github.com/user';
const response = await fetch(url, {
headers: {
'Accept': 'application/vnd.github+json',
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
},
});
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
)
func main() {
targetURL := "https://api.github.com/user"
req, _ := http.NewRequest("GET", targetURL, nil)
req.Header.Set("Accept", "application/vnd.github+json")
req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.github.com/user")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
req["Accept"] = "application/vnd.github+json"
req["Authorization"] = "Bearer YOUR_ACCESS_TOKEN"
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.github.com/user";
$opts = ["http" => [
"method" => "GET",
"header" => implode("\r\n", [
"Accept: application/vnd.github+json",
"Authorization: Bearer YOUR_ACCESS_TOKEN"
]),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Postman Setup Guide
- Create a new GET request to https://api.github.com/users/octocat
- Add a header: Accept = application/vnd.github+json
- Send — no auth needed for this public endpoint
- For authenticated requests: go to the Authorization tab, select Bearer Token, paste your PAT
- Create a PAT at GitHub → Settings → Developer Settings → Personal access tokens → Generate new token
- Tip: store the token as a Postman variable {{github_token}} and reference it in the Authorization tab
What can you build with GitHub REST API?
GitHub REST API is a Company API. Developers commonly use company APIs for:
- enriching CRM records with company firmographics
- building lead-generation and prospecting tools
- verifying business identity and registration details
- monitoring competitors and market intelligence
- powering B2B data enrichment pipelines
Bearer token. Your app exchanges credentials for a short-lived token, then sends it as an Authorization header. Tokens expire, so your code needs to handle renewal.
New to APIs? Read our beginner's guide · Learn about API keys · What is REST?