List Customer Addresses
Retrieves a list of all addresses for a specific customer with filtering, searching, and ordering capabilities.
HTTP Request
GET/api/customers/:id/addresses
Authorization
Authorization
- Required: Yes
- Permission: Staff or Admin
- Authentication: Token-based (Authorization: Token <your_api_key>)
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | Integer | Yes | Unique ID of the customer |
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 term to filter results by first_name, last_name, postal_code, address |
| ordering | string | — | Field to order results by (id, country, state, city, created_at, updated_at, default) |
| country_in | string | — | Filter by multiple country IDs (comma-separated: 1,2,3) |
| state_in | string | — | Filter by multiple state IDs (comma-separated: 1,2,3) |
| city_in | string | — | Filter by multiple city IDs (comma-separated: 1,2,3) |
| country_id | integer | — | Filter by specific country ID |
| state_id | integer | — | Filter by specific state ID |
| city_id | integer | — | Filter by specific city ID |
| has_national_code | boolean | — | Filter addresses with/without national code |
| 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 addresses for customer
4response = requests.get('http://www.example.com/api/customers/123/addresses',
5 headers={'Authorization': 'Token <your_api_key>'}
6)
7print(response.json())
8
9# Search for addresses with filters
10response = requests.get('http://www.example.com/api/customers/123/addresses', params={
11 'search': 'john',
12 'country_id': 1,
13 'has_national_code': True,
14 'ordering': '-created_at',
15 'limit': 20
16}, headers={'Authorization': 'Token <your_api_key>'})
17print(response.json())
18
19# Filter by location
20response = requests.get('http://www.example.com/api/customers/123/addresses', params={
21 'country_in': '1,2,3',
22 'state_id': 5,
23 'created_from': '2023-01-01'
24}, headers={'Authorization': 'Token <your_api_key>'})
25print(response.json())1# List all addresses for customer
2curl "http://www.example.com/api/customers/123/addresses" -H "Authorization: Token <your_api_key>"
3
4# Search with filters
5curl "http://www.example.com/api/customers/123/addresses?search=john&country_id=1&has_national_code=true&ordering=-created_at&limit=20" \
6-H "Authorization: Token <your_api_key>"
7
8# Filter by location
9curl "http://www.example.com/api/customers/123/addresses?country_in=1,2,3&state_id=5&created_from=2023-01-01" \
10-H "Authorization: Token <your_api_key>"Status Codes
| Code | Description |
|---|---|
| 200 | Customer addresses retrieved successfully |
| 401 | Unauthorized — authentication required |
| 403 | Forbidden — insufficient permissions |
| 404 | Customer not found |
| 500 | Internal server error |
Response Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the address |
| default | Boolean | Whether this is the customer's default address |
| country_data | Object | Country information with id, name, etc. |
| state_data | Object | State information with id, name, etc. |
| city_data | Object | City information with id, name, etc. |
| address | String | Street address |
| postal_code | String | Postal/ZIP code |
| first_name | String | First name on the address |
| last_name | String | Last name on the address |
| national_code | String | National identification code |
| mobile_number | String | Mobile phone number for this address |
| text | String | Additional text/notes for the address |
| created_at | String (ISO 8601) | Timestamp when address was created |
| updated_at | String (ISO 8601) | Timestamp when address was last updated |
Country Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the country |
| name | String | Name of the country |
| code | String | ISO country code (e.g., US, CA) |
State Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the state |
| name | String | Name of the state |
| code | String | State code (if applicable) |
City Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the city |
| name | String | Name of the city |