A structured, versioned, and developer-friendly data layer for Kenya.
Kenya Data provides structured Kenyan administrative and geographic data through a portable SQLite database and native Python and TypeScript SDKs.
The project currently provides:
- 47 counties
- 290 constituencies
- 1,450 wards
- County → constituency and constituency → ward relationships
- Stable identifiers and codes
- Dataset version and update metadata
- A bundled, read-only SQLite database
- Native Python and TypeScript APIs
| Package | Registry | Version |
|---|---|---|
| Python | PyPI | 0.1.1 |
| TypeScript | npm | 0.1.1 |
The current dataset is 2026.09-iebc2012-knbs2019 (approved), updated on 2026-09-20.
The same dataset is published for both Python and TypeScript, so applications can use the SDK that best fits their stack. The screenshots below show the packages as published in their respective registries.
The Python SDK is available on PyPI as kenya-data, making the administrative dataset installable with standard Python tooling.
The TypeScript SDK is available on npm as kenya-data-core, with the bundled SQLite database ready for use in JavaScript and TypeScript projects.
from kenya_data import Kenya
kenya = Kenya()
print(kenya.counties.list())
print(kenya.counties.get("Nakuru"))
print(kenya.constituencies.in_county("Nakuru"))
print(kenya.wards.in_constituency("Naivasha"))
kenya.close()Install it with:
pip install kenya-dataimport { Kenya } from "kenya-data-core";
const kenya = new Kenya();
console.log(kenya.counties.list());
console.log(kenya.counties.get("Nakuru"));
console.log(kenya.constituencies.inCounty("Nakuru"));
console.log(kenya.wards.inConstituency("Naivasha"));
kenya.close();Install it with:
npm install kenya-data-coreKenya Data models a simple administrative hierarchy:
Kenya
├── Counties (47)
│ └── Constituencies (290)
│ └── Wards (1,450)
└── Dataset metadata
Every record has stable identifiers and relationships to the level above it. For example, Nairobi contains 17 constituencies, and those relationships are represented directly in the dataset.
The SDKs also expose dataset metadata:
print(kenya.dataset.version)
print(kenya.dataset.updated_at)
print(kenya.dataset.info())console.log(kenya.dataset.version);
console.log(kenya.dataset.updatedAt);
console.log(kenya.dataset.info());The published kenya-data==0.1.1 and kenya-data-core@0.1.1 packages have been tested from clean environments using PyPI and npm. Both distributions were verified to provide:
- 47 counties, 290 constituencies, and 1,450 wards
- A working bundled SQLite database
- Matching dataset metadata
- Correct Nairobi and constituency relationships
- Valid constituency-to-county and ward-to-constituency references
Relationship validation returned:
Constituencies with invalid county: 0
Wards with invalid constituency: 0
Kenya Data documents its sources, retrieval information, dataset versions, transformations, validation procedures, data-model decisions, known discrepancies, and approval status. The current dataset incorporates documented Kenyan administrative and geographic information, including IEBC delimitation data and KNBS census data.
See:
The project follows this pipeline:
Data sources → Research → Source registry → Ingestion → Validation
→ Approved data → SQLite → Python SDK / TypeScript SDK
SQLite is the common distribution layer used by both SDKs. It is portable, serverless, self-contained, easy to inspect, and requires no API key or database server for ordinary queries.
More detail is available in:
Python requires Python 3.9+:
pip install kenya-data
python -c "from kenya_data import Kenya; print(len(Kenya().counties.list()))"Expected output: 47.
For TypeScript and JavaScript:
npm install kenya-data-core
npm list kenya-data-coregit clone https://github.com/ToshGitonga0/kenya-data.git
cd kenya-data
make setup
make build-db
make validate
make test
make lintUse make inspect-db to inspect the generated SQLite database.
kenya-data/
├── data/ # Approved data and the SQLite database
├── docs/ # Architecture, quality, research, and SDK documentation
├── packages/ # Python and TypeScript SDKs
├── research/ # Sources, investigations, and discrepancies
├── screenshots/ # Registry screenshots used in this README
├── Makefile
├── CONTRIBUTING.md
├── LICENSE
└── README.md
Contributions are welcome. Depending on the change, contributions may involve research, source documentation, data transformation, validation, tests, documentation, or SDK implementation. Changes to the dataset should preserve provenance and validation information.
See CONTRIBUTING.md for the contribution workflow.
Kenya Data is released under the MIT License. See LICENSE for the full license text.

