ng-postcode
Python library for Nigeria's National Digital Alphanumeric Postcode System (NDAPS), the building-level postcode NIPOST launched in October 2026. Parse, validate and format postcodes offline, and call the postcode.gov.ng API for lookup, autocomplete and reverse geocoding.
Also available for Rust: ng-postcode on crates.io.
pip install ng-postcode # offline core, no dependencies
pip install "ng-postcode[client]" # adds the API client (httpx)
Format
An 11-character code in five segments: state, LGA, district, area, building unit.
| Style | Example |
|---|---|
| Canonical | EK-01-A03-FK-01 |
| Display | EK 01 A03 FK 01 |
| Compact | EK01A03FK01 |
Compact form as a regular expression: ^[A-Z]{2}(0[1-9]|[1-9][0-9])[A-Z0-9]{3}[A-Z]{2}(0[1-9]|[1-9][0-9])$
Offline
Expected failures are returned as values, not raised, so the type checker makes you handle them.
from ng_postcode import Postcode, Segment, parse
match parse("ek 01 a03 fk 01"):
case Postcode() as code:
print(code) # EK-01-A03-FK-01
print(code.compact) # EK01A03FK01, store this
print(code.spaced) # EK 01 A03 FK 01
print(code.prefix(Segment.AREA)) # EK-01-A03-FK
case error:
print(error) # e.g. "invalid lga segment"
parseaccepts hyphenated, spaced or compact input in either case.parse_lenientfirst swaps look-alikes that cannot occur where they stand (O/0,I/1,S/5,B/8) and reports how many it changed.from_segmentsassembles a code from its parts and zero-fills the LGA and unit.Postcodeis immutable, hashable and sorts by state, LGA, district, area, unit.
A well-formed code is not necessarily assigned to a building. Only the API can confirm that a postcode exists.
API
from ng_postcode import Postcode, parse
from ng_postcode.api import lookup
from ng_postcode.client import Client
code = parse("EK-01-A03-FK-01")
assert isinstance(code, Postcode)
with Client(api_key="nipost_live_...") as client:
found = client.send(lookup(code, level=2))
send returns the typed response, an ApiError (for example auth_required or insufficient_credits) or a TransportError. AsyncClient has the same interface for asyncio.
ng_postcode.api covers lookup, autocomplete, reverse geocoding and nearby search. Each function returns a Request value and decode turns a status and body into a typed result, so it works with any HTTP client without the client extra.
License
MIT
Metadata
Release files for ng-postcode 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ng_postcode-0.2.0.tar.gz | 12.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ng_postcode-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.8 kB
Release files / ng_postcode-0.2.0.tar.gz
| Download URL | ng_postcode-0.2.0.tar.gz |
|---|---|
| Size | 12.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e4b7d6cd0d2d9aad956932c5e17c5b8dbe84baaca67f10f591ab09eaa15f9e61
|
|
BLAKE2b-256 checksum How to use checksums |
108c7338410c5707f158df0b7801caa4c43a81d5170e5d225b1f2ef9281d3bc1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.
Transparency logRelease files / ng_postcode-0.2.0-py3-none-any.whl
| Download URL | ng_postcode-0.2.0-py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f54f525de3822737b6ddc14b73e1c5f2ac77601065a5932a8189c8936266a1b5
|
|
BLAKE2b-256 checksum How to use checksums |
894a3cd3b1b564e140140a32180836a2a355568577dcdc8b88ab5caf58a3bee9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.
Transparency log