Authentication (JWT)
Obtain a JWT token with the login endpoint, then pass it in
Authorization: Bearer <token> for protected endpoints.POST
/api/v1/login
Request body (JSON)
{
"email": "user@example.com",
"password": "secret"
}
Success response (200)
{
"token": "eyJhbGciOiJI...",
"token_type": "Bearer",
"expires_in": 3600,
"user": { "id": 123, "email": "user@example.com", "name": "A. Buyer" }
}
Example curl
curl -X POST https://api.example.com/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"user@example.com","password":"secret"}'
Products
GET
/api/products
Query parameters
| parameter | type | required | notes |
|---|---|---|---|
| page | int | no | pagination (default 1) |
| limit | int | no | items per page (default 20) |
| q | string | no | search term |
| category | string | no | slug or id |
Response (200)
{
"data": [
{ "id": 12, "title": "T‑shirt", "price": 399.0, "currency":"INR", "in_stock": true }
],
"meta": { "page":1, "limit":20, "total":154 }
}
GET
/api/products/:id
Response (200)
{
"id": 12,
"title": "T‑shirt",
"description": "100% cotton...",
"price": 399.0,
"images": ["/media/p1.jpg"],
"variants": [],
"stock": 120
}
Cart
Protected endpoints — require
Authorization: Bearer <token>POST
/api/cart
Body
{
"product_id": 12,
"quantity": 2,
"variant_id": null
}
Response (201) — current cart snapshot
{
"cart_id": "abc123",
"items": [{"product_id":12,"title":"T‑shirt","quantity":2,"price":399}],
"total": 798
}
DELETE
/api/cart/{item_id}
Removes an item from the cart. Returns updated cart.
Orders
POST
/api/orders
Place an order (protected)
{
"cart_id": "abc123",
"shipping_address": {
"line1":"12 MG Road",
"city":"Kolkata",
"pincode":"700001",
"country":"IN"
},
"payment_method": "razorpay"
}
Response (201)
{
"order_id": "ORD-2025-0001",
"status": "confirmed",
"amount": 798,
"items": [ ... ]
}
Users
GET
/api/users/profile
Protected — returns current user profile
{
"id":123,
"email":"user@example.com",
"name":"A. Buyer",
"phone":"+91-98xxxx"
}
Errors
Standard error envelope
{
"error": {
"code": "INVALID_CREDENTIALS",
"message": "Email or password is incorrect",
"status": 401
}
}