Skip to main content

Get All Related Products

Retrieve a list of products with optional filtering, searching, and pagination.

HTTP Request

GET/api/shop/products/:product_id/related

Authorization

Authorization

  • Required: No
  • Permission: Public (read-only)
  • Authentication: Optional (affects `is_favorite` field)

Path Parameters

ParameterTypeRequiredDescription
product_idIntegerYesUnique ID of the main product

Example Requests

1import requests
2
3# Get related products
4response = requests.get('http://www.example.com/api/shop/products/123/related')
5print(response.json())
6
7# With authentication for favorites
8response = requests.get('http://www.example.com/api/shop/products/123/related', headers={
9  'Authorization': 'Token <your_api_key>'
10})
11print(response.json())

Status Codes

CodeDescription
200Related products retrieved successfully
404Main product not found
500Internal server error

Response Fields

FieldTypeDescription
idIntegerUnique ID of the product
imageObjectProduct image data (`id`, `url`, `name`, etc.)
codeStringProduct code/SKU
nameStringProduct name
slugStringURL-friendly product identifier
stock_typeStringType of stock management
in_stockBooleanWhether product is in stock
stockIntegerCurrent stock quantity
regular_priceDecimalRegular price of the product
sale_priceDecimalSale price (if on sale)
discountDecimalDiscount amount
discount_percentDecimalDiscount percentage
priceDecimalFinal calculated price
ratingDecimalAverage product rating
comments_countIntegerNumber of product comments/reviews
price_notesStringAdditional price information
excerptStringShort product description
is_favoriteBooleanWhether product is in user's favorites (requires auth)
brand_dataObjectBrand information (`id`, `name`, `slug`)
category_dataArray[Object]Category information (`id`, `name`, `slug`)

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

    • Related products are returned using the same serializer as the product listing
    • The endpoint combines manually set related products with category-based recommendations
    • Products are automatically excluded from their own related products list
    • All related products inherit the same filtering and computed field logic as the main product listing