Skip to main content
GET
/
api
/
v1
/
cart
Get Cart
curl --request GET \
  --url https://api.example.com/api/v1/cart/
{
  "items": {
    "[item_key]": {
      "product": "<string>",
      "variant_id": 123,
      "price": "<string>",
      "original_price": "<string>",
      "quantity": 123,
      "offer_applied": true,
      "shipping": "<string>",
      "item_type": "<string>",
      "active_offer": {
        "offer_id": 123,
        "requires_voucher": true,
        "is_valid": true
      },
      "voucher_discount": {
        "voucher_id": 123,
        "discount_type": "<string>",
        "discount_amount": 123
      }
    }
  },
  "count": 123,
  "subtotal": 123,
  "shipping": 123,
  "total": 123
}

Overview

Retrieves the current user’s shopping cart from their session. Returns all cart items with calculated totals including subtotal, shipping, and final total. Cart sessions automatically expire after 30 minutes of inactivity.

Session Management

The shopping cart uses Django session storage to maintain cart state:
  • Session Duration: 30 minutes (1800 seconds) of inactivity
  • Storage: Session-based (no authentication required)
  • Auto-refresh: Cart items are automatically refreshed every 5 minutes to validate stock levels and pricing

Request

cURL
curl -X GET https://api.example.com/api/v1/cart/ \
  -H "Cookie: sessionid=your_session_id"

Response

items
object
Dictionary of cart items keyed by item identifier
[item_key]
object
Individual cart item details
product
string
Product name
variant_id
integer
Product variant ID
price
string
Current price per unit (as decimal string)
original_price
string
Original price before any discounts (as decimal string)
quantity
integer
Quantity of this item in cart
offer_applied
boolean
Whether an automatic offer/discount is applied to this item
shipping
string
Shipping cost for this item (as decimal string)
item_type
string
Type of item: “standalone” or “variant”
active_offer
object
Present if an offer is applied to this item
offer_id
integer
ID of the applied offer
requires_voucher
boolean
Whether the offer requires a voucher code
is_valid
boolean
Whether the offer is currently active and not expired
voucher_discount
object
Present if a voucher discount is applied to this item
voucher_id
integer
ID of the applied voucher
discount_type
string
Type of discount: “percentage” or “fixed”
discount_amount
number
Calculated discount amount
count
integer
Total number of items in cart (sum of all quantities)
subtotal
number
Subtotal of all items before shipping and discounts
shipping
number
Total shipping cost
total
number
Final total including shipping and after discounts

Success Response

200 OK
{
  "items": {
    "prod123_SKU789_dflt": {
      "product": "Wireless Headphones",
      "variant_id": 456,
      "price": "89.99",
      "original_price": "99.99",
      "quantity": 2,
      "offer_applied": true,
      "shipping": "0",
      "item_type": "variant",
      "active_offer": {
        "offer_id": 12,
        "requires_voucher": false,
        "is_valid": true
      }
    },
    "prod234_SKU890_dflt": {
      "product": "USB-C Cable",
      "variant_id": 457,
      "price": "12.99",
      "original_price": "12.99",
      "quantity": 1,
      "offer_applied": false,
      "shipping": "0",
      "item_type": "standalone"
    }
  },
  "count": 3,
  "subtotal": 192.97,
  "shipping": 0,
  "total": 192.97
}

Empty Cart Response

200 OK
{
  "info": "Your cart is empty"
}

Cart Item Keys

Cart items are identified by a unique key in the format:
prod{product_id}_{variant_sku}_dflt
For example: prod123_2f23232242f2f3f_dflt This key is required when updating or removing specific items from the cart.

Automatic Cart Refresh

The cart automatically refreshes to:
  • Validate product availability and stock levels
  • Update prices based on current offers
  • Remove unavailable items
  • Adjust quantities if stock is insufficient
  • Revalidate applied vouchers
Refresh occurs:
  • Every 5 minutes automatically
  • Before adding new items
  • When updating item quantities

Build docs developers (and LLMs) love