List Countries
Retrieves a list of all countries.
HTTP Request
GET/api/locations/countries
Authorization
Authorization
- Required: Yes
- Permission: Admin or Staff
- Authentication: Token-based (Authorization: Token <your_api_key>)
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 `id`, `name`, or `code` |
| ordering | string | — | Field to order results by (`id`, `active`, `name`, `code`) |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2
3response = requests.get('http://www.example.com/api/locations/countries',
4 params={
5 'limit': 5,
6 'ordering': 'name',
7 'search': 'Iran'
8 },
9 headers={'Authorization': 'Token <your_api_key>'}
10)
11print(response.json())1curl "http://www.example.com/api/locations/countries?limit=5&ordering=name&search=Iran" \
2-H "Authorization: Token <your_api_key>"Status Codes
| Code | Description |
|---|---|
| 200 | List retrieved successfully |
| 400 | Bad request — invalid input |
| 500 | Internal server error |
Response Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the country |
| name | String | Name of the country |
| code | String | ISO code of the country (e.g., "IR") |