Contents

Web & Networking › API Styles & Formats

API

An interface that lets programs talk to each other.

Also known as: application programming interface, web API, REST API

An API (application programming interface) is a defined way for one piece of software to ask another to do something, without knowing how it works inside. You use the interface, and the provider handles the details.

You use APIs all the time:

  • A library’s functions: Math.round(2.5) or requests.get(url).
  • The operating system’s calls: open a file, create a thread.
  • A web API: send an HTTP request to a service, and get data back.
const res = await fetch("https://api.example.com/users/42");
const user = await res.json();

Web APIs

When people say “API” in backend and frontend work, they usually mean a web API: a set of endpoints a program can call over HTTP, exchanging JSON.

StyleIdea
RESTresources at URLs, with HTTP methods
GraphQLthe client asks for exactly the fields it wants
gRPCfast, typed calls between services

What an API promises

An API is a contract: what you send, what you get back, what errors can happen. As long as the contract holds, the provider can change the internals freely, and consumers don’t break (API design, backward compatibility).

Working with one

Your own services are APIs too, and designing them well is a core backend skill.