Skip to main content
GET
/
api
/
cart
Get Cart
curl --request GET \
  --url https://api.example.com/api/cart \
  --header 'Authorization: <authorization>' \
  --header 'x-api-key: <x-api-key>'
{
  "success": true,
  "message": "<string>",
  "data": [
    {
      "cart_id": 123,
      "id": 123,
      "name": "<string>",
      "description": "<string>",
      "price": 123,
      "quantity": 123,
      "variant": "<string>",
      "img_urls": [
        {}
      ]
    }
  ]
}

Authentication

This endpoint requires JWT authentication.

Required Headers

x-api-key
string
required
Your API key for authentication
Authorization
string
required
Bearer token for user authentication. Format: Bearer {token}

Response

success
boolean
Indicates if the request was successful
message
string
Response message
data
array
Array of cart items with product details

Example Request

curl -X GET https://api.example.com/api/cart \
  -H "x-api-key: your_api_key" \
  -H "Authorization: Bearer your_jwt_token"

Example Response

{
  "success": true,
  "message": "Success fetching cart data",
  "data": [
    {
      "cart_id": 1,
      "id": 123,
      "name": "Wireless Headphones",
      "description": "High-quality wireless headphones with noise cancellation",
      "price": 99.99,
      "quantity": 2,
      "variant": "Black",
      "img_urls": [
        "https://example.com/images/headphones-1.jpg",
        "https://example.com/images/headphones-2.jpg"
      ]
    },
    {
      "cart_id": 2,
      "id": 456,
      "name": "USB-C Cable",
      "description": "Durable USB-C charging cable",
      "price": 15.99,
      "quantity": 1,
      "variant": null,
      "img_urls": [
        "https://example.com/images/cable-1.jpg"
      ]
    }
  ]
}

Error Codes

Status CodeDescription
200Cart data retrieved successfully
401Missing or invalid authentication credentials
500Internal server error

Build docs developers (and LLMs) love