REST API Introduction
Imagine you are at a restaurant. You (the client) look at the menu, place an order, and the kitchen (the server) prepares your food and brings it back. You don't need to know how the kitchen works – you just need to know what dishes are available and how to order them.
REST APIs work exactly like this restaurant. They allow different applications (web, mobile, desktop) to communicate with each other over the internet using standard HTTP methods.
REST APIs work exactly like this restaurant. They allow different applications (web, mobile, desktop) to communicate with each other over the internet using standard HTTP methods.
What is REST?
REST stands for Representational State Transfer. It is an architectural style for designing networked applications. It uses HTTP protocols and is stateless, meaning each request contains all the information needed to process it.
REST Principles:
- Client-Server – Separation of concerns (frontend and backend independent).
- Stateless – Server does not store client state between requests.
- Cacheable – Responses must define themselves as cacheable or not.
- Uniform Interface – Consistent way to interact with resources.
- Layered System – Client cannot tell if it's connected directly to the end server.
In Spring, we build REST APIs using
@RestController. Here is the simplest REST API:@RestController
public class HelloController {
@GetMapping("/hello")
public String sayHello() {
return "Hello, World!";
}
}
When you visit
http://localhost:8080/hello, you get back the text "Hello, World!" – that's your first REST API!Two Minute Drill
- REST is an architectural style for building web services.
- It uses standard HTTP methods (GET, POST, PUT, DELETE).
- REST APIs are stateless – each request is independent.
- Resources are identified by URLs (e.g., /api/users).
- In Spring, @RestController creates REST APIs easily.
Need more clarification?
Drop us an email at career@quipoinfotech.com
