Get All Orders
Retrieves a list of all orders with optional filtering, sorting, and pagination.
HTTP Request
GET/api/orders
Authorization
Authorization
- Required: Yes
- Permission: Staff or Admin
- Authentication: Token-based (Authorization: Token <your_api_key>)
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| limit | integer | — | Number of results to return per page |
| offset | integer | — | Number of results to skip before returning results |
| search | string | — | Search term to filter results by `id`, `key`, `customer__id`, `customer__first_name`, `customer__last_name`, `customer__email`, `customer__username`, `customer__mobile_number`, `notes`, `billing_country__name`, `billing_state__name`, `billing_city__name`, `billing_first_name`, `billing_last_name`, `billing_mobile_number` |
| ordering | string | — | Field to order results by (`id`, `status`, `customer__id`, `customer__username`, `customer__first_name`, `customer__last_name`, `shipping_cost`, `created_at`, `updated_at`) |
| status | string | — | Filter by specific order status (`new`, `hold`, `failed`, `cancelled`, `processing`, `shipped`, `completed`, `refunded`, `deleted`) |
| status_in | string | — | Filter by multiple order statuses (comma-separated) |
| customer | integer | — | Filter by specific customer ID |
| customer_in | string | — | Filter by multiple customer IDs (comma-separated) |
| payment_method | integer | — | Filter by specific payment method ID |
| payment_method_in | string | — | Filter by multiple payment method IDs (comma-separated) |
| shipping_method | integer | — | Filter by specific shipping method ID |
| shipping_method_in | string | — | Filter by multiple shipping method IDs (comma-separated) |
| billing_country | integer | — | Filter by billing country ID |
| billing_state | integer | — | Filter by billing state ID |
| billing_city | integer | — | Filter by billing city ID |
| billing_country_in | string | — | Filter by multiple billing country IDs (comma-separated) |
| billing_state_in | string | — | Filter by multiple billing state IDs (comma-separated) |
| billing_city_in | string | — | Filter by multiple billing city IDs (comma-separated) |
| shipping_cost_min | number | — | Minimum shipping cost filter |
| shipping_cost_max | number | — | Maximum shipping cost filter |
| has_customer | boolean | — | Filter orders with/without customer |
| has_payment_method | boolean | — | Filter orders with/without payment method |
| has_shipping_method | boolean | — | Filter orders with/without shipping method |
| has_billing_country | boolean | — | Filter orders with/without billing country |
| has_billing_state | boolean | — | Filter orders with/without billing state |
| has_billing_city | boolean | — | Filter orders with/without billing city |
| has_billing_address | boolean | — | Filter orders with/without billing address |
| has_billing_postal_code | boolean | — | Filter orders with/without billing postal code |
| has_billing_national_code | boolean | — | Filter orders with/without billing national code |
| has_billing_mobile_number | boolean | — | Filter orders with/without billing mobile number |
| has_billing_first_name | boolean | — | Filter orders with/without billing first name |
| has_billing_last_name | boolean | — | Filter orders with/without billing last name |
| has_notes | boolean | — | Filter orders with/without notes |
| id_min | integer | — | Minimum ID filter |
| id_max | integer | — | Maximum ID filter |
| created_date | string | — | Filter by creation date (e.g., 2023-01-01) |
| updated_date | string | — | Filter by last updated date (e.g., 2023-01-01) |
| created_from | string | — | Filter by creation date range start |
| created_to | string | — | Filter by creation date range end |
| updated_from | string | — | Filter by last updated date range start |
| updated_to | string | — | Filter by last updated date range end |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2
3# List all orders
4response = requests.get('http://www.example.com/api/orders',
5 headers={'Authorization': 'Token <your_api_key>'}
6)
7print(response.json())
8
9# Search for orders with filters
10response = requests.get('http://www.example.com/api/orders', params={
11 'search': 'john',
12 'status': 'pending',
13 'has_customer': True,
14 'ordering': '-created_at',
15 'limit': 20
16}, headers={'Authorization': 'Token <your_api_key>'})
17print(response.json())
18
19# Filter by customer and payment method
20response = requests.get('http://www.example.com/api/orders', params={
21 'customer': 123,
22 'payment_method': 1,
23 'shipping_cost_min': 10.00
24}, headers={'Authorization': 'Token <your_api_key>'})
25print(response.json())1# List all orders
2curl "http://www.example.com/api/orders" -H "Authorization: Token <your_api_key>"
3
4# Search with filters
5curl "http://www.example.com/api/orders?search=john&status=pending&has_customer=true&ordering=-created_at&limit=20" -H "Authorization: Token <your_api_key>"
6
7# Filter by customer and payment method
8curl "http://www.example.com/api/orders?customer=123&payment_method=1&shipping_cost_min=10.00" -H "Authorization: Token <your_api_key>"Status Codes
| Code | Description |
|---|---|
| 200 | Orders retrieved successfully |
| 400 | Bad request — invalid parameters |
| 401 | Unauthorized — authentication required |
| 403 | Forbidden — insufficient permissions |
| 500 | Internal server error |
Response Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the order |
| key | String | Unique key of the order (read-only) |
| status | String | Current status of the order |
| customer_data | Object | Customer information (read-only) |
| payment_method_data | Object | Payment method information (read-only) |
| shipping_method_data | Object | Shipping method information (read-only) |
| shipping_cost | Number | Cost of shipping |
| notes | String | Order notes |
| extra | Object | Additional order data |
| created_at | String (ISO 8601) | Timestamp when order was created |
| updated_at | String (ISO 8601) | Timestamp when order was last updated |
| billing_country_data | Object | Billing country information (read-only) |
| billing_state_data | Object | Billing state information (read-only) |
| billing_city_data | Object | Billing city information (read-only) |
| billing_address | String | Billing address |
| billing_postal_code | String | Billing postal code |
| billing_national_code | String | Billing national code |
| billing_mobile_number | String | Billing mobile number |
| billing_first_name | String | Billing first name |
| billing_last_name | String | Billing last name |
| count | Integer | Number of items in order (computed field) |
| quantity | Integer | Total quantity of items (computed field) |
| items_subtotal | Number | Subtotal of all items (computed field) |
| items_discount | Number | Total discount on items (computed field) |
| subtotal | Number | Order subtotal (computed field) |
| total_discount | Number | Total discount amount (computed field) |
| total | Number | Order total amount (computed field) |
| amount_paid | Number | Amount already paid (computed field) |
| amount_outstanding | Number | Outstanding amount (computed field) |
| is_paid | Boolean | Whether order is fully paid (computed field) |
| items | Array | List of order items (read-only) |
| payments | Array | List of order payments (read-only) |
Order Items Structure
Each item in the items array contains:
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the order item |
| product | Integer | Unique ID of the product |
| product_name | String | Current Product Name |
| product_data | Object | Snapshot of product data at time of order |
| unit_price | Integer | Price per unit (in smallest currency unit) |
| unit_discount | Integer | Discount per unit (in smallest currency unit) |
| quantity | Integer | Quantity ordered |
| notes | String | Item-specific notes |
| subtotal | Integer | Calculated subtotal (computed field) |
| discount | Integer | Total discount for this item (computed field) |
| total | Integer | Final total for this item (computed field) |
| created_at | String (ISO 8601) | Item creation timestamp |
| updated_at | String (ISO 8601) | Item last update timestamp |
Payment Method Structure
The payment_method object contains:
| Field | Type | Description |
|---|---|---|
| id | Integer | Payment method ID |
| name | String | Payment method name |
| image | Object | Payment method image data |
Customer Structure
The customer object contains:
| Field | Type | Description |
|---|---|---|
| id | Integer | Customer ID |
| username | String | Customer username |
| full_name | String | Customer full name (computed) |
Geographic Data Structures
Country, state, and city objects contain:
Country/State:
| Field | Type | Description |
|---|---|---|
| id | Integer | Location ID |
| active | Boolean | Whether location is active |
| name | String | Location name |
| code | String | Location code |
City:
| Field | Type | Description |
|---|---|---|
| id | Integer | City ID |
| active | Boolean | Whether city is active |
| name | String | City name |