Localities
Localities are the finest level of the geographic hierarchy. They represent villages or neighborhoods.
Geographic hierarchy
Region → Sector → Municipality → Locality
^^^^^^^^
GET /api/localites
Retrieves the list of localities.
Endpoint
GET /api/localites
Headers
| Header | Value | Required |
|---|---|---|
| Authorization | Bearer {token} | Yes |
Filter parameters
| Parameter | Type | Description |
|---|---|---|
| type | string | Filter by type (village or quartier) |
| secteur.id | UUID | Filter by sector |
| secteur.commune.id | UUID | Filter by municipality |
Success response
Code: 200 OK
{
"@context": "/api/contexts/Localite",
"@id": "/api/localites",
"@type": "hydra:Collection",
"hydra:totalItems": 2450,
"hydra:member": [
{
"@id": "/api/localites/dd0e8400-e29b-41d4-a716-446655440001",
"@type": "Localite",
"id": "dd0e8400-e29b-41d4-a716-446655440001",
"nom": "Village de Ndiaye",
"code": "VIL-001",
"type": "village",
"population": 1250,
"secteur": {
"@id": "/api/secteurs/aa0e8400-e29b-41d4-a716-446655440001",
"nom": "Secteur 1"
}
},
{
"@id": "/api/localites/dd0e8400-e29b-41d4-a716-446655440002",
"@type": "Localite",
"id": "dd0e8400-e29b-41d4-a716-446655440002",
"nom": "Quartier Médina",
"code": "QUA-001",
"type": "quartier",
"population": 8500,
"secteur": {
"@id": "/api/secteurs/aa0e8400-e29b-41d4-a716-446655440002",
"nom": "Secteur 2"
}
}
],
"hydra:view": {
"@id": "/api/localites?page=1",
"hydra:first": "/api/localites?page=1",
"hydra:last": "/api/localites?page=82"
}
}
GET /api/localites/{id}
Retrieves a locality by its identifier.
Endpoint
GET /api/localites/{id}
Success response
Code: 200 OK
{
"@context": "/api/contexts/Localite",
"@id": "/api/localites/dd0e8400-e29b-41d4-a716-446655440001",
"@type": "Localite",
"id": "dd0e8400-e29b-41d4-a716-446655440001",
"nom": "Village de Ndiaye",
"code": "VIL-001",
"type": "village",
"population": 1250,
"secteur": {
"@id": "/api/secteurs/aa0e8400-e29b-41d4-a716-446655440001",
"@type": "Secteur",
"nom": "Secteur 1",
"commune": {
"@id": "/api/communes/bb0e8400-e29b-41d4-a716-446655440001",
"nom": "Commune 1"
}
}
}
POST /api/localites
Creates a new locality (ADMIN only).
Endpoint
POST /api/localites
Request body
{
"nom": "Nouveau Village",
"code": "NV-001",
"type": "village",
"population": 500,
"secteur": "/api/secteurs/aa0e8400-e29b-41d4-a716-446655440001"
}
Fields
| Field | Type | Required | Description |
|---|---|---|---|
| nom | string | Yes | Locality name |
| code | string | No | Locality code |
| type | string | No | Type: village (default) or quartier |
| population | integer | No | Estimated population |
| secteur | IRI | Yes | Reference to the sector |
Success response
Code: 201 Created
PUT /api/localites/{id}
Updates a locality (ADMIN only).
Endpoint
PUT /api/localites/{id}
Request body
{
"nom": "Village de Ndiaye Modifié",
"population": 1500
}
DELETE /api/localites/{id}
Deletes a locality (ADMIN only).
Endpoint
DELETE /api/localites/{id}
Success response
Code: 204 No Content
Examples
cURL - Filter by type
# Villages only
curl "https://sig.ucp-pch.org/api/localites?type=village" \
-H "Authorization: Bearer TOKEN"
# Neighborhoods only
curl "https://sig.ucp-pch.org/api/localites?type=quartier" \
-H "Authorization: Bearer TOKEN"
cURL - Filter by sector
curl "https://sig.ucp-pch.org/api/localites?secteur.id=aa0e8400-e29b-41d4-a716-446655440001" \
-H "Authorization: Bearer TOKEN"
JavaScript
const getLocalites = async (filters = {}) => {
const params = new URLSearchParams();
if (filters.type) params.append('type', filters.type);
if (filters.secteurId) params.append('secteur.id', filters.secteurId);
if (filters.communeId) params.append('secteur.commune.id', filters.communeId);
const response = await fetch(
`https://sig.ucp-pch.org/api/localites?${params}`,
{
headers: {
'Authorization': `Bearer ${localStorage.getItem('token')}`
}
}
);
return response.json();
};
// Villages of a sector
const villages = await getLocalites({
type: 'village',
secteurId: 'aa0e8400-e29b-41d4-a716-446655440001'
});
villages['hydra:member'].forEach(loc => {
console.log(`${loc.nom} - Pop: ${loc.population || 'N/A'}`);
});
Python
import requests
def get_localites(token, **filters):
params = {}
if 'type' in filters:
params['type'] = filters['type']
if 'secteur_id' in filters:
params['secteur.id'] = filters['secteur_id']
if 'commune_id' in filters:
params['secteur.commune.id'] = filters['commune_id']
response = requests.get(
'https://sig.ucp-pch.org/api/localites',
headers={'Authorization': f'Bearer {token}'},
params=params
)
return response.json()
# Villages only
villages = get_localites(token, type='village')
print(f"Total villages: {villages['hydra:totalItems']}")
for v in villages['hydra:member']:
pop = v.get('population', 'N/A')
print(f"- {v['nom']} ({v['secteur']['nom']}) - Pop: {pop}")
Locality types
| Type | Description |
|---|---|
| village | Rural area |
| quartier | Urban area |
Fields
| Field | Type | Required | Description |
|---|---|---|---|
| id | UUID | - | Unique identifier |
| nom | string | Yes | Locality name |
| code | string | No | Locality code |
| type | string | No | village or quartier (default: village) |
| population | integer | No | Estimated population |
| secteur | IRI | Yes | Reference to the parent sector |
Notes
- Localities are the most precise level for geolocating households
- The type allows distinguishing rural areas (villages) from urban areas (neighborhoods)
- The population is an estimate used for statistics
- Creation/modification/deletion requires the ADMIN role