From Wikipedia, we have “a set of Routines, protocols and tools for building software applications”.
Re presentation S tate T ransfer is a software architecture style consisting of guidelines and best practices for creating scalable web services. REST is a coordinated set of constraints applied to the design of components in a distributed hypermedia system...
Typically, communicate over HTTP, using same HTTP verbs used by web browsers to retrieve web pages and send data to remove servers.
- Performance
- Scalability
REST’s client-server separation of concerns simplifies component implementation, reduces the complexity of connector semantics, improves the effectiveness of performance tuning, and increases the scalability of pure server components. Layered system constraints allow intermediaries—proxies, gateways, and firewalls—to be introduced at various points in the communication without changing the interfaces between components, thus allowing them to assist in communication translation or improve performance via large-scale, shared caching. REST enables intermediate processing by constraining messages to be self-descriptive: interaction is stateless between requests, standard methods and media types are used to indicate semantics and exchange information, and responses explicitly indicate cacheability.
- Simplicity
- Modifiability
- Portability
- Reliability
- Client-server
- Stateless (idempotent) -> No seesion: OAuth2
- Cacheable: how to cache HTTP?
- Layered System
- Uniform Interface (Identification of resources, Manipulations of resources through representations, Self-descriptive messages, Hypermedia as the engine of application state)
Implementators should be aware that the software represents the user in their interactions over the Internet, and should be careful to allow the user to be aware of any actions they might take which may have an unexpected significance to themselves or others.
Safe methods means that we won’t make change on the server (just return data). Idempotency means that you can make the same request multiple times and you will always get the same result.
- GET
-
- “no side effects”: user cannot be accountable for them
-
- Conditional GET (specific headers for caching)
-
- Partial GET (range header)
- HEAD: Similar to GET, but server MUST NOT return a message-body. Check for headers.
- POST (not Idempotent??) -> https://www.masteringmodernpayments.com/blog/idempotent-stripe-requests
- PUT/PATCH
- DELETE (200, 202, 204, 404)
- OPTIONS
- TRACE: message sent == message returned
- CONNECT: tunneling