Skip to main content

List All Categories

GET /api/v1/categories/

Authentication

This endpoint does not require authentication. It is publicly accessible.

Query Parameters

Search categories by name

Response

id
integer
Unique category identifier
name
string
Category name
slug
string
URL-friendly category identifier (auto-generated from name)

Request Example

curl -X GET "https://api.example.com/api/v1/categories/" \
  -H "Accept: application/json"

Response Example

200 OK
[
  {
    "id": 1,
    "name": "Electronics",
    "slug": "electronics"
  },
  {
    "id": 2,
    "name": "Clothing",
    "slug": "clothing"
  },
  {
    "id": 3,
    "name": "Home & Garden",
    "slug": "home-garden"
  }
]

Get Category Details

Retrieve a specific category along with all its associated products.
GET /api/v1/categories/{slug}/

Authentication

This endpoint does not require authentication. It is publicly accessible.

Path Parameters

slug
string
required
The URL-friendly slug identifier of the category

Response

id
integer
Unique category identifier
name
string
Category name
slug
string
URL-friendly category identifier
product_set
array
Array of all products in this category

Request Example

curl -X GET "https://api.example.com/api/v1/categories/electronics/" \
  -H "Accept: application/json"

Response Example

200 OK
{
  "id": 1,
  "name": "Electronics",
  "slug": "electronics",
  "product_set": [
    {
      "id": 1,
      "name": "Premium Wireless Headphones",
      "category": "Electronics",
      "description": "High-quality wireless headphones with noise cancellation",
      "store": "https://api.example.com/api/v1/stores/tech-store/",
      "base_price": "149.99",
      "shipping_fee": "5.99",
      "rating": 4.5,
      "is_standalone": false,
      "total_stock_level": 250,
      "total_sold": 1050,
      "is_available": true,
      "is_active": true,
      "created": "2024-01-15T10:30:00Z",
      "updated": "2024-03-01T14:22:00Z",
      "media": [
        {
          "id": 1,
          "file": "https://cdn.example.com/products/2024/01/headphones.jpg",
          "is_primary": true,
          "file_size": 2.45,
          "file_type": "image"
        }
      ],
      "product_offers": []
    },
    {
      "id": 2,
      "name": "4K Smart TV",
      "category": "Electronics",
      "description": "55-inch 4K Ultra HD Smart LED TV",
      "store": "https://api.example.com/api/v1/stores/tech-store/",
      "base_price": "599.99",
      "shipping_fee": "29.99",
      "rating": 4.7,
      "is_standalone": true,
      "total_stock_level": 45,
      "total_sold": 230,
      "is_available": true,
      "is_active": true,
      "created": "2024-01-20T09:15:00Z",
      "updated": "2024-02-28T11:30:00Z",
      "media": [
        {
          "id": 5,
          "file": "https://cdn.example.com/products/2024/01/tv-main.jpg",
          "is_primary": true,
          "file_size": 3.12,
          "file_type": "image"
        }
      ],
      "product_offers": [
        {
          "id": 15,
          "name": "Electronics Clearance - 20% Off",
          "discount_type": "percentage",
          "discount_value": "20.00"
        }
      ]
    }
  ]
}

Error Responses

404
Not Found
Category with the specified slug does not exist
{
  "detail": "Not found."
}

List Products by Category

Get a paginated list of products filtered by category slug.
GET /api/v1/products/categories/{slug}/

Authentication

This endpoint does not require authentication. It is publicly accessible.

Path Parameters

slug
string
required
The URL-friendly slug identifier of the category

Query Parameters

search
string
Search products within this category
is_available
boolean
Filter by availability status
store
integer
Filter by store ID
limit
integer
default:"10"
Number of products per page
offset
integer
default:"0"
Pagination offset

Request Example

curl -X GET "https://api.example.com/api/v1/products/categories/electronics/" \
  -H "Accept: application/json"

Response Example

200 OK
{
  "count": 45,
  "next": "https://api.example.com/api/v1/products/categories/electronics/?limit=10&offset=10",
  "previous": null,
  "results": [
    {
      "id": 1,
      "name": "Premium Wireless Headphones",
      "category": "Electronics",
      "base_price": "149.99",
      "rating": 4.5,
      "is_available": true,
      "media": [...],
      "product_offers": [...]
    }
  ]
}

Notes

  • Categories are ordered alphabetically by name
  • Category slugs are automatically generated from the category name when created
  • Slugs are URL-safe and lowercase (e.g., “Home & Garden” becomes “home-garden”)
  • Products within categories are ordered by total_sold (descending) and then by rating (descending)
  • The category lookup by slug is case-sensitive

Build docs developers (and LLMs) love