Retrieve City
Retrieve a specific city by its unique identifier.
HTTP Request
GET/api/locations/cities/:id
Authorization
Authorization
- Required: Yes
- Permission: Admin or Staff
- Authentication: Token-based (Authorization: Token <your_api_key>)
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | integer | Yes | Unique identifier of the city |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2
3url = "https://api.example.com/api/locations/cities/42"
4headers = {
5 "Authorization": "Token <your_api_key>"
6}
7response = requests.get(url, headers=headers)
8print(response.json())1curl -X GET "https://api.example.com/api/locations/cities/42" \
2-H "Authorization: Token <your_api_key>"Status Codes
| Code | Description |
|---|---|
| 200 | Successfully retrieved city details |
| 400 | Invalid city ID |
| 401 | Authentication required |
| 403 | Insufficient permissions |
| 500 | Server error occurred |
Response Fields
| Field | Type | Description |
|---|---|---|
| id | integer | Unique city identifier |
| name | string | City name |
| code | string | City code (e.g., 'LA') |
| state | object | State information |
State Object Fields:
| Field | Type | Description |
|---|---|---|
| id | integer | Unique state identifier |
| name | string | State name |
| code | string | State code |