Skip to content
BENIBIX Learn

REST API

Development🔌 APIsAPI Architecture Styles

Also known as REST, RESTful API, Representational State Transfer

A web API where each thing has its own address, and HTTP methods act on it.

Think of it like

Think of it like a library. Each book has its own shelf number.

Example

Jack's REST API has /books and /books/7. GET /books/7 reads book 7, and DELETE /books/7 removes it.

Why it matters

Most public web APIs follow REST. Learn it once and you can use thousands of them.

Definition

A REST API gives each thing, called a resource, its own web address. You act on them with the normal HTTP methods: GET to read, POST to create, PUT or PATCH to change and DELETE to remove. Each request carries everything the server needs, so the server keeps no memory between requests. Answers are usually JSON. REST was described by Roy Fielding in 2000 and is the most common style of web API.

Example code

http
GET /books/7 HTTP/1.1
Host: api.example.com
Accept: application/json
The address names the book; the method says what to do with it.

Common mistake

Putting verbs in addresses, like /getBook?id=7. In REST, the address names the thing and the method is the verb.

Key takeaways

  1. 1
    Things have addresses. Called resources.
  2. 2
    Methods are the verbs. GET, POST, PUT, DELETE.
  3. 3
    No memory between calls. Each request stands alone.

Compare