REST API Explained with Simple Example

Technology has transformed the way we live, interact, and do business. From ordering food to booking a cab, every click on your mobile app triggers a series of powerful backend operations. But have you ever wondered how different applications talk to each other behind the scenes? The secret sauce that connects apps, databases, and servers together is something called an API. And when these APIs follow a particular structure known as REST, they become powerful, scalable, and easy to use.

In this article, we are going to explore what REST API really is and why it matters.

REST API Explained with Simple Example

We will walk you through its key principles, real world relevance, and a simple example to help you truly understand how it works. Whether you are just starting out in coding or managing a tech product, this guide will make REST API feel a lot more accessible. If you are ready to dive deeper into backend development, we also recommend checking out the Full Stack Web Development with NodeJS course by Uncodemy, where REST APIs are taught with practical hands-on experience.

Let us begin by understanding the core concept of an API.

What is an API

An API or Application Programming Interface is like a messenger between two software systems. Imagine you are at a restaurant. You look at the menu and tell the waiter what you want. The waiter then goes to the kitchen, gets your food, and delivers it back to your table. Here, you are the user, the kitchen is the server, and the waiter is the API.

In technical terms, APIs help one application request data or services from another application. For example, when you use a weather app on your phone, it fetches data from a server that hosts weather updates. That exchange happens through an API.

APIs make it possible for applications to interact without exposing their inner workings. They allow different systems to talk in a standardized way, just like how we all understand what a menu means at a restaurant.

What is REST in REST API

REST stands for Representational State Transfer. It is a set of design rules or principles that guide how APIs should be built. REST is not a programming language or a tool. Instead, it is a style of architecture for creating scalable and maintainable web services.

When an API is built following the REST principles, we call it a RESTful API. These APIs allow clients to interact with servers using simple HTTP requests. Since the internet already runs on HTTP, REST APIs fit naturally into modern web development.

Principles of REST API

To understand how REST APIs work, it is important to know the principles they are based on.

1. Stateless Communication

Each API call must contain all the information needed to complete the request. The server does not store any previous information about the client. Every interaction is independent, which makes the system easier to scale and debug.

2. Resource Based

In REST, data is treated as a resource. Each resource, like a user, a product, or an article, is identified through a unique URL. For example, a URL like https://api.company.com/products/1 refers to product number one.

3. Use of HTTP Methods

REST APIs rely on standard HTTP methods to perform operations:

  • GET is used to retrieve data
     
  • POST is used to add new data
     
  • PUT is used to update existing data
     
  • DELETE is used to remove data
     

This clear mapping makes it easier to understand what each request does.

4. Uniform Interface

REST APIs follow a consistent structure and naming convention. This makes it easier for developers to use them without needing extensive documentation.

5. Separation of Client and Server

The front end and back end are separated in REST architecture. This allows each part to evolve independently as long as the interface between them remains the same.

6. Layered System

A REST API can have multiple layers of servers between the client and the actual resource. This helps with load balancing and security.

Why REST API Matters for Modern Applications

Today’s digital systems are built to be fast, responsive, and connected. Whether you are creating a social media platform, a fitness tracking app, or an ecommerce website, chances are you will be dealing with lots of data. REST APIs make it easy to move that data between the client and server.

Here are a few reasons why REST APIs are preferred by developers and businesses:

  • They are simple to understand and implement
     
  • They use standard protocols like HTTP and formats like JSON
     
  • They are scalable due to their stateless nature
     
  • They can be used across different platforms and devices
     
  • They support multiple programming languages
     

In short, REST APIs bring flexibility and structure to your application architecture. They allow teams to build better products faster.

Real Life Analogy: Food Delivery Application

Let us take a relatable example. Suppose you are using a food delivery app. You want to view nearby restaurants, check out their menu, place an order, and track it in real time.

Here is how REST API helps at each step:

  1. When you open the app and search for restaurants, a GET request is sent to the server to fetch restaurant data.
     
  2. When you select a food item and click on order, a POST request is sent to create a new order.
     
  3. If you want to change your delivery address, a PUT request updates the address.
     
  4. If you cancel the order, a DELETE request removes it from the system.

In all these cases, the user never sees what is happening in the backend. But REST API ensures that data is fetched, updated, or deleted smoothly without interruptions.

A Simple REST API Example

Now let us walk through a basic example to see REST API in action. We will consider a simple system for managing books in an online library. The base URL for the API is:

Copy Code

arduino

CopyEdit

https://api.libraryapp.com/books

Each book is a resource and we will use HTTP methods to interact with it.

1. Get All Books

To retrieve the list of all books:

Copy Code

nginx

CopyEdit

GET https://api.libraryapp.com/books

 

Response:

Copy Code

json

CopyEdit

[

  {

    "id": 1,

    "title": "Introduction to REST",

    "author": "Priya Sharma"

  },

  {

    "id": 2,

    "title": "Mastering APIs",

    "author": "Arun Khanna"

  }

]

2. Get a Specific Book

To fetch details of a specific book with ID 1:

Copy Code

nginx

CopyEdit

GET https://api.libraryapp.com/books/1

Response:

Copy Code

json

CopyEdit

{

  "id": 1,

  "title": "Introduction to REST",

  "author": "Priya Sharma"

}

3. Add a New Book

To add a new book:

Copy Code

nginx

CopyEdit

POST https://api.libraryapp.com/books

Payload:

Copy Code

json

CopyEdit

{

  "title": "Learning Backend",

  "author": "Ravi Mehta"

}

4. Update a Book

To update the book with ID 1:

Copy Code

nginx

CopyEdit

PUT https://api.libraryapp.com/books/1

Payload:

Copy Code

json

CopyEdit

{

  "title": "Introduction to REST API",

  "author": "Priya Sharma"

}

5. Delete a Book

To remove a book with ID 1:

Copy Code

nginx

CopyEdit

DELETE https://api.libraryapp.com/books/1

These five actions represent the core operations supported by most REST APIs. Whether you are building a shopping site, an event booking system, or a blogging platform, these methods can be applied similarly.

How to Practice REST API Skills

Learning REST API is not just about reading theory. It is about building small projects, testing endpoints, and understanding how the client and server communicate.

Here are a few ways to practice:

  • Use tools like Postman or Insomnia to test API requests
     
  • Build a simple to-do list app with backend storage
     
  • Explore free public APIs like JSONPlaceholder
     
  • Try building your own REST API using NodeJS or Flask
     

If you want a structured and beginner friendly way to get started, consider enrolling in Uncodemy’s Full Stack Development with NodeJS course. It covers how REST APIs work in real world scenarios and guides you through creating your own APIs from scratch. The course is designed for learners who want practical skills along with conceptual clarity.

Final Thoughts

REST API is one of the most valuable tools in modern web development. It acts as the backbone of communication between systems and plays a major role in how data is created, accessed, and managed in applications.

Understanding REST principles and knowing how to use them will help you become a better developer. It also opens up career opportunities in backend development, full stack engineering, and software architecture.

By learning how to send a simple GET or POST request, you are stepping into the world of scalable systems, smart integrations, and real world solutions. So whether you are building a personal project or contributing to a company application, REST API is a skill that will always be in demand.

To continue your journey, do not forget to check out the Uncodemy Full Stack Development course where you can get hands-on experience with REST APIs, NodeJS, MongoDB, and more.

Start building smarter today.

Placed Students

Our Clients

Partners

...

Uncodemy Learning Platform

Uncodemy Free Premium Features

Popular Courses