REST (Representational State Transfer) is described in the original dissertation as an "architectural style for distributed hypermedia systems." There are several key features of a REST API:
- It separates the client representation from the server data
- It is stateless
- It is cacheable
- It relies on a uniform interface, generally HTTP verbs
- It leverages a decoupled, layered system
Many people consider any API that uses a Universal Resource Indicator (URI) style to be REST by comparing it against other protocols like SOAP, AMF, or CORBA. REST, however, is specific to acting on resources using the correct HTTP verb. If you are performing some other action on the system, it's a Remote Procedure Call (RPC). The following table uses some examples to compare the two styles:
| Operation | RPC style | REST style |
|
Login |
POST /login |
POST /session |
|
Logout |
GET /logout |
DELETE /session/id |
|
Create user |
POST /addUser |
POST /user |
|
Update a node |
POST /updateNode |
PATCH /node/id |
With traditional REST architecture, you don't login, you create a new session resource; you don't logout, you delete your current session. This encourages consistency because you have a limited number of resources and a limited number of operations on them from the HTTP verbs.