Get All Products
Retrieve a list of products with optional filtering, searching, and pagination.
HTTP Request
GET/api/products
Authorization
Authorization
- Required: Yes
- Permission: Staff or Admin
- Authentication: Token-based (Authorization: Token <your_api_key>)
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| limit | integer | 10 | Number of results per page |
| offset | integer | 0 | Number of results to skip |
| active | boolean | — | Filter by active status |
| order_min | integer | — | Minimum order value filter |
| order_max | integer | — | Maximum order value filter |
| stock_type | string | — | Filter by stock type |
| stock_min | integer | — | Minimum stock quantity filter |
| stock_max | integer | — | Maximum stock quantity filter |
| brand_id | integer | — | Filter by specific brand ID |
| brand_in | string | — | Filter by multiple brand IDs (comma-separated) |
| category_id | integer | — | Filter by specific category ID |
| category_in | string | — | Filter by multiple category IDs (comma-separated) |
| category_tree_id | integer | — | Filter by category and all its descendants |
| regular_price_min | decimal | — | Minimum regular price filter |
| regular_price_max | decimal | — | Maximum regular price filter |
| sale_price_min | decimal | — | Minimum sale price filter |
| sale_price_max | decimal | — | Maximum sale price filter |
| has_discount | boolean | — | Filter products with/without discount |
| discount_percent_min | decimal | — | Minimum discount percentage filter |
| discount_percent_max | decimal | — | Maximum discount percentage filter |
| discount_min | decimal | — | Minimum discount amount filter |
| discount_max | decimal | — | Maximum discount amount filter |
| price_min | decimal | — | Minimum final price filter |
| price_max | decimal | — | Maximum final price 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 | decimal | — | Minimum rating filter |
| rating_max | decimal | — | 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 |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2
3# List all products
4response = requests.get('http://www.example.com/api/products',
5 headers={'Authorization': 'Token <your_api_key>'}
6)
7print(response.json())
8
9# Search for products with filters
10response = requests.get('http://www.example.com/api/products', params={
11 'search': 'laptop',
12 'active': True,
13 'has_discount': True,
14 'ordering': '-created_at',
15 'limit': 20
16}, headers={'Authorization': 'Token <your_api_key>'})
17print(response.json())
18
19# Filter by category tree and price range
20response = requests.get('http://www.example.com/api/products', params={
21 'category_tree_id': 5,
22 'price_min': 100,
23 'price_max': 500,
24 'in_stock': True
25}, headers={'Authorization': 'Token <your_api_key>'})
26print(response.json())1# List all products
2curl "http://www.example.com/api/products" -H "Authorization: Token <your_api_key>"
3
4# Search with filters
5curl "http://www.example.com/api/products?search=laptop&active=true&has_discount=true&ordering=-created_at&limit=20" -H "Authorization: Token <your_api_key>"
6
7# Filter by category tree and price range
8curl "http://www.example.com/api/products?category_tree_id=5&price_min=100&price_max=500&in_stock=true" -H "Authorization: Token <your_api_key>"Status Codes
| Code | Description |
|---|---|
| 200 | Products retrieved successfully |
| 400 | Bad request — invalid parameters |
| 401 | Unauthorized — authentication required |
| 403 | Forbidden — insufficient permissions |
| 500 | Internal server error |
Response Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the product |
| active | Boolean | Whether the product is active |
| image_data | Object | Image details (read-only) |
| order | Integer | Display order priority |
| code | String | Product code/SKU |
| name | String | Product name |
| slug | String | URL-friendly product identifier |
| stock_type | String | Stock management type |
| stock | Integer | Available stock quantity |
| in_stock | Boolean | Whether the product is in stock (computed) |
| regular_price | Decimal | Original price of the product |
| sale_price | Decimal | Sale price (if on sale) |
| discount | Decimal | Discount amount (computed) |
| discount_percent | Decimal | Discount percentage (computed) |
| price | Decimal | Final price after discount (computed) |
| price_notes | String | Additional pricing notes |
| excerpt | String | Short product description |
| comments_count | Integer | Number of comments (computed) |
| rating | Decimal | Average product rating (computed) |
| description | String | Full product description |
| created_at | String (ISO 8601) | Timestamp when product was created |
| updated_at | String (ISO 8601) | Timestamp when product was last updated |
| brand_data | Object | Brand details (id: int, name: string) |
| categories_data | Array[Object] | List of categories the product belongs to (id: int, name: string) |
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) |
Brand Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the brand |
| name | String | Name of the brand |
Categories Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the category |
| name | String | Name of the category |
Notes
- Fields marked as "computed" are generated by the system and cannot be set directly.
- Date fields are in ISO 8601 format (e.g., "2023-01-01T12:00:00Z").