REST API Learning Hub

API Docs

Learn REST APIs in baby steps with real-world examples, endpoint practice, testing labs, interview questions, and challenges.

HTTP GET POST PUT DELETE JSON Status Codes Authentication

First Learning Roadmap

A simple path for your first session on this page

Use this order if you are starting from zero and want the fastest route from confusion to confident practice.

01

Learn the words first

Start with API, REST, endpoint, request, response, JSON, and status codes so the later sections feel easy instead of abstract.

02

Read real examples

Compare a GET, POST, PUT, PATCH, and DELETE side by side so you can see what changes in the URL, headers, body, and response.

03

Practice safely

Use the simulated API Lab to send your own requests without touching real production data or needing a complicated setup.

04

Explain it back clearly

Use the challenge cards, quiz, and interview questions to turn memorized ideas into confident explanations.

Why REST API Matters

Why this skill shows up in real work

REST API understanding is useful for product work, integrations, debugging, analytics, AdTech operations, and technical interviews.

APIs connect systems

Frontends, servers, databases, analytics tools, and ad platforms all rely on APIs to exchange data.

APIs power real products

Login flows, profile pages, order creation, reporting, campaign updates, and dashboards all run through API calls.

API fluency helps in many roles

Developers, TAMs, support teams, solution engineers, and AdTech teams all need to read requests and debug responses.

Debugging APIs is practical work

Understanding 401, 404, 409, CORS, bad JSON, and slow queries is part of real production support.

REST API In Baby Steps

Build the basics one concept at a time

Step 1

What is an API?

Simple meaning: A way for one system to ask another system for data or actions.

Easy analogy: A waiter between you and the kitchen.

Quick example
GET /api/v1/lab-playground.php?resource=users&id=101
Step 2

What is REST?

Simple meaning: A common way to design APIs around resources like users, orders, or campaigns.

Easy analogy: Labeled folders with clear actions.

Quick example
GET /users
PATCH /users/42
Step 3

What is an endpoint?

Simple meaning: The exact URL you call.

Easy analogy: An apartment number, not just the building.

Quick example
GET /api/v1/lab-playground.php?resource=users&id=102
Step 4

What is a request?

Simple meaning: The method, URL, headers, query params, and body sent by the client.

Easy analogy: A full order slip.

Quick example
{
  "method": "POST",
  "url": "/api/v1/lab-playground.php?resource=users"
}
Step 5

What is a response?

Simple meaning: The status code, headers, and data returned by the server.

Easy analogy: The tray coming back from the kitchen.

Quick example
{
  "status": 201,
  "data": {"id": 7}
}
Step 6

What is JSON?

Simple meaning: A simple text format for structured data.

Easy analogy: A labeled packing list.

Quick example
{
  "id": 1,
  "name": "Ava"
}
Step 7

What are methods?

Simple meaning: GET reads, POST creates, PUT replaces, PATCH updates part, DELETE removes.

Easy analogy: Different buttons for different actions.

Quick example
GET /users
POST /users
DELETE /users/9
Step 8

What are headers?

Simple meaning: Extra request instructions like auth and content type.

Easy analogy: Sticky notes on the package.

Quick example
Content-Type: application/json
Authorization: Bearer token
Step 9

What are query params?

Simple meaning: Extra filters after the URL path.

Easy analogy: Customizations after choosing the base item.

Quick example
GET /users?role=student&limit=5
Step 10

What are status codes?

Simple meaning: Quick numeric summaries of what happened.

Easy analogy: Signal lights before the full explanation.

Quick example
200 OK
404 Not Found
500 Internal Server Error

How API Works In Real Life

Client -> request -> endpoint -> server logic -> database -> response

Think about this flow whenever you debug login, fetch profile, create order, update campaign, or delete record issues.

Client / App

Browser, mobile app, Postman, or frontend code starts the call.

Request

Method, URL, headers, and body travel to the backend.

