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:
- A free BSB lookup API
- A BSB validator web tool
- SWIFT/BIC code lookup for Australian banks
- Bulk BSB lookup
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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bsb_validate-1.0.0.tar.gz | 5.6 kB | Without provenance | Details for bsb_validate-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bsb_validate-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for bsb_validate-1.0.0-py3-none-any.whl |
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
|
Security for bsb-validate 1.0.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.