Get All Brands
Retrieve a list of brands with optional filtering, searching, and pagination.
HTTP Request
GET/api/shop/brands
Authorization
Authorization
- Required: No
- Permission: None (public access) or Authenticated users
- Authentication: None or Token-based authentication
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| limit | Integer | — | Number of results to return per page. Default is 10. |
| offset | Integer | — | Number of results to skip before returning results. Default is 0. |
| search | String | — | Search in `name`. |
| ordering | String | — | Field to order results by. Options are `id`, `order`, `name`, `created_at`, `updated_at`. |
| has_image | Boolean | — | Filter brands by image presence. |
| has_products | Boolean | — | Filter brands with/without products. |
| id_min | Integer | — | Minimum ID filter. |
| id_max | Integer | — | Maximum ID filter. |
| created_date | String (YYYY-MM-DD) | — | Filter by creation date (e.g., `2023-01-01`). |
| updated_date | String (YYYY-MM-DD) | — | Filter by last updated date (e.g., `2023-01-01`). |
| created_from | String (YYYY-MM-DD) | — | Filter by creation date range start. |
| created_to | String (YYYY-MM-DD) | — | Filter by creation date range end. |
| updated_from | String (YYYY-MM-DD) | — | Filter by last updated date range start. |
| updated_to | String (YYYY-MM-DD) | — | Filter by last updated date range end. |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2
3# List all brands
4response = requests.get('http://www.example.com/api/shop/brands')
5print(response.json())
6
7# List brands with filters
8response = requests.get('http://www.example.com/api/shop/brands?has_products=true&created_from=2023-01-01&created_to=2023-12-31')
9print(response.json())
10
11# Search for brands
12
13response = requests.get('http://www.example.com/api/shop/brands?search=apple')
14print(response.json())1# List all brands
2curl "http://www.example.com/api/shop/brands"
3
4# List brands with filters
5curl "http://www.example.com/api/shop/brands?has_products=true&created_from=2023-01-01&created_to=2023-12-31"
6
7# Search for brands
8curl "http://www.example.com/api/shop/brands?search=apple"Status Codes
| Code | Description |
|---|---|
| 200 | Brands retrieved successfully |
| 400 | Bad request — invalid parameters |
| 500 | Internal server error |
Response Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the brand |
| order | Integer | Display order of the brand |
| image | Object or null | Brand image data (`id`, `url`, `name`) |
| name | String | Brand name |
| slug | String | URL-friendly version of the brand name |
| description | String | Brand description |
| products_count | Integer | Number of products associated with this brand |
| created_at | String (ISO 8601) | Timestamp when brand was created |
| updated_at | String (ISO 8601) | Timestamp when brand was last updated |
Example Response
[
{
"id": 1,
"order": 0,
"image": {
"id": 10,
"url": "/media/brands/apple.jpg",
"name": "Apple"
},
"name": "Apple",
"description": "Leading technology brand known for iPhones, iPads, and Macs.",
"products_count": 200,
"created_at": "2023-01-01T12:00:00Z",
"updated_at": "2023-01-02T12:00:00Z"
},
{
"id": 2,
"order": 1,
"image": null,
"name": "Samsung",
"description": "",
"products_count": 150,
"created_at": "2023-01-05T12:00:00Z",
"updated_at": "2023-01-06T12:00:00Z"
}
]
Notes
- The
imagefield may be null if no image is associated with the brand. - The
descriptionfield may be empty if no description is available. - The
products_countfield indicates how many active products are associated with the brand.