API Endpoint

The server routes the request to the right code.

Server Logic

Validation, auth, and business rules run here.

Database / Service

The backend reads or writes data in MySQL or another service.

Response

The backend sends JSON and a status code back to the client.

HTTP Methods

What each method does

GET

Read data

Example endpoint: /users

Example request
GET /users?limit=2
Example response
{
  "items": [{"id":101,"name":"Riya"}]
}

Use case: Load a report or fetch one user profile.

POST

Create data

Example endpoint: /users

Example request
{
  "name": "Ava",
  "email": "ava@example.com"
}
Example response
{
  "id": 103,
  "name": "Ava"
}

Use case: Create a user, webhook subscription, or order.

PUT

Replace a full record

Example endpoint: /users/101

Example request
{
  "name": "Riya Das",
  "email": "riya@example.com"
}
Example response
{
  "id": 101,
  "name": "Riya Das"
}

Use case: Overwrite a full config or profile.

PATCH

Update part of a record

Example endpoint: /users/101

Example request
{
  "role": "Senior Engineer"
}
Example response
{
  "id": 101,
  "role": "Senior Engineer"
}

Use case: Change one field like status or budget.

DELETE

Remove data

Example endpoint: /users/101

Example request
DELETE /users/101
Example response
{
  "deleted": true,
  "id": 101
}

Use case: Delete a record or archive a stale item.

Status Codes

Read the number before you read the message

Status Meaning When it happens Simple example
200 OK Request worked Common success for GET, PUT, PATCH, DELETE List users returns data.
201 Created New record created Common success for POST Creating a user returns the new row.
400 Bad Request Input or body is wrong Missing fields or invalid JSON POST body forgot email.
401 Unauthorized Not authenticated Missing or invalid token Protected profile call without auth.
403 Forbidden Authenticated but not allowed Role lacks permission Read-only user tries delete.
404 Not Found Route or record missing Wrong URL or ID Requesting id 9999.
409 Conflict Request conflicts with existing data Duplicate unique value Creating the same email twice.
500 Internal Server Error Backend failed Unexpected code or DB issue Query or connection crash.

Request And Response Examples

See the full shape of common calls

GET

GET /users

Endpoint: /users

Headers
Accept: application/json
Request body
No body needed
JSON response
{
  "items": [{"id":101,"name":"Riya"}]
}

Status code: 200 OK

GET

GET /users/101

Endpoint: /users/101

Headers
Accept: application/json
Request body
No body needed
JSON response
{
  "id":101,
  "name":"Riya"
}

Status code: 200 OK

POST

POST /users

Endpoint: /users

Headers
Content-Type: application/json
Request body
{
  "name": "Ava",
  "email": "ava@example.com"
}
JSON response
{
  "id":103,
  "name":"Ava"
}

Status code: 201 Created

PUT

PUT /users/101

Endpoint: /users/101

Headers
Content-Type: application/json
Request body
{
  "name": "Riya Das",
  "email": "riya@example.com"
}
JSON response
{
  "id":101,
  "name":"Riya Das"
}

Status code: 200 OK

DELETE

DELETE /users/101

Endpoint: /users/101

Headers
Accept: application/json
Request body
No body needed
JSON response
{
  "deleted": true,
  "id":101
}

Status code: 200 OK

Real-World API Challenges

Practical debugging scenarios

Why am I getting 401 Unauthorized?

Symptom: API says you are not authenticated.

Likely cause: Missing or expired token, wrong header format.

How to debug: Check Authorization header and token expiry.

Possible fix: Send a valid token or key again.

Why is my POST request failing?

Symptom: Create request returns 400 or 409.

Likely cause: Bad JSON, missing fields, duplicate unique value.

How to debug: Check Content-Type and compare body fields to the contract.

Possible fix: Send valid JSON and unique data.

Why is the response empty?

Symptom: Success response but no data.

