GET /repos/facebook/react • HTTP 200 OK

GitHub Repositories Public API Example — Request & Response Example

Demonstrates consuming GitHub’s world-class REST API without authentication for public open-source repository statistics.

1. HTTP Client Request (GET)

GET /repos/facebook/react HTTP/1.1
{
  "Accept": "application/vnd.github.v3+json",
  "User-Agent": "Cometflow-API-Client"
}

2. Server JSON Response (HTTP 200 OK)

{
  "name": "react",
  "full_name": "facebook/react",
  "description": "The library for web and native user interfaces.",
  "html_url": "https://github.com/facebook/react",
  "stargazers_count": 228914,
  "forks_count": 46210,
  "open_issues_count": 1420,
  "license": {
    "key": "mit",
    "name": "MIT License"
  }
}

Copy-Paste Code Snippets (cURL, JavaScript Fetch, Python, Node.js)

curl -H "Accept: application/vnd.github.v3+json" \
  -H "User-Agent: MyApp" \
  "https://api.github.com/repos/facebook/react"
fetch('https://api.github.com/repos/facebook/react', {
  headers: {
    'Accept': 'application/vnd.github.v3+json',
    'User-Agent': 'MyApp'
  }
}).then(res => res.json()).then(repo => console.log(`Stars: ${repo.stargazers_count}`));
import requests

headers = {"Accept": "application/vnd.github.v3+json", "User-Agent": "MyApp"}
res = requests.get("https://api.github.com/repos/facebook/react", headers=headers)
print(res.json()["stargazers_count"])

How This API Call Works Step-by-Step

  1. 1. Custom Header: Accept header specifies GitHub API version 3.
  2. 2. User-Agent Mandatory: GitHub requires a User-Agent header on all requests.
  3. 3. Rate Limit Headers: Response headers tell client how many unauthenticated requests remain this hour.

Backend API Functions: The GitHub repository handler queries git metadata clusters and caches output with strong HTTP ETags.

Frequently Asked Questions

Why does GitHub require a User-Agent header?

GitHub requires User-Agent to identify the application or script consuming resources, enabling their engineering team to reach out or throttle bad actors.