APIs: an interactive API course
APIs is an interactive API course that takes you from "what is an API?" to writing your own endpoint and calling it. Its 32 short sections cover HTTP methods, URLs and parameters, the parts of a request and a response, JSON, status codes, REST design, API keys and tokens, error handling, building routes in Express and making requests with fetch.
An API (application programming interface) is how one program asks another for data or to do something. Every app that shows the weather, takes a payment or signs you in with another account is using APIs. Our guide what is an API covers the idea on its own.
What the API course covers
| Sections | Topic | What you do |
|---|---|---|
| 1 to 3 | What an API is, and how it connects systems | Match each part of an API to a restaurant analogy |
| 4 to 6 | HTTP methods: GET, POST, PUT and DELETE | Pick the right method for each scenario |
| 7 to 9 | URLs, endpoints, routes and parameters | Put the parts of a URL in order |
| 10 to 12 | Request and response structure | Label the parts of a raw request and response |
| 13 to 15 | JSON and nested data | Type the dot and bracket notation that pulls a value out of JSON |
| 16 to 18 | Status codes | Fill in a table of codes and their meanings |
| 19 to 21 | REST principles and RESTful URLs | Decide whether each method and URL follows REST |
| 22 to 24 | Authentication, API keys and tokens | Spot the code that exposes a key |
| 25 to 26 | Error handling | Add error handling to a fetch call |
| 27 to 29 | Building endpoints with Express | Write a GET route that returns a product or a 404 |
| 30 to 32 | Making requests with fetch, and putting it together | Write a fetch call that sends JSON and logs the reply |
How requests work
The first half explains the conversation between client and server. A request has a method, a URL, headers and sometimes a body. A response has a status code, headers and usually a body of JSON. Once you can read both, any API's documentation starts to make sense.
Designing and securing APIs
REST is the common style for web APIs: URLs name things, such as /products/42, and HTTP methods say what to do with them. The course then covers how APIs know who is calling, with API keys and tokens, and why a key must never sit in code that reaches the browser. The what is an API key guide goes deeper on that.
Writing code
The last part has you write both sides: a small Express server with GET, POST and DELETE routes, and fetch calls from the browser that send JSON and handle errors.
const res = await fetch("/api/products/42");
if (!res.ok) throw new Error("Request failed: " + res.status);
const product = await res.json();
console.log(product.name);Try a question from the course
Each HTTP method has a job. GET reads data without changing anything. POST creates something new, such as a new comment. PUT replaces something that exists, and DELETE removes it. So loading a list of products is a GET, and submitting a sign-up form that creates an account is a POST.
Now pick the method for a new scenario, then press Mark to check your answer in the course.
Pick the correct HTTP method for each scenario.
Press Mark to have your answer marked in the APIs course.
Who this course is for
- Beginner developers who can write a little JavaScript and want to connect their sites to real data.
- Students on computing or web courses who need to understand how the web's services talk to each other.
- Designers, analysts and product people who work with developers and want to follow the conversation about endpoints and status codes.
What you need to know first
Basic JavaScript, such as variables, functions and objects, for the coding sections at the end. The HTML, CSS & JavaScript course is a good start. The first two thirds need no coding at all.
How long it takes
There are 32 sections and most take a few minutes. Learners without a plan can open two sections of a course a day, in order, so the whole course takes 16 days. A plan removes the daily limit and lets you go straight to any topic, such as status codes or fetch.
Common questions
Is this API course free?
What should I learn first for APIs?
What is a REST API?
What do HTTP status codes mean?
Do I need to know how to code for this course?
What is the difference between an API key and a token?
Revision cards
Say the answer first, then flip the card to check it.
Where to go next
- Solve it
Code Editor
Write and run code right in your browser
Open the tool - Learn it
APIs
Build and consume RESTful APIs that connect systems together
Start the course