About Lesson
Key Features of REST API
1.Stateless
Every request must contain all required information; the server does not store client session data.
Example:
- You log in to a website.
- The next time you request user data, you must send your login token again.
- The server does not remember your session.
2.Client-Server Architecture
The frontend (client) and backend (server) are separate.
Example:
- A mobile app fetches data from a server using an API.
- The same API can also be used by a web app.
3.Cacheable
API responses can be stored (cached) to improve speed.
Example:
- When you open a news app, the latest news articles load instantly because they were cached.
- The app does not fetch the data from the server every time.
4.Uniform Interface
REST APIs use a consistent structure.
Example:
- To get user data, the endpoint is always /users/{id}.
- To delete a user, the endpoint is always /users/{id} with a DELETE request.
5.Layered System
Requests pass through multiple layers, such as security and caching, before reaching the server.
Example:
- When you visit a website, your request first goes through:
- A firewall (security layer).
- A load balancer (manages traffic).
- The API server (processes the request).