Orders
Ce contenu n’est pas encore disponible dans votre langue.
Overview
Section titled “Overview”The Orders resource provides fake order data with status tracking, pricing breakdowns, coupon support, and order items containing product references and quantities.
Endpoints
Section titled “Endpoints”| Method | Endpoint | Description |
|---|---|---|
| GET | /v1/orders | List all orders |
| GET | /v1/orders/:id | Get a specific order |
| GET | /v1/orders/:id/items | Get order's items |
Order Object
Section titled “Order Object”{ "id": 1, "userId": 1, "status": "pending", "subtotal": 599.98, "discount": 50.0, "shipping": 9.99, "total": 559.97, "currency": "USD", "couponCode": "SAVE50", "createdAt": "2026-01-15T10:30:00.000Z", "updatedAt": "2026-01-15T10:30:00.000Z"}| Field | Type | Description |
|---|---|---|
id |
number |
Unique identifier |
userId |
number |
ID of the order owner |
status |
string |
Order status (pending, processing, shipped, delivered, cancelled) |
subtotal |
number |
Sum of item prices before discounts |
discount |
number |
Total discount applied |
shipping |
number |
Shipping cost |
total |
number |
Final order total |
currency |
string |
Currency code (e.g. USD) |
couponCode |
string |
Applied coupon code (if any) |
createdAt |
string |
ISO 8601 timestamp |
updatedAt |
string |
ISO 8601 timestamp |
Order Item Object
Section titled “Order Item Object”{ "id": 1, "orderId": 1, "productId": 1, "quantity": 2, "unitPrice": 299.99, "total": 599.98, "createdAt": "2026-01-15T10:30:00.000Z", "updatedAt": "2026-01-15T10:30:00.000Z"}| Field | Type | Description |
|---|---|---|
id |
number |
Unique identifier |
orderId |
number |
ID of the parent order |
productId |
number |
ID of the ordered product |
quantity |
number |
Quantity ordered |
unitPrice |
number |
Price per unit at order time |
total |
number |
Line item total |
createdAt |
string |
ISO 8601 timestamp |
updatedAt |
string |
ISO 8601 timestamp |
List Orders
Section titled “List Orders”curl https://api.phantomjson.app/v1/ordersQuery Parameters
Section titled “Query Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
page |
number |
1 |
Page number |
limit |
number |
20 |
Items per page (max: 100) |
sort |
string |
— | Sort field and direction |
q |
string |
— | Search query |
fields |
string |
— | Fields to return |
userId |
number |
— | Filter by user ID |
status |
string |
— | Filter by order status |
Response
Section titled “Response”{ "data": [ { "id": 1, "userId": 1, "status": "pending", "subtotal": 599.98, "total": 559.97, "currency": "USD" } ], "meta": { "total": 300, "page": 1, "limit": 20, "totalPages": 15 }}Get Order by ID
Section titled “Get Order by ID”curl https://api.phantomjson.app/v1/orders/1Response
Section titled “Response”{ "data": { "id": 1, "userId": 1, "status": "pending", "subtotal": 599.98, "discount": 50.0, "shipping": 9.99, "total": 559.97, "currency": "USD", "couponCode": "SAVE50", "createdAt": "2026-01-15T10:30:00.000Z", "updatedAt": "2026-01-15T10:30:00.000Z" }}Get Order’s Items
Section titled “Get Order’s Items”curl https://api.phantomjson.app/v1/orders/1/itemsResponse
Section titled “Response”{ "data": [ { "id": 1, "orderId": 1, "productId": 1, "quantity": 2, "unitPrice": 299.99, "total": 599.98 } ], "meta": { "total": 2, "page": 1, "limit": 20, "totalPages": 1 }}Examples
Section titled “Examples”Filter by User
Section titled “Filter by User”curl "https://api.phantomjson.app/v1/orders?userId=1"Filter by Status
Section titled “Filter by Status”curl "https://api.phantomjson.app/v1/orders?status=delivered"Sort by Date
Section titled “Sort by Date”curl "https://api.phantomjson.app/v1/orders?sort=createdAt:desc"Field Selection
Section titled “Field Selection”curl "https://api.phantomjson.app/v1/orders?fields=id,status,total,currency"Relations
Section titled “Relations”- User — Each order belongs to a user (
userId) - Items — Each order has many order items (access via
/v1/orders/:id/items) - Coupon — Each order may reference a coupon (
couponCode)
