ENES

REST API

The most common style of web API: things have URLs and you act on them with HTTP verbs.

An app sends GET, POST, PUT and DELETE requests to URLs like /orders/42, and the server answers with JSON and a status code

A REST API is an API designed around a simple idea: everything the system knows about is a resource with its own URL, and you use the standard verbs of HTTP to act on it. GET /orders/42 reads order 42, POST /orders creates a new one, PUT /orders/42 replaces it and DELETE /orders/42 removes it. The answer usually comes back as JSON.

The style was described by Roy Fielding in his 2000 doctoral thesis, and the name stands for REpresentational State Transfer. One of its rules is that each request is stateless: it carries everything the server needs to answer it, so the server does not have to remember previous requests. That makes REST APIs easy to spread over many servers and to cache.

Every answer also brings a status code, a three-digit number that says how it went: 200 means OK, 201 created, 404 not found, 401 you are not logged in, 500 the server failed. Because it reuses what the web already has, REST became the default way apps, websites and companies talk to each other. When people say "the Stripe API" or "the GitHub API", they usually mean a REST API.

Keep in mind

Go deeper

Related terms

More in Software