Likely cause: Filters exclude everything or no rows exist.

How to debug: Remove filters and check the table data.

Possible fix: Seed data or fix query filters.

Why am I getting 404 Not Found?

Symptom: Route or record cannot be found.

Likely cause: Wrong URL or missing ID.

How to debug: Compare path spelling and record id.

Possible fix: Use the right endpoint or create the record first.

Why is CORS blocking my request?

Symptom: Browser fails before the API completes.

Likely cause: Server did not allow the frontend origin or header.

How to debug: Inspect browser devtools network headers.

Possible fix: Configure safe CORS rules on the backend.

Why is JSON parsing failing?

Symptom: Backend says the body is invalid.

Likely cause: Bad commas, missing quotes, or wrong content type.

How to debug: Validate the JSON body separately.

Possible fix: Send proper JSON with application/json.

Why is API latency high?

Symptom: Response works but feels slow.

Likely cause: Slow queries, big payloads, or downstream calls.

How to debug: Measure DB time, payload size, and dependencies.

Possible fix: Index queries, paginate, or cache.

Why is authentication token expired?

Symptom: Earlier calls worked, now 401.

Likely cause: Token lifetime passed.

How to debug: Check token expiry and refresh flow.

Possible fix: Refresh or re-login for a new token.

Why am I getting 500 Internal Server Error?

Symptom: Backend crashes unexpectedly.

Likely cause: Unhandled exception or DB failure.

How to debug: Read server logs and stack traces.

Possible fix: Fix backend code and add safer error handling.

Interactive API Test Lab

Try a safe simulated API playground directly on this page

This playground uses internal mock responses so beginners can safely practice methods, URLs, headers, bodies, status codes, and debugging without touching production data.

Quick Examples

Load a ready-made request into the playground

Use one of these presets if you want to see a working request immediately before editing the method, headers, or body yourself.

Example 1

List Users

Safe GET example returning a mock user collection.

Example 2

Get User 101

Fetch one simulated user record.

Example 3

Create User

Simulate a POST create request with JSON.

Example 4

Update Campaign

Simulate patching a campaign status.

Example 5

Authenticated Profile

Try a request with a bearer token header.

Example 6

Trigger 404

Practice reading a not-found response.

Equivalent cURL
curl "/api/v1/lab-playground.php"

Practice Tasks

Mini tasks that help the flow click

Fetch all users

Goal: Read the full mock user list.

Endpoint: /api/v1/lab-playground.php?resource=users

Expected output: 200 OK with an items array.

Hint: Use GET and no body.

Fetch one user

Goal: Read one mock user.

Endpoint: /api/v1/lab-playground.php?resource=users&id=101

Expected output: 200 OK with one data object.

Hint: Use the id query param.

Create a new user

Goal: Simulate creating a user safely.

Endpoint: /api/v1/lab-playground.php?resource=users

Expected output: 201 Created with a generated mock row.

Hint: Send name, email, and role.

Update a campaign status

Goal: Simulate a partial update.

Endpoint: /api/v1/lab-playground.php?resource=campaigns&id=301

Expected output: 200 OK with updated campaign data.

Hint: Use PATCH and send only the changed fields.

Delete a record

Goal: Simulate deleting one mock row.

Endpoint: /api/v1/lab-playground.php?resource=users&id=102

Expected output: 200 OK with deleted_id.

Hint: Use DELETE.

Send auth-style header

Goal: Practice using headers cleanly.

Endpoint: /api/v1/lab-playground.php?resource=profile

Expected output: 200 OK with a mock authenticated profile.

Hint: Use Authorization: Bearer demo-token.

Debug a 404

Goal: Trigger a not-found case on purpose.

Endpoint: /api/v1/lab-playground.php?resource=users&id=9999

Expected output: 404 Not Found.

Hint: Use an id that does not exist.

Identify a wrong request body

Goal: See validation fail.

