DEV Community

Cover image for Learn REST API Easily
Vidya
Vidya

Posted on

Learn REST API Easily

What is REST API?
A REST API (Representational State Transfer Application Programming Interface) is a way for applications to communicate with each other using HTTP methods like GET, POST, PUT, and DELETE. It allows clients and servers to exchange data, usually in JSON format. Each resource is identified using a unique URL such as http://localhost:8080/products. REST APIs are widely used in web and mobile applications because they are simple, fast, and scalable.

When we used REST API?
We use REST APIs when different applications need to communicate and share data with each other. They are commonly used to connect frontend applications with backend servers. REST APIs are also used in web and mobile applications to perform operations like creating, reading, updating, and deleting data. They help applications work efficiently across different platforms and technologies.

Example:

Example:
http://localhost:8080/users

This is a REST API endpoint used to manage user data from the server.

localhost → Your local machine where the application runs
8080 → Port number of the server
/users → Resource that contains user information

Operations:

GET /users → Get all users
GET /users/1 → Get user with ID 1
POST /users → Add a new user
PUT /users/1 → Update user details
DELETE /users/1 → Delete user with ID 1

Image Format:

Top comments (0)