What is an API?
GET /api/v1/lab-playground.php?resource=campaigns&id=301
Self-Paced REST API Course
Master REST APIs step-by-step at your own pace. Track your completion, test endpoints live, and build confidence from scratch.
Think of an API as a waiter in a restaurant connecting you (the customer) to the kitchen (the server):
You look at the menu (Documentation) and place your request (e.g. GET /campaigns/301).
The API safely carries your order to the backend server and ensures authentication is valid.
The server fetches data from MySQL and sends back a response in JSON format + Status Code.
When you open an app, your phone doesn't store millions of posts or ad campaigns locally. How does your phone know which ads or user posts to display? It asks the server!
That structured conversation between your app (Client) and the server happens through an API (Application Programming Interface).
HTTP & URL Anatomy
Without HTTP, REST APIs do not exist! A browser sends an HTTP Request to a server, and the server returns an HTTP Response.
https://api.adtechsanto.fun/v1/campaigns/301?status=active&limit=10
? symbol.
/campaigns/301 targets one exact entity ID, whereas /campaigns?status=active filters a list of entities.
Headers & Security
Carries API keys or JWT tokens: Bearer eyJhbGci...
Tells the server how to parse the request body: application/json
Requests JSON back from the server: application/json
POST /auth/login with email + password.localStorage or secure cookie.Authorization: Bearer <token> to every API call.Data Format
JSON is the universal language of REST APIs. Learn the data types used in request bodies and responses.
{}
Key-value pairs enclosed in curly braces.
{ "id": 301, "status": "active" }
[]
Ordered lists enclosed in square brackets.
[ "banner", "video", "native" ]
true/false), and null.
{ "cpm": 2.50, "is_active": true }
{
"campaign_id": 301,
"line_items": [
{ "id": 501, "budget": 1200 }
]
}
First Learning Roadmap
Why REST API Matters
Frontends, servers, databases, analytics tools, and ad platforms all rely on APIs to exchange data.
Login flows, profile pages, order creation, reporting, campaign updates, and dashboards all run through API calls.
Developers, TAMs, support teams, solution engineers, and AdTech teams all need to read requests and debug responses.
Understanding 401, 404, 409, CORS, bad JSON, and slow queries is part of real production support.
REST API In Baby Steps
GET /api/v1/lab-playground.php?resource=campaigns&id=301
GET /campaigns
PATCH /campaigns/301
GET /api/v1/lab-playground.php?resource=campaigns&id=301
{
"method": "POST",
"url": "/api/v1/lab-playground.php?resource=campaigns"
}
{
"status": 201,
"data": {"id": 301, "name": "Q3 Video Campaign"}
}
{
"id": 301,
"name": "Q3 Video Campaign",
"budget": 5000
}
GET /campaigns
POST /campaigns
DELETE /creatives/901
Content-Type: application/json
Authorization: Bearer token
GET /campaigns?status=active&limit=10
200 OK
404 Not Found
500 Internal Server Error
How API Works In Real Life
Think about this flow whenever you debug login, fetch profile, create order, update campaign, or delete record issues.
Browser, mobile app, Postman, or frontend code starts the call.
Method, URL, headers, and body travel to the backend.
The server routes the request to the right code.
Validation, auth, and business rules run here.
The backend reads or writes data in MySQL or another service.
The backend sends JSON and a status code back to the client.
HTTP Methods Comparator
Compare GET, POST, PUT, PATCH, and DELETE side-by-side to understand what each method does.
Endpoint: /campaigns
GET /campaigns?status=active
{
"items": [{"id":301,"name":"Q3 Video Campaign"}]
}
💡 Use: Fetch active campaigns or line items.
Endpoint: /campaigns
{
"name": "Q4 CTV Campaign",
"budget": 10000
}
{
"id": 302,
"name": "Q4 CTV Campaign"
}
💡 Use: Create a campaign, creative asset, or user account.
Endpoint: /campaigns/301
{
"name": "Q3 Video Campaign (Updated)",
"budget": 7500,
"status": "active"
}
{
"id": 301,
"name": "Q3 Video Campaign (Updated)"
}
💡 Use: Overwrite an entire campaign configuration.
Endpoint: /campaigns/301
{
"status": "paused"
}
{
"id": 301,
"status": "paused"
}
💡 Use: Change a single field like status or daily budget.
Endpoint: /creatives/901
DELETE /creatives/901
{
"deleted": true,
"id": 901
}
💡 Use: Archive or delete an unused creative asset.
Status Codes Matrix
Status codes act as instant signal lights telling you if a request succeeded, failed due to bad client input, or crashed on the server.
Architecture & Design
| Feature | REST API | GraphQL |
|---|---|---|
| Endpoints | Multiple (/campaigns, /creatives) |
Single Endpoint (/graphql) |
| Data Fetching | Fixed payload per route | Client asks for exact fields |
| Overfetching | Possible (returns extra fields) | Eliminated (exact query) |
| Caching | Built-in HTTP caching | Requires custom client caching |
An operation is idempotent if executing it 1 time produces the exact same server result as executing it 100 times.
Run 1x: Overwrites Campaign #301 ➔ Budget = $5,000
Run 2x: Overwrites Campaign #301 ➔ Budget = $5,000 (No duplicate created!)
Run 1x: Creates Campaign #301
Run 2x: Creates Campaign #302 (Duplicate row created!)
Developer Debugging
How real engineers inspect API requests in production using F12 DevTools Network Tab.
curl -X POST https://api.adtechsanto.fun/v1/campaigns \
-H "Authorization: Bearer demo-token-xyz" \
-H "Content-Type: application/json" \
-d '{"name": "Q3 Video Campaign", "budget": 5000}'
const response = await fetch('https://api.adtechsanto.fun/v1/campaigns', {
method: 'POST',
headers: {
'Authorization': 'Bearer demo-token-xyz',
'Content-Type': 'application/json'
},
body: JSON.stringify({ name: 'Q3 Video Campaign', budget: 5000 })
});
const data = await response.json();
console.log(data);
import requests
url = "https://api.adtechsanto.fun/v1/campaigns"
headers = {
"Authorization": "Bearer demo-token-xyz",
"Content-Type": "application/json"
}
payload = {"name": "Q3 Video Campaign", "budget": 5000}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
<?php
$ch = curl_init('https://api.adtechsanto.fun/v1/campaigns');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer demo-token-xyz',
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'name' => 'Q3 Video Campaign',
'budget' => 5000
]));
$response = curl_exec($ch);
curl_close($ch);
?>
AdTech Domain Focus
See how REST & JSON APIs power ad servers, Demand-Side Platforms (DSPs), Mobile Attribution (MMP), and Supply-Side Platforms (SSPs).
Publishers use GAM REST/SOAP APIs to automate line item creation and targeting rules.
POST /v202402/LineItemService
{
"name": "Q3 Video Pre-Roll 300x250",
"lineItemType": "STANDARD",
"costPerUnit": { "currencyCode": "USD", "microAmount": 2500000 },
"targeting": { "inventoryTargeting": { "targetedAdUnits": ["1234567"] } }
}
SSPs send OpenRTB JSON bid requests to DSPs within 100ms auctions.
POST /openrtb2/auction
{
"id": "auction_987654321",
"imp": [{ "id": "1", "banner": { "w": 300, "h": 250 }, "bidfloor": 1.50 }],
"site": { "domain": "adtechsanto.fun", "page": "https://adtechsanto.fun" },
"device": { "ua": "Mozilla/5.0", "ip": "172.56.21.9" }
}
Mobile Measurement Partners post install conversion data back to ad networks.
POST /v1/postback/install
{
"app_id": "com.game.app",
"advertising_id": "38400000-8cf0-11bd-b23e-10b96e40000d",
"media_source": "AdTechSanto_DSP",
"campaign": "Q3_AppInstall_US",
"event_time": "2026-07-26T17:50:00Z"
}
Request And Response Examples
/api/v1/campaigns?resource=campaigns&status=active/api/v1/lab-playground.php?resource=campaignsAccept: application/jsonNo body needed (GET requests do not send JSON bodies).{
"status": 200,
"items": [
{"id": 301, "name": "Q3 Video Campaign", "budget": 5000}
]
}/api/v1/campaigns/301?resource=campaigns&id=301/api/v1/lab-playground.php?resource=campaigns&id=301Accept: application/jsonNo body needed.{
"status": 200,
"data": {"id": 301, "name": "Q3 Video Campaign", "status": "active"}
}/api/v1/campaigns?resource=campaigns/api/v1/lab-playground.php?resource=campaignsContent-Type: application/json
Accept: application/json{
"name": "Q4 Mobile App Install",
"budget": 7500,
"status": "active"
}{
"status": 201,
"created": true,
"data": {"id": 302, "name": "Q4 Mobile App Install"}
}/api/v1/campaigns/301?resource=campaigns&id=301/api/v1/lab-playground.php?resource=campaigns&id=301Content-Type: application/json
Accept: application/json{
"status": "paused"
}{
"status": 200,
"updated": true,
"data": {"id": 301, "status": "paused"}
}/api/v1/creatives/901?resource=creatives&id=901/api/v1/lab-playground.php?resource=creatives&id=901Accept: application/jsonNo body needed.{
"status": 200,
"deleted": true,
"id": 901
}Real-World API Challenges
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.
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.
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.
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.
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.
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.
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.
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.
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
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
Use one of these presets if you want to see a working request immediately before editing the method, headers, or body yourself.
Example 1
Safe GET example returning a mock user collection.
Example 2
Fetch one simulated user record.
Example 3
Simulate a POST create request with JSON.
Example 4
Simulate patching a campaign status.
Example 5
Try a request with a bearer token header.
Example 6
Practice reading a not-found response.
Practice Tasks
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.
GET /api/v1/lab-playground.php?resource=usersGoal: 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.
GET /api/v1/lab-playground.php?resource=users&id=101Goal: 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.
POST /api/v1/lab-playground.php?resource=users
{
"name": "Practice User",
"email": "practice@example.com",
"role": "Student"
}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.
PATCH /api/v1/lab-playground.php?resource=campaigns&id=301
{
"status": "paused"
}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.
DELETE /api/v1/lab-playground.php?resource=users&id=102Goal: 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.
Authorization: Bearer demo-token
X-Debug-Mode: practiceGoal: 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.
GET /api/v1/lab-playground.php?resource=users&id=9999Goal: See validation fail.
Endpoint: /api/v1/lab-playground.php?resource=users
Expected output: 400 Bad Request.
Hint: Try POST without email.
POST /api/v1/lab-playground.php?resource=users
{
"name": "Broken Example"
}Quiz / Questions & Answers
Pick an option below, then click "Check answer" to see if you're right. Your score updates in real-time.
Authentication asks who you are. Authorization asks what you are allowed to do.
They let browsers, frontend code, and humans quickly understand whether a call succeeded, failed, or needs a retry.
It removes frontend complexity and shows the exact method, URL, headers, and body being sent.
Consistent naming, clear JSON, good examples, helpful errors, and predictable status codes.
REST API Interview Questions
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.
Simple answer: GET reads data. POST usually creates data or triggers an action.
Real-world example: Example: GET `/reports`, POST `/reports/export`.
Simple answer: PUT usually replaces a full record. PATCH updates only the fields you send.
Real-world example: PATCH may send only `{ "role": "manager" }`.
Simple answer: It means the route or resource was not found.
Real-world example: Example: requesting a user id that does not exist.
Simple answer: Authentication proves identity. Authorization checks permission.
Real-world example: A logged-in user may still not be allowed to delete.
Simple answer: A text format used to structure request and response data.
Real-world example: Example: `{ "id": 1, "name": "Riya" }`.
Simple answer: The exact API URL a client calls.
Real-world example: Example: `GET /api/v1/lab-playground.php?resource=users&id=101`.
Simple answer: Extra metadata sent with the request or response.
Real-world example: Example: `Content-Type: application/json`.
Simple answer: Backend exceptions, bad SQL, missing env vars, or dependency failures.
Real-world example: Example: database connection failure.
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
Learn API, REST, endpoint, request, response, and JSON.
Understand GET, POST, PUT, PATCH, DELETE and the common status families.
Practice headers, bodies, path params, and query params.
Learn API keys, bearer tokens, and permission checks.
Use the API Lab, curl, devtools, and Postman.
Work through 401, 404, CORS, latency, parsing, and 500 cases.
Practice explaining concepts clearly with examples.
Go Deeper
Definitions and examples for programmatic, CTV, privacy, and protocols.
Open pageGo deeper into first principles and curl examples.
Open pageStudy pagination, auth, validation, and frontend usage.
Open pageMove into idempotency, retries, tracing, and caching.
Open pageSee how PHP, MySQL, and JSON fit together in a real site.
Open pageNext Step
Start with the API Lab, move through the challenge cards, then use the deeper pages as your next hands-on exercises.
Enter any two values
to calculate the third
More tools coming soon