Your First API Request
Time to send your first real API request! We'll use a free mock e-commerce API to practice.
The Test API
We'll use FakeStoreAPI - a free API that simulates an e-commerce backend:
Base URL:https://fakestoreapi.com
Available endpoints:
/products- Product catalog/carts- Shopping carts/users- User accounts
---
Sending a GET Request
Let's fetch all products:
Step 1: Create the Request
- Click + for a new request tab
- Select GET from the dropdown
- Enter URL:
https://fakestoreapi.com/products - Click Send
Step 2: Examine the Response
You should see something like:
[
{
"id": 1,
"title": "Fjallraven - Foldsack No. 1 Backpack",
"price": 109.95,
"description": "Your perfect pack for everyday use...",
"category": "men's clothing",
"image": "https://fakestoreapi.com/img/81fPKd-2AYL._AC_SL1500_.jpg",
"rating": {
"rate": 3.9,
"count": 120
}
},
{
"id": 2,
"title": "Mens Casual Premium Slim Fit T-Shirts",
"price": 22.3,
...
}
]
---
Understanding the Response
Look at the response panel:
Status Code
Status: 200 OK
Common status codes:
| Code | Meaning |
|---|---|
200 OK | Success |
201 Created | Resource created |
400 Bad Request | Invalid request |
401 Unauthorized | Authentication required |
404 Not Found | Resource doesn't exist |
500 Server Error | Server problem |
Response Time
Time: 245 ms
This tells you how long the API took to respond. For e-commerce:
- < 200ms = Excellent
- 200-500ms = Good
- 500ms-1s = Acceptable
- > 1s = Needs optimization
Response Size
Size: 5.2 KB
Larger responses take longer to download - important for mobile users.
---
Fetching a Single Product
Let's get details for product ID 1:
- New request tab
- GET
https://fakestoreapi.com/products/1 - Click Send
Response:
{
"id": 1,
"title": "Fjallraven - Foldsack No. 1 Backpack",
"price": 109.95,
"description": "Your perfect pack for everyday use and target item",
"category": "men's clothing",
"image": "https://fakestoreapi.com/img/81fPKd-2AYL._AC_SL1500_.jpg",
"rating": {
"rate": 3.9,
"count": 120
}
}
Notice: Single object {} vs array [] for multiple products.
---
Request Components
Every API request has these parts:
┌─────────────────────────────────────────────────────┐
│ METHOD │ URL │
├────────┴────────────────────────────────────────────┤
│ GET https://fakestoreapi.com/products/1 │
├─────────────────────────────────────────────────────┤
│ HEADERS │
│ Content-Type: application/json │
│ Authorization: Bearer token123 │
├─────────────────────────────────────────────────────┤
│ BODY (for POST/PUT) │
│ { "productId": 1, "quantity": 2 } │
└─────────────────────────────────────────────────────┘
| Component | Purpose | Used In |
|---|---|---|
| Method | Action to perform | All requests |
| URL | Resource location | All requests |
| Headers | Metadata (auth, content type) | Most requests |
| Body | Data to send | POST, PUT, PATCH |
---
Response Components
┌─────────────────────────────────────────────────────┐
│ STATUS CODE │
│ 200 OK │
├─────────────────────────────────────────────────────┤
│ HEADERS │
│ Content-Type: application/json │
│ X-RateLimit-Remaining: 99 │
├─────────────────────────────────────────────────────┤
│ BODY │
│ { "id": 1, "title": "Backpack", "price": 109.95 } │
└─────────────────────────────────────────────────────┘
Click the Headers tab in the response section to see response headers.
---
Saving Your Request
Don't lose your work! Save requests to your collection:
- Click Save (or
Ctrl/Cmd + S) - Name it:
Get All Products - Select folder:
Products - Click Save
Now it appears in your sidebar:
📁 Shop API
📁 Products
GET Get All Products ← Saved!
---
Practice Exercises
Exercise 1: Get Limited Products
Fetch only the first 5 products:
GET https://fakestoreapi.com/products?limit=5
Save as: Get Products (Limit 5)
Exercise 2: Get Products by Category
Fetch only electronics:
GET https://fakestoreapi.com/products/category/electronics
Save as: Get Electronics
Exercise 3: Get a Cart
Fetch cart with ID 1:
GET https://fakestoreapi.com/carts/1
Response shows cart with product IDs and quantities:
{
"id": 1,
"userId": 1,
"date": "2020-03-02T00:00:00.000Z",
"products": [
{ "productId": 1, "quantity": 4 },
{ "productId": 2, "quantity": 1 }
]
}
Save as: Get Cart by ID in the Cart folder.
---
Common Mistakes
1. Forgetting the Protocol
❌ fakestoreapi.com/products
✅ https://fakestoreapi.com/products
2. Trailing Slashes
Some APIs are sensitive:
https://api.example.com/products✅https://api.example.com/products/❌ (might fail)
3. Case Sensitivity
URLs can be case-sensitive:
/Productsmight differ from/products
---
What's in the Response Headers?
Click Headers tab in response:
| Header | Meaning |
|---|---|
Content-Type | Format of response (usually application/json) |
Content-Length | Size in bytes |
Cache-Control | Caching instructions |
X-RateLimit-* | API rate limiting info |
---
Key Takeaways
- GET requests fetch data without modifying it
- Status codes tell you if the request succeeded
- Response time indicates API performance
- Always save requests to your collection
- URL structure:
protocol://domain/path?query
Next up: HTTP Methods - learn POST, PUT, DELETE for full CRUD operations!