Skip to content
BENIBIX Learn

REST vs GraphQL

A REST API gives every thing its own address and uses HTTP methods on it. GraphQL sends every query to one address and lets the client pick the exact fields. REST is simpler to cache; GraphQL saves trips on a slow phone.

Development🔌 APIs

REST API

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

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
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.
Full entry
Development🔌 APIs

GraphQL

A way to ask an API for just the fields you want, in one go.

GraphQL is a query language that lets a client ask for exactly the fields it wants. All requests go to one address, and each one says the shape of the answer it expects. One request can gather data that a REST API would spread across several calls. The server publishes a schema that lists every type and field you can ask for. Facebook built it and released it to the public in 2015.

Example
Lucy's phone app needs a user's name and their last 3 orders. One GraphQL query fetches both, with no extra fields.
Why it matters
Apps on slow phone networks can fetch just what one screen needs in a single trip.
Full entry

In one line

REST API
A web API where each thing has its own address, and HTTP methods act on it.
GraphQL
A way to ask an API for just the fields you want, in one go.