An API is the contract between your backend and everything that talks to it: your website, your mobile app, a partner's system. Two styles dominate today — REST and GraphQL — and the debate between them is usually louder than the actual difference in outcome. Here is how to think about it without the hype.
How REST works
REST models your data as resources, each with its own URL — for example /orders/42 — and uses standard HTTP methods: GET to read, POST to create, PUT or PATCH to update, DELETE to remove. Every endpoint returns a fixed shape of data. Because it is built on plain HTTP, responses cache well in browsers and CDNs, and almost every tool, framework and developer already knows it.
How GraphQL works
GraphQL exposes a single endpoint and a typed schema. The client sends a query that names exactly the fields it wants — an order, its customer's name and the titles of its items — and the server returns that shape and nothing more. It was created at Facebook to serve many different mobile and web clients from one backend.
Where each one fits
- REST suits straightforward create-read-update-delete systems, public APIs, webhooks and anything that benefits from HTTP caching.
- GraphQL suits products with several different clients (web, iOS, Android) that each need different slices of the same data.
- GraphQL is also helpful when screens combine deeply related data and REST would need many round trips to assemble it.
The trade-offs people forget
- GraphQL needs query-depth and cost limits, otherwise one expensive query can slow the whole server.
- HTTP caching is simpler with REST; with GraphQL you usually cache at the application layer.
- REST can over-fetch (returning fields you don't need) or under-fetch (forcing several calls), which GraphQL was designed to avoid.
- GraphQL adds tooling and a learning curve to a small team.
A practical rule of thumb
Start with REST unless you can name a concrete problem it cannot solve — usually several clients with very different data needs. A well-designed REST API with clear naming, pagination and consistent error responses carries most products a long way, and you can add GraphQL later for the parts that truly benefit.