Skip to main content

bsb-validate (Python)

Validate, format, decode, and look up Australian BSB (Bank State Branch) numbers in Python.

  • ✅ Offline validation — no network call needed to check format
  • 🔎 Full lookups — bank, branch, address and payment capabilities via the free BSBFinder API
  • 🧩 Zero dependencies (standard library only)
  • 🐍 Python 3.8+

BSB numbers are the six-digit codes that route domestic bank transfers in Australia. This library helps you validate them before submitting a payment, decode their structure, and fetch full branch details on demand.

Install

pip install bsb-validate

Quick start

from bsb_validate import validate_bsb, format_bsb, decode_bsb, lookup_bsb

# Offline: validate format
validate_bsb("062-000")
# → {'valid': True, 'formatted': '062-000'}

validate_bsb("62")
# → {'valid': False, 'formatted': None, 'reason': 'BSB must contain exactly 6 digits'}

# Offline: normalise messy input
format_bsb(" 062 000 ")   # → '062-000'
format_bsb("062000")      # → '062-000'

# Offline: decode the structural parts
decode_bsb("062-000")
# → {'formatted': '062-000', 'bank_code': '06', 'state_code': '2', 'branch_code': '000'}

# Online: full details via the BSBFinder API
details = lookup_bsb("062-000")
print(details["bank"], details.get("branch"), details.get("address"))

API

validate_bsb(value) -> dict

Checks whether a value is a structurally valid BSB (six digits). Works fully offline. Returns {"valid", "formatted", "reason"?}.

This validates format, not whether the BSB is currently active in the AusPayNet register. For that, use lookup_bsb().

format_bsb(value) -> str | None

Normalises any 6-digit input ("062000", "062-000", " 062 000 ", 123456) to canonical NNN-NNN form. Returns None if it can't be reduced to six digits.

decode_bsb(value) -> dict | None

Breaks a BSB into its parts: bank_code (institution), state_code (state/territory), and branch_code. Returns None on invalid input.

lookup_bsb(value, timeout=10.0) -> dict

Fetches full details for a BSB from the free BSBFinder API — bank name, branch, address, SWIFT code and payment methods (BECS/NPP).

Raises InvalidBSBError for malformed input and BSBNotFoundError if the BSB isn't in the register.

Data source

Full lookups are powered by BSBFinder.com, a free tool that indexes every active Australian BSB code (sourced from AusPayNet). BSBFinder also offers:

The API is free to use for reasonable volumes and requires no authentication.

A JavaScript/Node version of this library is also available on npm as bsb-validate.

License

MIT © Ujwal Jayendran


Built alongside BSBFinder.com — free Australian bank code tools.

Metadata

Release files for bsb-validate 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bsb-validate 1.0.0
File Size Uploaded
bsb_validate-1.0.0.tar.gz 5.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bsb-validate 1.0.0
File Interpreter ABI Platform
bsb_validate-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.1 kB

Release files / bsb_validate-1.0.0.tar.gz

Download URL bsb_validate-1.0.0.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bb711ae3f49a566f9beb148264be015e7e4848019df05b4998fcba00c2cff343
BLAKE2b-256 checksum
How to use checksums
38afa2cd5de29137a47d3d714dff44200bf8a111f46aaec3a46811f9b5af3f0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.1

Release files / bsb_validate-1.0.0-py3-none-any.whl

Download URL bsb_validate-1.0.0-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
23a2b3e06126e314a2b96cbb42761bef3055b92b2854ca61f35c2c5c9c646a3e
BLAKE2b-256 checksum
How to use checksums
7905d3fdb0a94454495de26e38acc71c82cce7c7e120385018b30e372d9f80de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.1

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page