curl "{{base_url}}/account/geo-data?country=Kenya&county=Nairobi" \
-H "x-api-key: YOUR_CONSUMER_KEY"
{
"code": 200,
"message": "Geo data",
"data": {
"country": "Kenya",
"levels": ["county", "subcounty"],
"level": "subcounty",
"filters": {
"county": "Nairobi"
},
"places": [
{
"name": "Dagoretti",
"has_children": false
},
{
"name": "Westlands",
"has_children": false
}
]
}
}
Geo Data
Geo Data
Countries and the divisions under them, from regions and counties down to sub-counties and parishes.
GET
/
account
/
geo-data
curl "{{base_url}}/account/geo-data?country=Kenya&county=Nairobi" \
-H "x-api-key: YOUR_CONSUMER_KEY"
{
"code": 200,
"message": "Geo data",
"data": {
"country": "Kenya",
"levels": ["county", "subcounty"],
"level": "subcounty",
"filters": {
"county": "Nairobi"
},
"places": [
{
"name": "Dagoretti",
"has_children": false
},
{
"name": "Westlands",
"has_children": false
}
]
}
}
Geo data is the place list for an address. Each country names its own levels. Call this with no query parameters to see those levels, then add
Put each filter in the query string, in that order. A subcounty request also needs the district and county above it. Matching ignores case. Older spellings are accepted and returned under the current name, such as
Kenya counties:
Sub-counties in Nairobi:
Districts in Greater Accra:
Parishes under Kampala Central:
country and one level at a time until you reach the place you need.
Levels differ by country:
| Country | Levels, in order |
|---|---|
| Ghana | region, district |
| Kenya | county, subcounty |
| Nigeria | state, lga |
| Tanzania | region, district |
| Uganda | district, county, subcounty, parish |
Taita-Taveta for Taita Taveta. Plural keys are accepted when they name that country’s level: counties, subcounties, districts, regions, states, lgas, parishes.
Country name:
Ghana, Kenya, Nigeria, Tanzania, or Uganda. Omit it to list countries and their levels.Kenya county, or a Uganda county. A Kenya county returns sub-counties. A Uganda county requires
district and returns sub-counties.Kenya sub-county, which requires
county, or a Uganda sub-county, which requires district and county and returns parishes.data.level is the level of data.places. It is null when the last filter is a place with no children. Each place includes name and has_children. A place may include aliases.
Sample requests
List countries and the filter names each one accepts:curl "https://api.xwift.africa/account/geo-data" \
-H "x-api-key: YOUR_CONSUMER_KEY"
curl "https://api.xwift.africa/account/geo-data?country=Kenya" \
-H "x-api-key: YOUR_CONSUMER_KEY"
curl "https://api.xwift.africa/account/geo-data?country=Kenya&county=Nairobi" \
-H "x-api-key: YOUR_CONSUMER_KEY"
curl "https://api.xwift.africa/account/geo-data?country=Ghana®ion=Greater%20Accra" \
-H "x-api-key: YOUR_CONSUMER_KEY"
curl "https://api.xwift.africa/account/geo-data?country=Uganda&district=Kampala&county=Kampala%20Central%20Division&subcounty=Kampala%20Central" \
-H "x-api-key: YOUR_CONSUMER_KEY"
Errors
| Message | When |
|---|---|
country is required. | A level query parameter was sent without country |
Unsupported country. Allowed: Ghana, Kenya, Nigeria, Tanzania, Uganda. | country is not one of those names |
Unknown filter {key}. Use: {levels}. | The filter is not a level for that country |
Pass {level} before {level}. | A deeper level was sent without the level above it |
Unknown {level}. | The place name is not under the parent you sent |
An unexpected error occurred. Please try again. | The division list could not be read |
curl "{{base_url}}/account/geo-data?country=Kenya&county=Nairobi" \
-H "x-api-key: YOUR_CONSUMER_KEY"
{
"code": 200,
"message": "Geo data",
"data": {
"country": "Kenya",
"levels": ["county", "subcounty"],
"level": "subcounty",
"filters": {
"county": "Nairobi"
},
"places": [
{
"name": "Dagoretti",
"has_children": false
},
{
"name": "Westlands",
"has_children": false
}
]
}
}
