REST API and GeoJSON dataset for all South African District and Metropolitan Municipalities.
# South Africa District API
A lightweight REST API and GeoJSON dataset for South Africa's **52 Metropolitan and District Municipalities**.
The project combines official municipality information with OpenStreetMap, Wikidata and Statistics South Africa into a single developer-friendly API.
---
## Features
- πΏπ¦ 52 District & Metropolitan Municipalities
- π Administrative headquarters
- πΊ GeoJSON boundaries
- π OSM Relation IDs
- π§ Wikidata IDs
- π Wikipedia links
- π₯ Population
- π Area (kmΒ²)
- π Search API
- β‘ Ready for Leaflet, OpenLayers and MapLibre
- π Automatic update scripts
---
## Project Structure
```
south-africa-district-api/
api/
data/
docs/
examples/
scripts/
package.json
README.md
```
---
## Installation
```bash
git clone
github.com
cd south-africa-district-api
npm install
```
---
## Running
Development
```bash
npm run dev
```
Production
```bash
npm start
```
---
## Building the dataset
Download OpenStreetMap boundaries
```bash
npm run osm
```
Download Wikidata metadata
```bash
npm run wikidata
```
Download Statistics South Africa data
```bash
npm run statssa
```
Build GeoJSON
```bash
npm run build
```
Run everything
```bash
npm run update
```
---
# API Endpoints
## Provinces
```
GET /api/provinces
```
Returns the nine South African provinces.
---
## Municipalities
```
GET /api/municipalities
```
Returns every district and metropolitan municipality.
---
## Municipality
```
GET /api/municipalities/DC22
```
Returns one municipality.
---
## Search
```
GET /api/search?q=umgungundlovu
```
Search by
- Municipality code
- Municipality name
- Seat
- Province
- Wikidata ID
- OSM Relation ID
---
## Boundaries
Entire province
```
GET /api/boundaries/KZN
```
Single municipality
```
GET /api/boundaries/DC22
```
---
## Municipality Object
```json
{
"code": "DC22",
"name": "uMgungundlovu District Municipality",
"province": "KwaZulu-Natal",
"type": "District Municip β¦