Lookup Australian postcodes, suburbs, and states from Python. The dataset (16,511 rows) is bundled inside the package — no network calls, zero runtime dependencies (stdlib only).
pip install australian-postcodesOr from this repo directly:
pip install "git+https://github.com/schappim/australian-postcodes.git#subdirectory=libraries/python"import australian_postcodes as ap
# Find by postcode (always a list — one postcode can cover many suburbs)
ap.find_by_postcode("2000")
# [Record(postcode='2000', suburb='SYDNEY', state='NSW', lat='-33.860', lon='151.210', category='Delivery Area'), ...]
# Find by suburb (case-insensitive)
ap.find_by_suburb("melbourne")
# Narrow by state
ap.find_by_suburb("Springfield", state="QLD")
# The most common case — give me THE postcode
ap.postcode_for("Sydney", "NSW") # '2000'
# Everything in a state
len(ap.all_in_state("ACT")) # 151
# All records
len(ap.all_records()) # 16511Each Record is a frozen dataclass with postcode, suburb, state, lat, lon, category.
The package installs an australian-postcodes script:
australian-postcodes by-postcode 2000
australian-postcodes by-suburb Sydney --state NSW
australian-postcodes in-state ACT
australian-postcodes postcode-for Melbourne VIC # -> 3000All commands return JSON except postcode-for which prints the bare string.
postcodeis astr(preserves leading zeros —"0810","0200")- Suburb names are UPPERCASE
categoryis"Delivery Area"or"Post Office Boxes"- Lat/Lon are approximate (3 dp) and may be empty for newer rows