Get All Attributes
List all attributes with optional filtering, sorting, and pagination.
HTTP Request
GET/api/products/attributes
Authorization
Authorization
- Required: Yes
- Permission: Staff or Admin
- Authentication: Token-based (Authorization: Token <your_api_key>)
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| limit | integer | 10 | Number of results per page |
| offset | integer | 0 | Number of results to skip |
| search | string | — | Search term to filter results by "id" and "name" |
| ordering | string | — | Field to sort results by. Prefix with "-" for descending order. Supported fields: "id", "name", "created_at" and "updated_at" |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2
3# List all attributes
4response = requests.get('http://www.example.com/api/products/attributes',
5 headers={'Authorization': 'Token <your_api_key>'}
6)
7print(response.json())
8
9# Search for attributes with filters
10response = requests.get('http://www.example.com/api/products/attributes', params={
11 'search': 'color',
12 'ordering': 'name',
13 'limit': 20
14}, headers={'Authorization': 'Token <your_api_key>'}
15)
16print(response.json())1# List all attributes
2
3curl "http://www.example.com/api/products/attributes" -H "Authorization: Token <your_api_key>"
4
5# Search for attributes with filters
6curl "http://www.example.com/api/products/attributes?search=color&ordering=name&limit=20" -H "Authorization: Token <your_api_key>"Status Codes
| Code | Description |
|---|---|
| 200 | Attributes retrieved successfully |
| 401 | Unauthorized — authentication required |
| 403 | Forbidden — insufficient permissions |
| 500 | Internal server error |
Response Fields
| 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 |