Get All Products
Retrieve a list of products with optional filtering, searching, and pagination.
HTTP Request
GET/api/shop/products
Authorization
Authorization
- Required: No
- Permission: Public (read-only)
- Authentication: None
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| limit | integer | — | Number of results to return per page |
| offset | integer | — | Number of results to skip before returning results |
| 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`, `categories__id`, `categories__name`, `stock_type`, `stock`, `regular_price`, `sale_price`, `_price`, `_discount`, `_discount_percent`, `_in_stock`, `_rating`, `_comments_count`) |
| brand_id | integer | — | Filter by specific brand ID |
| brand_in | string | — | Filter by multiple brand IDs (comma-separated: `1,2,3`) |
| category_id | integer | — | Filter by specific category ID |
| category_in | string | — | Filter by multiple category IDs (comma-separated: `1,2,3`) |
| 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 |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2
3# Basic product listing
4response = requests.get('http://www.example.com/api/shop/products', params={
5 'limit': 20,
6 'ordering': '_price',
7 'search': 'smartphone',
8 'category_id': 1,
9 'has_discount': True,
10 'price_min': 100,
11 'price_max': 1000,
12 'in_stock': True
13})
14print(response.json())
15
16# With authentication for favorites
17response = requests.get('http://www.example.com/api/shop/products',
18 params={'limit': 10},
19 headers={'Authorization': 'Token <your_api_key>'}
20)
21print(response.json())1# Basic listing with filters
2curl "http://www.example.com/api/shop/products?limit=20&ordering=_price&search=smartphone&category_id=1&has_discount=true&price_min=100&price_max=1000&in_stock=true"
3
4# With authentication
5curl "http://www.example.com/api/shop/products?limit=10" -H "Authorization: Token <your_api_key>"Status Codes
| Code | Description |
|---|---|
| 200 | Products retrieved successfully |
| 400 | Bad request — invalid query parameters |
| 500 | Internal server error |
Response Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the product |
| image | Object | Product image data (`id`, `url`, `name`, etc.) |
| code | String | Product code/SKU |
| name | String | Product name |
| slug | String | URL-friendly product identifier |
| stock_type | String | Type of stock management |
| in_stock | Boolean | Whether product is in stock |
| stock | Integer | Current stock quantity |
| regular_price | Decimal | Regular price of the product |
| sale_price | Decimal | Sale price (if on sale) |
| discount | Decimal | Discount amount |
| discount_percent | Decimal | Discount percentage |
| price | Decimal | Final calculated price |
| rating | Decimal | Average product rating |
| comments_count | Integer | Number of product comments/reviews |
| price_notes | String | Additional price information |
| excerpt | String | Short product description |
| is_favorite | Boolean | Whether product is in user's favorites (requires auth) |
| brand_data | Object | Brand information (`id`, `name`, `slug`) |
| category_data | Array[Object] | Category information (`id`, `name`, `slug`) |
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 |