Skip to main content

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

ParameterTypeDefaultDescription
limitinteger10Number of results per page
offsetinteger0Number of results to skip
activebooleanFilter by active status
order_minintegerMinimum order value filter
order_maxintegerMaximum order value filter
stock_typestringFilter by stock type
stock_minintegerMinimum stock quantity filter
stock_maxintegerMaximum stock quantity filter
brand_idintegerFilter by specific brand ID
brand_instringFilter by multiple brand IDs (comma-separated)
category_idintegerFilter by specific category ID
category_instringFilter by multiple category IDs (comma-separated)
category_tree_idintegerFilter by category and all its descendants
regular_price_mindecimalMinimum regular price filter
regular_price_maxdecimalMaximum regular price filter
sale_price_mindecimalMinimum sale price filter
sale_price_maxdecimalMaximum sale price filter
has_discountbooleanFilter products with/without discount
discount_percent_mindecimalMinimum discount percentage filter
discount_percent_maxdecimalMaximum discount percentage filter
discount_mindecimalMinimum discount amount filter
discount_maxdecimalMaximum discount amount filter
price_mindecimalMinimum final price filter
price_maxdecimalMaximum final price filter
in_stockbooleanFilter by stock availability
has_imagebooleanFilter products with/without image
has_commentsbooleanFilter products with/without comments
comments_count_minintegerMinimum comments count filter
comments_count_maxintegerMaximum comments count filter
rating_mindecimalMinimum rating filter
rating_maxdecimalMaximum rating filter
id_minintegerMinimum ID filter
id_maxintegerMaximum ID filter
created_datestringFilter by creation date (e.g., 2023-01-01)
updated_datestringFilter by last updated date (e.g., 2023-01-01)
created_fromstringFilter by creation date range start
created_tostringFilter by creation date range end
updated_fromstringFilter by last updated date range start
updated_tostringFilter by last updated date range end

Example Requests

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())

Status Codes

CodeDescription
200Products retrieved successfully
400Bad request — invalid parameters
401Unauthorized — authentication required
403Forbidden — insufficient permissions
500Internal server error

Response Fields

FieldTypeDescription
idIntegerUnique ID of the product
activeBooleanWhether the product is active
image_dataObjectImage details (read-only)
orderIntegerDisplay order priority
codeStringProduct code/SKU
nameStringProduct name
slugStringURL-friendly product identifier
stock_typeStringStock management type
stockIntegerAvailable stock quantity
in_stockBooleanWhether the product is in stock (computed)
regular_priceDecimalOriginal price of the product
sale_priceDecimalSale price (if on sale)
discountDecimalDiscount amount (computed)
discount_percentDecimalDiscount percentage (computed)
priceDecimalFinal price after discount (computed)
price_notesStringAdditional pricing notes
excerptStringShort product description
comments_countIntegerNumber of comments (computed)
ratingDecimalAverage product rating (computed)
descriptionStringFull product description
created_atString (ISO 8601)Timestamp when product was created
updated_atString (ISO 8601)Timestamp when product was last updated
brand_dataObjectBrand details (id: int, name: string)
categories_dataArray[Object]List of categories the product belongs to (id: int, name: string)

Image Data Structure

FieldTypeDescription
idIntegerUnique ID of the image
typeStringFile type (e.g., image/jpeg)
nameStringOriginal file name
sizeIntegerFile size in bytes
human_readable_sizeStringHuman readable file size (e.g., 2.5 MB)
fStringURL to access the image file
widthIntegerImage width in pixels
heightIntegerImage height in pixels
modeStringColor mode (e.g., RGB, CMYK)

Brand Data Structure

FieldTypeDescription
idIntegerUnique ID of the brand
nameStringName of the brand

Categories Data Structure

FieldTypeDescription
idIntegerUnique ID of the category
nameStringName 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").