What is REST API?

1. Definition

REST API (Representational State Transfer) is a way to communicate between client and server using HTTP methods. It allows applications to send and receive data over the internet.

2. HTTP Methods

  • GET: Fetch data
  • POST: Create data
  • PUT: Update data
  • DELETE: Remove data

3. How it Works

  • Client sends HTTP request
  • Server processes request
  • Server sends response (JSON/XML)

4. Example

// GET request example
GET /users

// Response
[
  { "id": 1, "name": "John" },
  { "id": 2, "name": "Jane" }
]

5. Features

  • Stateless (no session stored)
  • Uses HTTP protocol
  • Scalable and flexible
  • Data format: JSON (most common)

6. Advantages

  • Easy to understand and use
  • Works with any frontend
  • Lightweight communication
  • Highly scalable