GET /api/menages/{id}
Retrieves detailed information about a household.
Endpoint
GET /api/menages/{id}
URL Parameters
| Parameter | Type | Description |
|---|---|---|
| id | integer | Household identifier |
Headers
| Header | Value | Required |
|---|---|---|
| Authorization | Bearer {token} | Yes |
Success Response
Code: 200 OK
{
"@context": "/api/contexts/Menage",
"@id": "/api/menages/1",
"@type": "Menage",
"id": 1,
"codeMenage": "MEN-2024-00001",
"tailleMenage": 5,
"scorePmt": "45.67",
"statut": "actif",
"latitude": "14.7167",
"longitude": "-17.4677",
"altitude": "12.5",
"precisionGps": "5.0",
"nbEnfants04": 1,
"nbEnfants514": 2,
"nbAdultes1564": 2,
"nbPersonnes65Plus": 0,
"nbHandicapes": 0,
"nbActifsOccupes": 2,
"chefMenage": {
"@id": "/api/chef_menages/1",
"@type": "ChefMenage",
"id": 1,
"nomComplet": "Mamadou Diallo",
"sexe": "M",
"age": 45,
"niveauEducation": "secondaire",
"occupationPrincipale": "commerce",
"statutMatrimonial": "marie",
"telephone": "771234567",
"numeroMobileMoney": "771234567",
"compteBancaire": null
},
"logement": {
"@id": "/api/logements/1",
"@type": "Logement",
"typeLogement": "maison",
"statutOccupation": "proprietaire",
"nbPieces": 4,
"materiauMur": "ciment",
"materiauToit": "tole",
"materiauSol": "ciment",
"sourceEau": "robinet",
"typeToilette": "wc_chasse",
"sourceEclairage": "electricite",
"combustibleCuisine": "gaz"
},
"region": {
"@id": "/api/regions/1",
"@type": "Region",
"id": 1,
"nom": "Dakar",
"code": "DK"
},
"secteur": {
"@id": "/api/secteurs/1",
"@type": "Secteur",
"id": 1,
"nom": "Secteur 1"
},
"commune": {
"@id": "/api/communes/1",
"@type": "Commune",
"id": 1,
"nom": "Commune 1"
},
"localite": {
"@id": "/api/localites/1",
"@type": "Localite",
"id": 1,
"nom": "Localite 1"
},
"beneficiaire": {
"@id": "/api/beneficiaires/1",
"@type": "Beneficiaire",
"id": 1,
"actif": true,
"modePaiement": "orange_money"
},
"membres": [
{
"@id": "/api/membre_menages/1",
"nomComplet": "Fatou Diallo",
"lienParente": "epouse",
"sexe": "F",
"age": 38
},
{
"@id": "/api/membre_menages/2",
"nomComplet": "Ibrahima Diallo",
"lienParente": "fils",
"sexe": "M",
"age": 15
}
],
"createdAt": "2024-01-15T10:30:00+00:00",
"updatedAt": "2024-01-20T14:15:00+00:00",
"createdBy": {
"@id": "/api/users/1",
"email": "admin@pch-sig.sn"
}
}
Error Responses
404 Not Found
{
"@context": "/api/contexts/Error",
"@type": "hydra:Error",
"hydra:title": "An error occurred",
"hydra:description": "Item not found for \"/api/menages/999\""
}
403 Forbidden
{
"@context": "/api/contexts/Error",
"@type": "hydra:Error",
"hydra:title": "An error occurred",
"hydra:description": "Access Denied."
}
Examples
cURL
curl https://sig.ucp-pch.org/api/menages/1 \
-H "Authorization: Bearer TOKEN"
JavaScript
const getMenage = async (id) => {
const response = await fetch(
`https://sig.ucp-pch.org/api/menages/${id}`,
{
headers: {
'Authorization': `Bearer ${localStorage.getItem('token')}`
}
}
);
if (response.status === 404) {
throw new Error('Household not found');
}
return response.json();
};
// Usage
try {
const menage = await getMenage(1);
console.log(`Head: ${menage.chefMenage.nomComplet}`);
console.log(`Size: ${menage.tailleMenage} people`);
console.log(`PMT Score: ${menage.scorePmt}`);
} catch (error) {
console.error(error.message);
}
Python
import requests
def get_menage(token, menage_id):
response = requests.get(
f'https://sig.ucp-pch.org/api/menages/{menage_id}',
headers={'Authorization': f'Bearer {token}'}
)
if response.status_code == 404:
raise Exception('Household not found')
return response.json()
# Usage
menage = get_menage(token, 1)
print(f"Code: {menage['codeMenage']}")
print(f"Head: {menage['chefMenage']['nomComplet']}")
print(f"Region: {menage['region']['nom']}")
Response Fields
Household
| Field | Type | Description |
|---|---|---|
| id | integer | Unique identifier |
| codeMenage | string | Unique household code |
| tailleMenage | integer | Number of people |
| scorePmt | string | PMT score (decimal) |
| statut | string | Status (actif, inactif, en_attente) |
| latitude, longitude | string | GPS coordinates |
Head of Household
| Field | Type | Description |
|---|---|---|
| nomComplet | string | Full name |
| sexe | string | M or F |
| age | integer | Age |
| telephone | string | Phone number |
| niveauEducation | string | Education level |
| occupationPrincipale | string | Main activity |
Housing
| Field | Type | Description |
|---|---|---|
| typeLogement | string | Type (house, apartment, etc.) |
| nbPieces | integer | Number of rooms |
| materiauMur | string | Wall material |
| sourceEau | string | Water source |
Notes
- The response includes all relations (head, housing, members, beneficiary)
- GPS coordinates are returned as strings (decimal)
- The
membresfield contains the list of household members excluding the head