REST is a design pattern (for APIs) and describes how network resources are accessed.
REST is not a standard nor a protocol.
By using a REST interface, different clients can hit the same REST endpoints, perform CRUD actions via HTTP mehods.
This architecture pattern makes the interaction between a client and a server uniform with a well-defined API, so that different clients (OS and browsers can all work with the API in the same way).
URL | HTTP verb | Request body | Action | Success Status Code |
---|---|---|---|---|
/api/projects |
GET |
(empty) | Returns all projects | 200 OK |
/api/projects |
POST |
JSON | Creates a new project | 201 Created |
/api/projects/:i |
GET |
(empty) | Returns the single project | 200 OK |
/api/projects/:i |
PUT |
JSON | Edits the projects | 200 OK |
/api/projects/:id |
DELETE |
(empty) | Deletes the projects | 204 No Content |
**HTTP methods are what defines operations in well-formed REST APIs, not the URLs. **
URLs should not contain verbs.
When we want to retrieve, modify, or delete a record, we operate by making the request and using the correct HTTP method.
Well-designed REST APIs must provide response status code that makes it clear there is a problem.