RESTful API Concepts
REST API (Representational State Transfer Application Programming Interface) is a software architectural style based on the HTTP protocol, used to build web application interfaces.
REST API is one of the most commonly used API design patterns in modern web service development.

What is an API?
Basic Concepts of API
API (Application Programming Interface) is like an "interpreter" between different software. Imagine you go to a foreign restaurant. You don't speak the local language, but the waiter speaks your language. He is the "interface" between you and the chef.
In the programming world, APIs enable different software systems to communicate and collaborate with each other. For example:
- Your mobile weather app needs to get weather data
- Your shopping app needs to process payments
- Your social media app needs to upload photos
The Role of API

The main roles of API include:
- Data exchange: allows different systems to transfer information
- Function reuse: avoids reinventing the wheel by using ready-made services
- System decoupling: allows the frontend and backend to be developed independently
- Security control: controls who can access what data
Real-life API Analogy
Think of an API as a restaurant menu:
- The menuis the API documentation, telling you what you can order
- Ordering foodis sending a request, telling the waiter what you want
- Serving the foodis receiving a response, getting the food you want
- The waiteris the API, responsible for passing your needs to the kitchen
What is REST?
The Meaning of REST
REST (Representational State Transfer) sounds complicated, but it is actually a set of rules and conventions for designing web APIs. Just as building a house requires following building codes, designing APIs also requires following certain standards.
The Six Principles of REST
1. Client-Server Architecture
The frontend (client) and backend (server) are completely separated, just like customers are separated from the kitchen.

2. Statelessness
Each request is independent, and the server does not remember previous requests. Just like every time you go to the bank to do business, you need to show your ID again.
3. Cacheability
Response data can be cached to improve performance, just like browsers cache webpage images.
4. Uniform Interface
All APIs follow the same rules and formats, just like all restaurant menus have similar structures.
5. Layered System
The system can have multiple layers, for example: Client → Load Balancer → API Server → Database
6. Code on Demand (Optional)
The server can send executable code to the client, such as JavaScript.
Why Choose REST?
- Simple and easy to understand: based on the HTTP protocol, easy to learn
- Lightweight: no additional protocol overhead required
- Scalable: new features can be easily added
- Cross-platform: any device that can send HTTP requests can use it