Favorite Products
Manage customer's favorite/wishlist products.
HTTP Request
List Favorite Products
GET/api/shop/customers/me/favorites
Add Product to Favorites
POST/api/shop/customers/me/favorites
Remove Product from Favorites
DELETE/api/shop/customers/me/favorites/:product_id
Authorization
Authorization
- Required: Yes
- Permission: Authenticated Customer
- Authentication: Token-based (`Authorization: Token <your_api_key>`)
Query Parameters (GET only)
Supports all product filtering parameters including:
| Parameter | Type | Default | Description |
|---|---|---|---|
| limit | integer | — | Number of results to return per page |
| offset | integer | — | Number of results to skip |
| search | string | — | Search in product `name` |
| ordering | string | — | Field to order results by (`id`, `name`, `created_at`, `updated_at`, `order`, `active`, `brand__id`, `brand__name`, `category__id`, `category__name`, `stock_type`, `stock`, `regular_price`, `sale_price`, `_price`, `_discount`, `_dicsount_percent`, `_in_stock`, `_rating`, `_comment_count`) |
| brand_id | integer | — | Filter by brand ID |
| category_id | integer | — | Filter by category ID |
| category_tree_id | integer | — | Filter by category tree ID (returns all products in the category and subcategories) |
| regular_price_min | number | — | Minimum regular price filter |
| regular_price_max | number | — | Maximum regular price filter |
| sale_price_min | number | — | Minimum sale price filter |
| sale_price_max | number | — | Maximum sale price filter |
| price_min | number | — | Minimum final price filter |
| price_max | number | — | Maximum final price filter |
| has_discount | boolean | — | Filter products with/without discount |
| discount_min | number | — | Minimum discount amount filter |
| discount_max | number | — | Maximum discount amount filter |
| discount_percent_min | number | — | Minimum discount percentage filter |
| discount_percent_max | number | — | Maximum discount percentage filter |
| in_stock | boolean | — | Filter by stock availability |
| has_image | boolean | — | Filter products with/without image |
| has_comments | boolean | — | Filter products with/without comments |
| comments_count_min | integer | — | Minimum comments count filter |
| comments_count_max | integer | — | Maximum comments count filter |
| rating_min | number | — | Minimum rating filter |
| rating_max | number | — | Maximum rating filter |
| id_min | integer | — | Minimum ID filter |
| id_max | integer | — | Maximum ID filter |
| created_date | string | — | Filter by creation date (e.g., `2023-01-01`) |
| updated_date | string | — | Filter by last updated date (e.g., `2023-01-01`) |
| created_from | string | — | Filter by creation date range start |
| created_to | string | — | Filter by creation date range end |
| updated_from | string | — | Filter by last updated date range start |
| updated_to | string | — | Filter by last updated date range end |
Request Body (POST only)
| Field | Type | Required | Description |
|---|---|---|---|
| product | integer | No | ID of the product to add to favorites |
Query Parameters (DELETE only)
| Field | Type | Required | Description |
|---|---|---|---|
| product_id | integer | No | ID of the product to remove from favorites (passed as a URL parameter) |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2
3# List favorite products
4response = requests.get('http://www.example.com/api/shop/customers/me/favorites',
5 params={
6 'ordering': '-created_at',
7 'has_discount': True
8 },
9 headers={'Authorization': 'Token <your_api_key>'}
10)
11print(response.json())
12
13# Add product to favorites
14response = requests.post('http://www.example.com/api/shop/customers/me/favorites',
15 json={
16 'product': 456
17 },
18 headers={'Authorization': 'Token <your_api_key>'}
19)
20print(response.status_code) # Should be 200
21
22# Remove product from favorites
23response = requests.delete('http://www.example.com/api/shop/customers/me/favorites/456',
24 headers={'Authorization': 'Token <your_api_key>'}
25)
26print(response.status_code) # Should be 2041# List favorite products with filters
2curl "http://www.example.com/api/shop/customers/me/favorites?ordering=-created_at&has_discount=true" -H "Authorization: Token <your_api_key>"
3
4# Add product to favorites
5curl -X POST "http://www.example.com/api/shop/customers/me/favorites" -H "Authorization: Token <your_api_key>" -H "Content-Type: application/json" -d '{
6 "product": 456
7}'
8
9# Remove product from favorites
10curl -X DELETE "http://www.example.com/api/shop/customers/me/favorites/456" -H "Authorization: Token <your_api_key>"Status Codes
| Code | Description |
|---|---|
| 200 | Favorites retrieved/product added successfully |
| 204 | Product removed from favorites successfully |
| 400 | Bad request — invalid product ID |
| 401 | Unauthorized — authentication required |
| 404 | Product not found in favorites |
| 500 | Internal server error |