Tanzania locations API and npm package— 31 regions, 168 districts, 4,054 wards, 75,061 streets with postcodes.
# tz-locations
Tanzania Location addresses — **31 regions, 168 districts, 4,054 wards, 75,061 streets** with postcodes.
## Why
There's no structured, developer-friendly address data for Tanzania. Every team building for TZ ends up scraping the same postal data, maintaining brittle spreadsheets, or hardcoding locations. This project fixes that — once and for all.
## Components
| Component | Description |
|-----------|-------------|
| `api/` | REST API — Hono + Cloudflare Workers + D1, 12 endpoints, full-text search |
| `packages/tz-locations/` | npm package — offline-first, typed, zero network dependency |
| `scraper/` | Python async scraper for tanzaniapostcode.com |
| `docs/` | Single-page documentation site |
## Quick Start: API
```bash
# All regions
curl
tz-locations-api.mwemanoor.…
# Districts in Dar es Salaam
curl
tz-locations-api.mwemanoor.…
# Search
curl "
tz-locations-api.mwemanoor.…"
# Postcode lookup
curl
tz-locations-api.mwemanoor.…
```
## Quick Start: npm Package
```bash
npm install tz-locations
```
```typescript
import { getRegions, getDistrictsByRegion, searchLocations, getByPostcode } from 'tz-locations';
const regions = getRegions(); // 31 regions
const districts = getDistrictsByRegion('dar-es-salaam'); // districts in DSM
const results = searchLocations('buguruni'); // search
const location = getByPostcode('12102'); // postcode lookup
```
## API Endpoints
| Endpoint | Description |
|----------|-------------|
| `GET /v1/regions` | All 31 regions |
| `GET /v1/regions/:slug` | Single region with stats |
| `GET /v1/regions/:slug/districts` | Districts in a region |
| `GET /v1/districts/:slug` | Single district with stats |
| `GET /v1/districts/:slug/wards` | Wards in a district |
| `GET /v1/wards/:slug` | Single wa …