A lightweight Python SDK for cascading Uganda address selection.
# ug-address
A lightweight Python SDK for cascading Uganda address selection.
Supports:
**District → County/Division → Sub-county → Parish → Village**
The SDK is:
- dependency-free
- offline-first
- fast
- pure Python
- framework agnostic
Perfect for:
- Django apps
- Flask apps
- FastAPI
- CLI tools
- data processing
- backend validation
- Uganda-based SaaS products
---
# Installation
```bash
pip install ug-address
```
---
# Quick Start
```python
from ug_address import UgAddress
addr = UgAddress()
districts = addr.get_districts()
print(districts[:5])
```
---
# Example Output
```python
[
{
"id": "98",
"name": "ABIM"
},
{
"id": "1",
"name": "ADJUMANI"
}
]
```
---
# Full Example
```python
from ug_address import UgAddress
addr = UgAddress()
# -----------------------------------
# Get districts
# -----------------------------------
districts = addr.get_districts()
print('DISTRICTS:\n')
for district in districts[:5]:
print(
district['id'],
'-',
district['name']
)
# -----------------------------------
# Select district
# -----------------------------------
addr.select_district('32') # Kampala
counties = addr.get_counties()
print('\nCOUNTIES:\n')
for county in counties:
print(
county['id'],
'-',
county['name']
)
# -----------------------------------
# Select county
# -----------------------------------
addr.select_county(counties[0]['id'])
subcounties = addr.get_subcounties()
print('\nSUBCOUNTIES:\n')
for subcounty in subcounties[:5]:
print(
subcounty['id'],
'-',
subcounty['name']
)
# -----------------------------------
# Select subcounty
# -----------------------------------
addr.select_subcounty(subcounties[0]['id'])
parishes = addr.get_parishes()
print('\nPARISHES:\n')
for parish in parishes[:5]:
print(
parish['id'],
'-',
parish['name']
)
# -----------------------------------
# Select parish
# -----------------------------------
addr.select_parish(parishes[0]['id'])
villages = addr.get_villages()
print('\nVILLAGES:\n')
fo …