Introduction to REST
REST, or (REpresentational State Transfer), is an architecture for developing web services. It enables communication between a client and server using HTTP protocols.
REST-compliant machines communicate with each other using
stateless messaging. Stateless messaging is a loosely coupled connection between a client and server, where each message is self-contained. This connection enables the client and server to communicate without first establishing a communication channel and without managing the state between systems.
- Client/Server model: Clients and servers are independent from each other, enabling portability and scalability.
- Stateless Communication: Each request is independent.
- Uniform Interface: Architecture is simplified through uniform standards.
A REST message consists of these four components:
- Endpoint: The endpoint is a Uniform Resource Identifier (URI) that shows where and how to find the resource on the internet. For example, to test an authorization request, you could send the request to this endpoint:.https://apitest.cybersource.com/pts/v2/payments
- HTTP Method: The method is the action performed by the resource. There are four basic HTTP methods:
- POST: Create a resource.
- GET: Retrieve a resource.
- PATCH: Modify a resource.
- DELETE: Delete a resource.
- Headers: The header is a collection of fields and their associated values. It provides information about the message to the receiver. Think of it as metadata about the message. The header also contains authentication information that indicates that the message is legitimate.
- Body: The request in JSON format.