A REST API (Representational State Transfer API) is a web service that adheres to the REST architectural style defined by Roy Fielding in 2000. REST has become the dominant approach for building web APIs because of its simplicity, scalability and compatibility with standard HTTP infrastructure.
Six REST Constraints
- Client–server separation — UI and data storage are decoupled.
- Statelessness — Each request contains all the information needed; no session state is stored on the server.
- Cacheability — Responses must define whether they are cacheable.
- Uniform interface — Resources are identified by URIs; operations use standard HTTP verbs.
- Layered system — The client cannot tell whether it is connected directly to the end server.
- Code on demand (optional) — Servers can send executable code to clients.
RESTful Resource Design
GET /articles— List all articles.GET /articles/42— Get article with ID 42.POST /articles— Create a new article.PUT /articles/42— Replace article 42.DELETE /articles/42— Delete article 42.