Skip to content

Carts

The Carts resource provides fake shopping cart data with user associations and cart items containing product references and quantities.

MethodEndpointDescription
GET/v1/cartsList all carts
GET/v1/carts/:idGet a specific cart
GET/v1/carts/:id/itemsGet cart's items
{
"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
{
"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
Terminal window
curl https://api.phantomjson.app/v1/carts
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
{
"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
}
}
Terminal window
curl https://api.phantomjson.app/v1/carts/1
{
"data": {
"id": 1,
"userId": 1,
"createdAt": "2026-01-15T10:30:00.000Z",
"updatedAt": "2026-01-15T10:30:00.000Z"
}
}
Terminal window
curl https://api.phantomjson.app/v1/carts/1/items
{
"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
}
}
Terminal window
curl "https://api.phantomjson.app/v1/carts?userId=1"
Terminal window
curl "https://api.phantomjson.app/v1/carts?sort=createdAt:desc"
Terminal window
curl "https://api.phantomjson.app/v1/carts?fields=id,userId"
  • User — Each cart belongs to a user (userId)
  • Items — Each cart has many cart items (access via /v1/carts/:id/items)