Calling the GitHub API
Explore a production API — public data without a key
⏱ Est. ~9 min
01 · Read
The GitHub REST API is one of the best APIs to practice on: - Free for public data — no key needed - Detailed docs at docs.github.com/en/rest - Real data — your real repos, commits, and profile - Standard patterns — what you learn here applies to most REST APIs
The base URL is https://api.github.com. Every endpoint hangs off that.
Key points
- Public data doesn't require an API key (max 60 requests per hour per IP)
- Authenticated requests get 5,000 requests per hour
- It's recommended to add the Accept: application/vnd.github.v3+json header
- Response data usually has more fields than you'll use — just pick what you need
02 · Real-machine exercise
Fetch your own GitHub profile (or any public user). Replace torvalds with any GitHub username.
curl https://api.github.com/users/torvalds
03 · Real-machine exercise
List that user's public repos.
curl https://api.github.com/users/torvalds/repos
04 · Real-machine exercise
Add query parameters to filter results — get the 3 most recently updated repos, sorted by update time.
curl "https://api.github.com/users/torvalds/repos?sort=updated&per_page=3"
05 · Real-machine exercise
Now try with your own GitHub username. Replace YOUR_USERNAME below.
curl "https://api.github.com/users/YOUR_USERNAME/repos?sort=updated&per_page=5"
06 · Quiz
What's the base URL of the GitHub API?
- api.github.com
- github.com/api
- rest.github.com
- github.api.com
07 · Fill in the blank
To list a user's repos from the GitHub API, use the path /users/USERNAME/_____.
Other lessons in this chapter
⚠ The full interactive experience needs JavaScript. Please enable it and reload.
※ This is an independent Traditional Chinese teaching project — not an official Anthropic product. Claude™ is a trademark of Anthropic, PBC.