Carts
Overview
Section titled “Overview”The Carts resource provides fake shopping cart data with user associations and cart items containing product references and quantities.
Endpoints
Section titled “Endpoints”| Method | Endpoint | Description |
|---|---|---|
| GET | /v1/carts | List all carts |
| GET | /v1/carts/:id | Get a specific cart |
| GET | /v1/carts/:id/items | Get cart's items |
Cart Object
Section titled “Cart Object”{ "id": 1, "userId": 1, "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 cart owner |
createdAt |
string |
ISO 8601 timestamp |
updatedAt |
string |
ISO 8601 timestamp |
Cart Item Object
Section titled “Cart Item Object”{ "id": 1, "cartId": 1, "productId": 1, "quantity": 2, "createdAt": "2026-01-15T10:30:00.000Z", "updatedAt": "2026-01-15T10:30:00.000Z"}| Field | Type | Description |
|---|---|---|
id |
number |
Unique identifier |
cartId |
number |
ID of the parent cart |
productId |
number |
ID of the product in cart |
quantity |
number |
Quantity of the product |
createdAt |
string |
ISO 8601 timestamp |
updatedAt |
string |
ISO 8601 timestamp |
List Carts
Section titled “List Carts”curl https://api.phantomjson.app/v1/cartsQuery 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 |
Response
Section titled “Response”{ "data": [ { "id": 1, "userId": 1, "createdAt": "2026-01-15T10:30:00.000Z", "updatedAt": "2026-01-15T10:30:00.000Z" } ], "meta": { "total": 150, "page": 1, "limit": 20, "totalPages": 8 }}Get Cart by ID
Section titled “Get Cart by ID”curl https://api.phantomjson.app/v1/carts/1Response
Section titled “Response”{ "data": { "id": 1, "userId": 1, "createdAt": "2026-01-15T10:30:00.000Z", "updatedAt": "2026-01-15T10:30:00.000Z" }}Get Cart’s Items
Section titled “Get Cart’s Items”curl https://api.phantomjson.app/v1/carts/1/itemsResponse
Section titled “Response”{ "data": [ { "id": 1, "cartId": 1, "productId": 1, "quantity": 2, "createdAt": "2026-01-15T10:30:00.000Z", "updatedAt": "2026-01-15T10:30:00.000Z" } ], "meta": { "total": 3, "page": 1, "limit": 20, "totalPages": 1 }}Examples
Section titled “Examples”Filter by User
Section titled “Filter by User”curl "https://api.phantomjson.app/v1/carts?userId=1"Sort by Date
Section titled “Sort by Date”curl "https://api.phantomjson.app/v1/carts?sort=createdAt:desc"Field Selection
Section titled “Field Selection”curl "https://api.phantomjson.app/v1/carts?fields=id,userId"Relations
Section titled “Relations”- User — Each cart belongs to a user (
userId) - Items — Each cart has many cart items (access via
/v1/carts/:id/items)
