APIs and JSON, hands on
How apps ask other services for data: endpoints, methods, status codes and JSON, with a real API you can try in your browser.
What an API is
An API is a menu of requests another program accepts. Each item on the menu is an endpoint, a URL like https://api.github.com/users/octocat. Your app sends a request; the service sends back a response, usually as JSON, a simple text format for data. Payments, maps, AI models and weather all work this way.
The parts of a request
- Method: GET reads data, POST creates something, PATCH or PUT updates it, DELETE removes it.
- URL and query parameters: /repos?per_page=5 asks for five results.
- Headers: extra details, like Authorization: Bearer <key> to prove who's asking.
- Body: the data you send with POST or PATCH, usually JSON.
Reading the response
The status code says how it went: 200 OK, 201 created, 400 something's wrong with the request, 401 not signed in, 403 not allowed, 404 not found, 429 too many requests, 500 the server failed. JSON uses { } for objects with named fields and [ ] for lists, so { "user": { "name": "Sam" } } gives you the name at user.name. Always check the status before using the data.
Try one, then use them safely
Open https://api.github.com/users/octocat in your browser: that's real JSON from GitHub's public API. In the browser Console you can run fetch('https://api.github.com/users/octocat').then((r) => r.json()).then(console.log). For APIs that need a key, call them from your server with the key in an environment variable, read the docs for limits and costs, handle errors and rate limits, and send only the data the service needs.
Key terms
- API
- An agreed way for one piece of software to ask another for something.
- Endpoint
- One URL an API answers, like /users/octocat, each doing one job.
- HTTP method
- The verb of a web request: GET reads, POST creates, PATCH or PUT updates, DELETE removes.
- JSON
- A simple text format for data that apps send to each other: names and values in curly braces.
- HTTP status code
- A number a server sends back: 200 OK, 401 not signed in, 403 not allowed, 404 not found, 500 server error.
- API key
- A secret code that identifies your app to a service and is often tied to billing.
- Rate limit
- The most requests or tokens a key may use in a period, such as per minute.
- Environment variable
- A setting or secret the app reads at run time, kept outside the code.
Try it
Your first API calls
- Open https://api.github.com/users/octocat in your browser and find the name and public_repos fields.
- Run the fetch line from the guide in your browser's Console and expand the result.
- Change the URL to a user that doesn't exist and note the status code.
- Ask an AI to write a tiny page that shows a GitHub user's name and avatar, checking response.ok first.
Ask an AI tutor about this guide
Copy a prompt into ChatGPT, Claude or Gemini to go deeper. Check what it tells you against the guide.
- Explain it like I'm 12
- Quiz me (5 questions, one at a time)
- Show me a real example for my situation
- What do beginners get wrong?
Knowledge check
Five questions. Get 4 right to earn the API Explorer badge. You can retake it as often as you like.
Question 1 of 5
Finished the How software works guides? Take the How software works track test for ten mixed questions.
My notes
Write what clicked, what confused you, and what you want to try. Saved in this browser only.
Learn it live
Digital Builders University runs small live workshops where you build something real with an instructor beside you, starting with Vibe Coding 101.
See workshopsPractise it
- Code playground: Objects and JSON (edit and run it in your browser)
- Game: Code Scramble (put the lines of a working program back in order)
Official sites
Last reviewed November 25, 2026. AI tools change fast; check each tool’s own site for current features, plans and prices.
