Uni-Sine
Computer ScienceCourses

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

SectionsTopicWhat you do
1 to 3What an API is, and how it connects systemsMatch each part of an API to a restaurant analogy
4 to 6HTTP methods: GET, POST, PUT and DELETEPick the right method for each scenario
7 to 9URLs, endpoints, routes and parametersPut the parts of a URL in order
10 to 12Request and response structureLabel the parts of a raw request and response
13 to 15JSON and nested dataType the dot and bracket notation that pulls a value out of JSON
16 to 18Status codesFill in a table of codes and their meanings
19 to 21REST principles and RESTful URLsDecide whether each method and URL follows REST
22 to 24Authentication, API keys and tokensSpot the code that exposes a key
25 to 26Error handlingAdd error handling to a fetch call
27 to 29Building endpoints with ExpressWrite a GET route that returns a product or a 404
30 to 32Making requests with fetch, and putting it togetherWrite 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.

Guided courseDatabasesWhat sits behind most APIs: tables, SQL queries, relationships and joins.

Common questions

Is this API course free?
You can take every section without paying, two sections a day, in order. A plan removes the daily limit and opens any section straight away.
What should I learn first for APIs?
How HTTP requests and responses work, then JSON, then status codes. After that, REST design and writing fetch calls make sense. This course follows that order.
What is a REST API?
An API that follows the REST style: each URL names a resource, such as /users/7, and the HTTP method says what to do with it, such as GET to read it or DELETE to remove it. Responses are usually JSON.
What do HTTP status codes mean?
They are three-digit codes on every response. Codes starting with 2 mean success, such as 200 OK and 201 Created. Codes starting with 4 mean the request was wrong, such as 404 Not Found. Codes starting with 5 mean the server failed.
Do I need to know how to code for this course?
Not for most of it. The coding comes in the last sections, where you write an Express route and a fetch call. Basic JavaScript is enough for those.
What is the difference between an API key and a token?
An API key is a long-lived secret that identifies an app. A token usually identifies a signed-in user, expires after a while and is issued after logging in. Both must be kept secret.

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
Read next
Computer Science · Web and APIsWhat does API stand for? APIs explained with examplesWhat API stands for, how an API works, what an API call is, with a real request and response, plus API types, API access and API testing.