List Product Attributes
Retrieves a list of all product attributes with filtering, searching, and ordering capabilities.
HTTP Request
GET/api/products/:product_id/attributes
Authorization
Authorization
- Required: Yes
- Permission: Staff or Admin
- Authentication: Token-based (Authorization: Token <your_api_key>)
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| product_id | Integer | Yes | Unique ID of the product |
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| limit | integer | 10 | Number of results to return per page |
| offset | integer | 0 | Number of results to skip before returning results |
| search | string | — | Search by `attribute__id`, `attribute__name`, `attribute__description` |
| ordering | string | — | Order by `attribute__id`, `attribute__name`, `attribute__created_at`, `attribute__updated_at`, `created_at`, `updated_at`, `product__id`, `product__name` |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2
3# List all product attributes
4response = requests.get('http://www.example.com/api/products/123/attributes',
5 headers={'Authorization': 'Token <your_api_key>'}
6)
7print(response.json())
8
9# Search and filter attributes
10response = requests.get('http://www.example.com/api/products/123/attributes', params={
11 'search': 'color',
12 'ordering': 'attribute__name',
13 'limit': 20
14}, headers={'Authorization': 'Token <your_api_key>'})
15print(response.json())1# List all product attributes
2curl -X GET "http://www.example.com/api/products/123/attributes" \
3-H "Authorization: Token <your_api_key>"
4
5# Search and filter attributes
6curl -X GET "http://www.example.com/api/products/123/attributes?search=color&ordering=attribute__name&limit=20" \
7-H "Authorization: Token <your_api_key>"Status Codes
| Code | Description |
|---|---|
| 200 | Attributes retrieved successfully |
| 401 | Unauthorized — authentication required |
| 403 | Forbidden — insufficient permissions |
| 404 | Not found — product does not exist |
| 500 | Internal server error |
Response Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the product attribute |
| attribute_data | Object | Details of the attribute (id, name, description) |
| value_data | Object | Details of the attribute value (id, value) |
| created_at | String (ISO 8601) | Timestamp when product attribute was created |
| updated_at | String (ISO 8601) | Timestamp when product attribute was last updated |
Attribute Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the attribute |
| name | String | Attribute name (max 150 characters) |
| description | String | Attribute description (max 500 characters) |
| created_at | String (ISO 8601) | Timestamp when attribute was created |
| updated_at | String (ISO 8601) | Timestamp when attribute was last updated |
Value Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the attribute value |
| value | String | The value of the attribute |
| created_at | String (ISO 8601) | Timestamp when attribute value was created |
| updated_at | String (ISO 8601) | Timestamp when attribute value was last updated |