List All Countries
Lists All counties with filtering, search and ordering capabilities
HTTP Request
GET/api/locations/countries
Authorization
Authorization
- Required: Yes
- Permission: Staff with CountryPermission or Admin
- Permission Code: 1602
- 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 lookup results by `id`, `name`, or `code` |
| ordering | string | — | 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>"Response Fields
| Field | Type | Description |
|---|---|---|
| count | Integer | Total number of categories |
| next | String | URL for the next page of results |
| previous | String | URL for the previous page of results |
| results | Array[Object] | Array of Country objects |
Country Object Structure
| 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") |
Sample Response
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": 1,
"name": "ایران",
"code": "IR"
}
]
}