Retrieve Cart
Retrieves the current user's shopping cart with all items and calculated totals.
HTTP Request
GET/api/shop/cart/
NOTE: NOT USING THE TRAILING SLASH AT THE END OF THE URL RESULTS TO AN EXTRA REDIRECT WITH 301 STATUS
Authorization
Authorization
- Required: Yes
- Permission: Authenticated User
- Authentication: Token-based (Authorization: Token <your_api_key>)
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2
3# Retrieve cart
4response = requests.get('http://www.example.com/api/shop/cart/',
5 headers={'Authorization': 'Token <your_api_key>'}
6)
7print(response.json())1curl "http://www.example.com/api/shop/cart/" -H "Authorization: Token <your_api_key>"Status Codes
| Code | Description |
|---|---|
| 200 | Cart retrieved successfully |
| 401 | Unauthorized — authentication required |
| 500 | Internal server error |
Response Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the product |
| address | Integer | Selected delivery address ID |
| shipping_method | Integer | Selected shipping method ID |
| payment_method | Integer | Selected payment method ID |
| created_at | String (ISO 8601) | Timestamp when cart was created |
| updated_at | String (ISO 8601) | Timestamp when cart was last updated |
| count | Integer | Number of unique items in cart |
| quantity | Integer | Total quantity of all items |
| is_empty | Boolean | Whether the cart is empty |
| items_subtotal | Integer | Subtotal of all items before discounts |
| items_discount | Integer | Total discount amount on items |
| subtotal | Integer | Cart subtotal after item discounts |
| discount | Integer | Additional cart-level discount |
| shipping_cost | Integer | Shipping cost of the cart |
| total | Integer | Final cart total |
| items | Array | Array of cart items (see Cart Item fields) |
Cart Item Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the cart item |
| ref | String | Cart Item reference (read-only) |
| product | Object | Product information with `id`, `name`, `image` |
| quantity | Integer | Item quantity |
| notes | String | Customer notes for this item |
| created_at | String (ISO 8601) | Timestamp when item was added |
| updated_at | String (ISO 8601) | Timestamp when item was last updated |
| unit_price | Integer | Price per unit (read-only) |
| unit_discount | Integer | Discount per unit (read-only) |
| subtotal | Integer | Item subtotal before discount (read-only) |
| discount | Integer | Total item discount (read-only) |
| total | Integer | Final item total (read-only) |
Product Object Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique id of the product |
| title | String | Product title |
| image | Object | Product image details |
Image Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the image |
| type | String | File type (e.g., image/jpeg) |
| name | String | Original file name |
| size | Integer | File size in bytes |
| human_readable_size | String | Human readable file size (e.g., 2.5 MB) |
| f | String | URL to access the image file |
| width | Integer | Image width in pixels |
| height | Integer | Image height in pixels |
| mode | String | Color mode (e.g., RGB, CMYK) |
| thumbnails | List of thumbnail objects | Imgae thumbnails |
Thumbnail Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the thumbnail (unique) |
| f | String | URL to access the thumbnail file |
| size | Integer | File size in bytes (nullable) |
Example Response
{
"id": 1,
"address": 1,
"shipping_method": null,
"payment_method": null,
"created_at": "2025-11-22T15:26:59.108182Z",
"updated_at": "2025-11-22T15:26:59.108188Z",
"count": 2,
"quantity": 8,
"is_empty": false,
"items_subtotal": 48004000,
"items_discount": 4960400,
"subtotal": 48004000,
"discount": 4960400,
"shipping_cost": 0,
"total": 43043600,
"items": [
{
"id": 3,
"ref": "54",
"product": {
"id": 54,
"title": "درب سمت راست پراید",
"image": null
},
"quantity": 4,
"notes": "Rem itaque perferendis id ipsam accusamus tenetur est sunt. Qui est fuga iste. Eum voluptatem nam consectetur praesentium quaerat aut. Libero ut culpa laudantium eum voluptatem omnis quod. Ratione a aut consequuntur fugit ut.",
"created_at": "2025-12-30T12:33:18.957141Z",
"updated_at": "2025-12-30T12:33:18.957148Z",
"unit_price": 1000,
"unit_discount": 100,
"subtotal": 4000,
"discount": 400,
"total": 3600
},
{
"id": 2,
"ref": "36",
"product": {
"id": 36,
"title": "ماوس لاجیتک MX Vertical",
"image": {
"id": 2,
"type": "image",
"name": "logitech-mx-1",
"size": 4766,
"human_readable_size": "4.65 KB",
"f": "http://127.0.0.1:8000/media/core_media/2025/11/22/logitech-mx-1.jpg",
"width": 225,
"height": 225,
"mode": "RGB",
"thumbnails": [
{
"id": 213,
"f": "http://127.0.0.1:8000/media/core_media/2026/02/02/thumbnails/test2_ecH0zVV_thumbnail_64x64.jpg",
"size": 64
},
{
"id": 214,
"f": "http://127.0.0.1:8000/media/core_media/2026/02/02/thumbnails/test2_ecH0zVV_thumbnail_128x128.jpg",
"size": 128
},
{
"id": 215,
"f": "http://127.0.0.1:8000/media/core_media/2026/02/02/thumbnails/test2_ecH0zVV_thumbnail_512x512.jpg",
"size": 512
},
{
"id": 216,
"f": "http://127.0.0.1:8000/media/core_media/2026/02/02/thumbnails/test2_ecH0zVV_thumbnail_1080x1080.jpg",
"size": 1080
}
]
}
},
"quantity": 4,
"notes": "placeat",
"created_at": "2025-12-30T12:33:03.257543Z",
"updated_at": "2025-12-30T12:33:03.257550Z",
"unit_price": 12000000,
"unit_discount": 1240000,
"subtotal": 48000000,
"discount": 4960000,
"total": 43040000
}
]
}