Sectors
Sectors are the second level of the geographic hierarchy, linked to a municipality.
Geographic hierarchy
Region → Sector → Municipality → Locality
^^^^^^
GET /api/secteurs
Retrieves the list of sectors.
Endpoint
GET /api/secteurs
Headers
| Header | Value | Required |
|---|---|---|
| Authorization | Bearer {token} | Yes |
Filter parameters
| Parameter | Type | Description |
|---|---|---|
| commune.id | UUID | Filter by municipality |
| commune.departement.id | UUID | Filter by department |
| commune.departement.region.id | UUID | Filter by region |
Success response
Code: 200 OK
{
"@context": "/api/contexts/Secteur",
"@id": "/api/secteurs",
"@type": "hydra:Collection",
"hydra:totalItems": 156,
"hydra:member": [
{
"@id": "/api/secteurs/aa0e8400-e29b-41d4-a716-446655440001",
"@type": "Secteur",
"id": "aa0e8400-e29b-41d4-a716-446655440001",
"nom": "Secteur 1",
"code": "S01",
"commune": {
"@id": "/api/communes/bb0e8400-e29b-41d4-a716-446655440001",
"nom": "Commune 1"
}
}
],
"hydra:view": {
"@id": "/api/secteurs?page=1",
"hydra:first": "/api/secteurs?page=1",
"hydra:last": "/api/secteurs?page=6"
}
}
GET /api/secteurs/{id}
Retrieves a sector by its identifier.
Endpoint
GET /api/secteurs/{id}
Success response
Code: 200 OK
{
"@context": "/api/contexts/Secteur",
"@id": "/api/secteurs/aa0e8400-e29b-41d4-a716-446655440001",
"@type": "Secteur",
"id": "aa0e8400-e29b-41d4-a716-446655440001",
"nom": "Secteur 1",
"code": "S01",
"commune": {
"@id": "/api/communes/bb0e8400-e29b-41d4-a716-446655440001",
"@type": "Commune",
"nom": "Commune 1",
"code": "COM01"
}
}
POST /api/secteurs
Creates a new sector (ADMIN only).
Endpoint
POST /api/secteurs
Request body
{
"nom": "Nouveau Secteur",
"code": "NS01",
"commune": "/api/communes/bb0e8400-e29b-41d4-a716-446655440001"
}
Success response
Code: 201 Created
PUT /api/secteurs/{id}
Updates a sector (ADMIN only).
Endpoint
PUT /api/secteurs/{id}
Request body
{
"nom": "Secteur Modifié"
}
DELETE /api/secteurs/{id}
Deletes a sector (ADMIN only).
Endpoint
DELETE /api/secteurs/{id}
Success response
Code: 204 No Content
Examples
cURL - List with filter
# Sectors of a municipality
curl "https://sig.ucp-pch.org/api/secteurs?commune.id=bb0e8400-e29b-41d4-a716-446655440001" \
-H "Authorization: Bearer TOKEN"
# Sectors of a region
curl "https://sig.ucp-pch.org/api/secteurs?commune.departement.region.id=990e8400-e29b-41d4-a716-446655440001" \
-H "Authorization: Bearer TOKEN"
JavaScript
const getSecteurs = async (filters = {}) => {
const params = new URLSearchParams();
if (filters.communeId) {
params.append('commune.id', filters.communeId);
}
if (filters.regionId) {
params.append('commune.departement.region.id', filters.regionId);
}
const response = await fetch(
`https://sig.ucp-pch.org/api/secteurs?${params}`,
{
headers: {
'Authorization': `Bearer ${localStorage.getItem('token')}`
}
}
);
return response.json();
};
// Sectors of a specific municipality
const secteurs = await getSecteurs({
communeId: 'bb0e8400-e29b-41d4-a716-446655440001'
});
secteurs['hydra:member'].forEach(secteur => {
console.log(`${secteur.nom} (${secteur.commune.nom})`);
});
Python
import requests
def get_secteurs(token, **filters):
params = {}
if 'commune_id' in filters:
params['commune.id'] = filters['commune_id']
if 'region_id' in filters:
params['commune.departement.region.id'] = filters['region_id']
response = requests.get(
'https://sig.ucp-pch.org/api/secteurs',
headers={'Authorization': f'Bearer {token}'},
params=params
)
return response.json()
# Sectors of a municipality
secteurs = get_secteurs(token, commune_id='bb0e8400-...')
for s in secteurs['hydra:member']:
print(f"- {s['nom']}")
Fields
| Field | Type | Required | Description |
|---|---|---|---|
| id | UUID | - | Unique identifier |
| nom | string | Yes | Sector name |
| code | string | No | Sector code |
| commune | IRI | Yes | Reference to the municipality |
Notes
- Sectors contain localities
- The filter by region uses the path
commune.departement.region.id - Creation/modification/deletion requires the ADMIN role