> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xwift.africa/llms.txt
> Use this file to discover all available pages before exploring further.

# Geo Data

> Countries and the divisions under them, from regions and counties down to sub-counties and parishes.

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 `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` |

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 `Taita-Taveta` for `Taita Taveta`. Plural keys are accepted when they name that country's level: `counties`, `subcounties`, `districts`, `regions`, `states`, `lgas`, `parishes`.

**country** `string`

Country name: `Ghana`, `Kenya`, `Nigeria`, `Tanzania`, or `Uganda`. Omit it to list countries and their levels.

**region** `string`

Ghana or Tanzania region. Returns its districts.

**district** `string`

Ghana or Tanzania district, or a Uganda district. A Uganda district returns its counties.

**county** `string`

Kenya county, or a Uganda county. A Kenya county returns sub-counties. A Uganda county requires `district` and returns sub-counties.

**subcounty** `string`

Kenya sub-county, which requires `county`, or a Uganda sub-county, which requires `district` and `county` and returns parishes.

**state** `string`

Nigeria state. Returns its local government areas.

**lga** `string`

Nigeria local government area. Requires `state`.

**parish** `string`

Uganda parish. Requires `district`, `county`, and `subcounty`.

`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:

```bash theme={null}
curl "https://api.xwift.africa/account/geo-data" \
  -H "x-api-key: YOUR_CONSUMER_KEY"
```

Kenya counties:

```bash theme={null}
curl "https://api.xwift.africa/account/geo-data?country=Kenya" \
  -H "x-api-key: YOUR_CONSUMER_KEY"
```

Sub-counties in Nairobi:

```bash theme={null}
curl "https://api.xwift.africa/account/geo-data?country=Kenya&county=Nairobi" \
  -H "x-api-key: YOUR_CONSUMER_KEY"
```

Districts in Greater Accra:

```bash theme={null}
curl "https://api.xwift.africa/account/geo-data?country=Ghana&region=Greater%20Accra" \
  -H "x-api-key: YOUR_CONSUMER_KEY"
```

Parishes under Kampala Central:

```bash theme={null}
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 |

```bash theme={null}
curl "{{base_url}}/account/geo-data?country=Kenya&county=Nairobi" \
  -H "x-api-key: YOUR_CONSUMER_KEY"
```

```json theme={null}
{
  "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
      }
    ]
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.