Infrastructure API¶
Points-of-interest database - vet centres, pharmacies, input shops, milk-collection centres, and similar livestock-relevant infrastructure. POIs are uploaded as a CSV and queried by type or by proximity to a cluster centroid.
Edit pattern
Same backend-CSV-upload pattern as the existing LEAF data update flow. There is no UI editor - partners maintain the dataset in a spreadsheet and re-upload.
CSV Schema¶
| Column | Required | Description |
|---|---|---|
type |
Yes | POI type, e.g. vet_centre, pharmacy, input_shop (case-insensitive on filter). |
name |
Yes | Display name. |
lat, long |
Yes | WGS84 coordinates. |
district_name |
No | Parent district. |
block_name |
No | Parent block. |
gp_name |
No | Parent GP. |
vill_name |
No | Hosting village. |
List POIs¶
Query Parameters¶
| Param | Type | Required | Description |
|---|---|---|---|
type |
string | No | Filter by POI type (case-insensitive). |
block |
string | No | Filter by block_name. |
district |
string | No | Filter by district_name. |
Response¶
[
{
"type": "vet_centre",
"name": "Khowang Vet",
"lat": 27.30,
"long": 94.92,
"district_name": "DIBRUGARH",
"block_name": "KHOWANG",
"gp_name": "KHOWANG",
"vill_name": "KHOWANG VET"
}
]
Records are ordered by type, then name. Optional fields (district_name, block_name, gp_name, vill_name) may be null.
| Code | Description |
|---|---|
200 |
Array of POI records. |
500 |
Unexpected server error. |
Import POIs CSV¶
Replaces the entire infrastructure dataset with the uploaded CSV. Either send multipart/form-data with a file field, or POST raw CSV with Content-Type: text/csv.
Response¶
| Code | Description |
|---|---|
200 |
Success - number of rows stored. |
400 |
Missing required columns or empty body. |
500 |
Unexpected server error. |
Full replacement
The import DELETEs every existing row before inserting the upload, so the CSV must contain the complete dataset each time. Required columns are type, name, lat, long; missing optional columns (district_name, block_name, gp_name, vill_name) are stored as null. The file is decoded as UTF-8 (BOM tolerated).
Nearest POIs¶
Returns up to n nearest POIs to a point, with distance_km attached. Provide either cluster_id (uses the cluster centroid) or both lat and long.
Query Parameters¶
| Param | Type | Required | Description |
|---|---|---|---|
cluster_id |
string | No | When set, the cluster's centroid is the reference point. |
lat, long |
number | Conditional | Required if cluster_id is not provided. |
type |
string | No | Filter by POI type. |
n |
integer | No | Max results (default 5). |
max_km |
number | No | Optional distance cap. |
Response¶
[
{
"type": "pharmacy",
"name": "Khowang Pharma",
"lat": 27.18,
"long": 94.83,
"district_name": "DIBRUGARH",
"block_name": "KHOWANG",
"gp_name": "KHOWANG",
"vill_name": "KHOWANG PHARMA",
"distance_km": 3.4217
}
]
Distance
distance_km is the raw haversine distance (full float precision, not rounded). Results are the n nearest after any type/max_km filtering, sorted by distance ascending.
| Code | Description |
|---|---|
200 |
Sorted by distance ascending. |
400 |
Neither cluster_id nor lat+long provided (or lat/long not numeric). |
404 |
cluster_id not found in the cluster store. |
500 |
Unexpected server error. |