A simple API with rest, just for learning
- API (Application Programming Interface) is basically a group of routines and patterns established by an application, for other applications can use the functionality of this application.
- REST (REpresentational State Transfer) REST defines some obligations in data transfer, usually with HTTP protocol.
-
Client-server: Separation of client and data storage (server).
-
Stateless: Each requisition from the client to the server, must have all the necessary information for the server understand and response the requisition. The server cannot store information from the previous requisition (state).
-
Cacheable: The responses to one requisition must be explicit to say if that requisition can or not be cacheable for the client.
-
Layered System: The client don't need to knows the layers which the server is accessing to response the requisition.
-
Uniform Interface: The uniform interface simplifies and decouples the architecture, which enables each part to evolve independently.
-
Code On Demand(optional): Make it possible for the application to take codes, such as JavaScript, for example, and execute them on the client.
- 1xx: information
- 2xx: sucess
- 200: Ok
- 201: Created
- 204: Don't have content PUT POST DELETE
- 3xx: Redirection
- 4xx: Client Error
- 400: Bad Request
- 404: Not Found
- 5xx: Server Error
- 500: Internal Server Error
I used the software Insomnia to test the routes.
- Disclaimer: the information was obtained by a video from RocketSeat on YouTube and at the following link: https://stackoverflow.com/questions/25172600/rest-what-exactly-is-meant-by-uniform-interface