Endpoint: /api/v1/lab-playground.php?resource=users

Expected output: 400 Bad Request.

Hint: Try POST without email.

Quiz / Questions & Answers

Score yourself and reveal concept answers

Score0 / 12
Answered0
StatusIn progress
Q1

What does an API do?

Q2

Which method is mainly used to read data?

Q3

True or False: JSON is common in API request and response bodies.

Q4

Which status code means a new record was created?

Q5

What is an endpoint?

Q6

True or False: Headers can carry authentication information.

Q7

What is a likely reason for 404?

Q8

Which method is best for creating a new user?

Q9

True or False: Query params are useful for filtering or pagination.

Q10

What does 401 usually mean?

Q11

Which method is often idempotent for full replacement?

Q12

True or False: A 500 response usually means a backend failure.

Authentication vs authorization?

Why do status codes matter?

Why debug with curl or an API lab?

What makes an API beginner-friendly?

REST API Interview Questions

Simple answers with real-world examples

What is a REST API?

Simple answer: A resource-oriented HTTP API style where methods like GET, POST, PUT, PATCH, and DELETE act on resources.

Real-world example: Example: `/users` for a list and `/users/101` for one user.

Difference between GET and POST?

Simple answer: GET reads data. POST usually creates data or triggers an action.

Real-world example: Example: GET `/reports`, POST `/reports/export`.

PUT vs PATCH?

Simple answer: PUT usually replaces a full record. PATCH updates only the fields you send.

Real-world example: PATCH may send only `{ "role": "manager" }`.

What is 404?

Simple answer: It means the route or resource was not found.

Real-world example: Example: requesting a user id that does not exist.

Authentication vs authorization?

Simple answer: Authentication proves identity. Authorization checks permission.

Real-world example: A logged-in user may still not be allowed to delete.

What is JSON?

Simple answer: A text format used to structure request and response data.

Real-world example: Example: `{ "id": 1, "name": "Riya" }`.

What is an endpoint?

Simple answer: The exact API URL a client calls.

Real-world example: Example: `GET /api/v1/lab-playground.php?resource=users&id=101`.

What are headers?

Simple answer: Extra metadata sent with the request or response.

Real-world example: Example: `Content-Type: application/json`.

What can cause 500?

Simple answer: Backend exceptions, bad SQL, missing env vars, or dependency failures.

Real-world example: Example: database connection failure.

What is idempotency?

Simple answer: Repeating the same request should leave the same final result.

Real-world example: PUT with the same full record twice should not create duplicates.

REST API Learning Path

A simple roadmap from zero to confidence

Stage 1

Basic API concepts

Learn API, REST, endpoint, request, response, and JSON.

Stage 2

Methods and status codes

Understand GET, POST, PUT, PATCH, DELETE and the common status families.

Stage 3

Request and response handling

Practice headers, bodies, path params, and query params.

Stage 4

Authentication basics

Learn API keys, bearer tokens, and permission checks.

Stage 5

Testing and debugging

Use the API Lab, curl, devtools, and Postman.

Stage 6

Real-world challenges

Work through 401, 404, CORS, latency, parsing, and 500 cases.

Stage 7

Interview preparation

Practice explaining concepts clearly with examples.

Go Deeper

Continue with the rest of the REST API track

AdTech glossary

Definitions and examples for programmatic, CTV, privacy, and protocols.

Open page

REST API Basics

Go deeper into first principles and curl examples.

Open page

Intermediate REST

Study pagination, auth, validation, and frontend usage.

Open page

Advanced REST

Move into idempotency, retries, tracing, and caching.

Open page

MySQL + JSON

See how PHP, MySQL, and JSON fit together in a real site.

Open page

Next Step

Keep practicing until request and response flow feels natural

Start with the API Lab, move through the challenge cards, then use the deeper pages as your next hands-on exercises.

AdTech Toolkit

Enter any two values
to calculate the third

More tools coming soon