Serksa
All Concepts
API & Backend

REST APIs Explained

1

What is it?

<strong>REST (Representational State Transfer)</strong> is an architectural style for building APIs. It uses standard HTTP methods (GET, POST, PUT, DELETE) to perform operations on resources, making APIs predictable and easy to use.

2

Think of it like...

The Library Analogy

REST is like a library's catalog system. You use standard methods (search, borrow, return) to interact with books. You don't need to know where books are storedβ€”you just follow the system.

πŸ“š

Books (Resources)

Data you want to access

πŸ“‹

Catalog System (REST)

Organized way to find books

πŸ‘¨β€πŸ’Ό

Librarian (Server)

Manages the books

3

Visual Flow

🌐Client

HTTP Request

β†’
πŸ”„REST API

Routes to Resource

β†’
πŸ’ΎResource

Returns Data

4

Where you see it

1

Client sends HTTP request

GET /users/123 - Request user data

2

API routes to resource

Maps URL to the users resource

3

Server processes request

Fetches user 123 from database

4

Returns JSON response

Sends back user data in JSON format

5

Common Mistake

❌

Wrong

"REST means using JSON" or "Any HTTP API is REST"

βœ…

Correct

REST is an <strong>architectural style</strong> with specific constraints: stateless communication, resource-based URLs, standard HTTP methods, and uniform interfaces.

πŸ’‘ Real-World Example

A social media app using REST API:

1

GET /posts - Fetch all posts

2

POST /posts - Create a new post

3

PUT /posts/123 - Update post 123

4

DELETE /posts/123 - Delete post 123