REST API Architecture 1. Overview → REST (Representational State...

1. Overview
→ REST (Representational State Transfer) is an architectural style for designing networked applications.
→ It uses HTTP methods to perform operations on resources represented by URLs.
→ REST APIs are stateless, cacheable, and designed around resources rather than actions.
2. Core Principles
→ Client-Server Architecture
The client handles the user interface while the server manages data and logic.
This separation allows scalability and independent development.
→ Statelessness
Each request contains all necessary information.
The server does not retain session data between requests.
This simplifies scaling and reliability.
→ Cacheability
Responses must specify whether they can be cached.
Proper caching reduces server load and improves performance.
→ Uniform Interface
REST enforces a consistent and predictable way to access resources.
Use clear URIs, standard HTTP verbs, and consistent data formats.
→ Layered System
REST allows a layered architecture including proxies, firewalls, and load balancers.
Each layer works independently and communicates only with its immediate neighbor.
→ Code-on-Demand (Optional)
The server can send executable code (like JavaScript) to the client when necessary.
3. Core Components
→ Resources
Everything in REST is a resource such as users, posts, or products.
Each resource is uniquely identified by a URI.
→ URIs (Uniform Resource Identifiers)
Example structure:
GET /users
GET /users/{id}
POST /users
PUT /users/{id}
DELETE /users/{id}
→ HTTP Methods
GET → Retrieve a resource
POST → Create a new resource
PUT → Update an existing resource
DELETE → Remove a resource
→ Representation
Resources are represented in formats such as JSON or XML.
Clients interact with these representations to exchange data.
4. Advantages
→ High scalability and performance
→ Simplified client-server communication
→ Easy integration with various platforms
→ Better maintainability and flexibility
→ Lightweight compared to complex protocols like SOAP
Grab this Ebook to Master APIs: codewithdhanian.gumroad.com/l/jnnhn

