Find a course

Module 1: APIs and HTTP BasicsLesson 1 of 1211 min

What Is an API?

Learn what an API is, why nearly every app depends on dozens of them, and how clients and servers cooperate through a contract of requests and responses.

Step 1 of 13Learn

The app that knows tomorrow's weather

Open a weather app and it shows the forecast for your city within a second. The app's developers didn't launch satellites or run climate models. Their app sent a short message over the internet to a weather service, something like "forecast for latitude 59.9, longitude 10.7, please", and got back a structured answer with temperatures, wind and rain chances. The app then drew that data on your screen.

That exchange happened through an API, an application programming interface: a defined way for one piece of software to ask another for data or actions. The weather service publishes the rules: which addresses to call, what to send, what comes back, and what errors look like. Any app that follows the rules can use the service, and the service can change its internals freely as long as it keeps its promises.

APIs are everywhere:

  • A ride-sharing app uses a maps API to draw streets and a payments API to charge your card.
  • A "Sign in with..." button uses an identity API.
  • An online store calls a shipping API for delivery quotes and a tax API for sales tax.

A typical modern app depends on dozens of APIs. Learning how they work lets you build on other people's services instead of reinventing them, and it's a core skill for front-end, back-end, mobile and data work alike.

Step 2 of 13Diagram

What happens in the second after you open a weather app

Tap each stage. The app only ever talks to the API; everything behind it stays hidden.

What happens in the second after you open a weather appProcess diagram: You open the app → App sends a request → Server finds the data → Server sends JSON back → App draws the screen.You open the appApp sends a requestServer finds thedataServer sends JSONbackApp draws thescreen

Tap a shape with to see more.

You open the app

The app knows your city from settings or location.

App sends a request

A short HTTP message such as GET /forecast?city=Denver to the weather service.

Server finds the data

The weather company looks up its latest forecast in its own systems.

Server sends JSON back

Temperatures, icons and times as structured data, not a finished screen.

App draws the screen

The app turns the data into its own design.

Step 3 of 13Practice · Select all that apply

Which of these are examples of one program using another program's API? Select all that apply.

Select all that apply.

Step 4 of 13Learn

Clients, servers and contracts

Every web API conversation has two roles:

  • The client is the program that asks. It might be a mobile app, a website running in a browser, a script on your laptop or another server.
  • The server is the program that answers. It owns the data or the capability and decides what to share.

The client sends a request; the server sends back a response. The client always starts the conversation. A server can't normally push data to a client that hasn't asked (later in the course you'll see webhooks and other ways around that).

What makes it work is the contract: the documented rules both sides agree on. A good API contract specifies:

  1. the address (URL) of each operation, such as https://api.example.com/v1/forecast;
  2. the inputs it accepts and which are required;
  3. the format of the response, usually JSON;
  4. the errors that can occur and how each is reported;
  5. the limits, such as how many requests per minute are allowed, and how to authenticate.

The contract is what lets thousands of independent developers build on one service. It's the same idea as encapsulation in programming: callers depend on the published interface, never on the hidden implementation behind it.

A client sends an HTTP request to a server and receives a responseClientapp, browserServerthe APIGET /weather?city=Oslo200 OK + JSON body

Step 5 of 13Practice · Match the pairs

Match each term to its role in an API conversation.

Tap an answer, then tap the place where it belongs (or drag it there).

  1. Client
  2. Server
  3. Request
  4. Response
  5. Contract

Step 6 of 13Learn

Not every API is a web API

"API" is a broad term. It means any interface that one piece of code offers to another.

  • Library APIs: when you call Math.max(3, 7) in JavaScript or len(items) in Python, you're using the language's built-in API. Libraries such as charting or date packages also expose APIs as functions and classes you call directly, in the same program.
  • Operating system APIs: programs ask the operating system to open files, draw windows or use the camera through system APIs.
  • Browser APIs: web pages use the browser's APIs for location, storage, notifications and more.
  • Web APIs: programs talk over the network using HTTP, usually exchanging JSON. These are what most people mean by "API" today, and they're the focus of this course.

Within web APIs there are several styles. REST is by far the most common for public APIs: it organizes everything around resources such as /users and /orders and uses standard HTTP methods. You'll also meet GraphQL, where the client describes exactly which fields it wants, gRPC, a fast binary protocol often used between internal services, and webhooks, where the server calls you when something happens.

This course concentrates on REST and JSON, because once you understand them, the other styles are variations on familiar ideas.

Step 7 of 13Practice · Sort into groups

Sort each example into the kind of API it uses.

Tap an item, then tap its group (or drag it there).

Step 8 of 13Timeline

A short history of web APIs

  1. 1990s
    Early remote calls

    Systems used remote procedure call protocols and, later, XML-based SOAP services with strict, verbose contracts.

  2. 2000
    REST is described

    Roy Fielding's doctoral dissertation defines REST as an architectural style based on how the web itself works.

  3. Mid-2000s
    Public web APIs spread

    Online stores, photo sites and maps open public APIs, and developers combine them into new apps.

  4. 2010s
    JSON wins

    JSON replaces XML as the default data format for most new APIs; mobile apps rely on REST and JSON everywhere.

  5. 2015 onward
    More styles

    GraphQL, gRPC and event-driven webhooks become common alongside REST, which remains the most widely used style for public APIs.

Step 9 of 13Note

Step 10 of 13Learn

Public, partner and private APIs

APIs also differ in who is allowed to use them.

  • Public (open) APIs are offered to any developer who signs up, sometimes free, often with a free tier and paid plans above it. Weather data, maps, payments, email delivery and AI models are commonly sold this way.
  • Partner APIs are shared only with approved business partners under a contract: an airline exposing seat inventory to selected travel agencies, or a bank sharing data with licensed apps.
  • Private (internal) APIs connect a company's own systems. A large company might run hundreds of internal services, such as accounts, search, recommendations and billing, that talk to each other only through APIs.

Most API traffic in the world is actually internal. Splitting a big application into services that communicate through APIs lets separate teams work and deploy independently, as long as each team keeps its contract stable.

For you as a developer, the kind of API changes the practical details: public APIs come with sign-up pages, keys, pricing and rate limits; partner APIs come with contracts and onboarding; internal APIs come with a colleague you can message when the docs are unclear. The technical skills, HTTP, JSON and reading documentation, are the same for all three.

Step 11 of 13Practice · Sort into groups

Classify each API by who can use it.

Tap an item, then tap its group (or drag it there).

Step 12 of 13Practice · True or false

An API is only useful to programmers who work at the company that built it.

Step 13 of 13Practice · Choose one

A weather service rewrites its forecasting system in a different programming language, but keeps every URL, input and response format the same. What happens to the apps that use its API?