A Python wrapper for the Australian Business Register (ABR) ABN Lookup API.
Project description
abn-lookup
Unofficial Python client for the Australian ABN Lookup API. Provides typed responses, a simple interface, and easy integration for retrieving ABN details in Python applications. Community-driven and lightweight with zero external dependencies.
Features
- Zero Dependencies: Built using Python’s standard library (
urllib), making it lightweight and easy to install anywhere. - Typed Models: Responses are mapped to Python dataclasses for excellent IDE support and autocompletion.
- Comprehensive Search: Supports searching by ABN, ASIC, name, postcode, charity status, and more.
- Modern Python: Uses modern Python 3 features and type hinting.
Installation
pip install abn-lookup
Usage
You must register for a GUID at:
http://abr.business.gov.au/Webservices.aspx
Initialization
from abnlookup import ABNLookupClient
# Initialize client with your GUID
client = ABNLookupClient(guid="YOUR_GUID_HERE")
Search by ABN
Retrieves detailed information for a specific Australian Business Number.
result = client.search_by_abn("51 835 430 479")
print(f"Company: {result.legal_name.name}")
print(f"Status: {result.abn_status.status_code}")
print(f"Type: {result.entity_type}")
print(
f"Address: "
f"{result.main_business_location.state} "
f"{result.main_business_location.postcode}"
)
# Check for specific funds (if available)
if result.approved_worker_entitlement_fund:
print(f"AWEF: {result.approved_worker_entitlement_fund}")
Search by ASIC
Retrieves detailed information using an ASIC number.
result = client.search_by_asic("123 456 789")
print(f"ABN: {result.abn}")
if result.dgr_item_number:
print(f"DGR Item: {result.dgr_item_number}")
Search by Name
Returns a list of entities matching a name query.
results = client.search_by_name(
name="Test Company",
state="NSW",
postcode="2000",
min_score=90,
)
for item in results:
print(f"{item.name} (ABN: {item.abn}) - Score: {item.score}")
Advanced Searches
The library supports several specialised search methods that return lists of matches.
Search by Postcode
# Get all active ABNs in a specific postcode
results = client.search_by_postcode(postcode="2000")
Search by ABN Status
# Specific status filters
results = client.search_by_abn_status(
postcode="2000",
active_only=True,
gst_registered_only=True,
)
Search by Charity
results = client.search_by_charity(
state="VIC",
charity_type_code="ADVANCEMENT OF RELIGION", # Optional
)
Search by Registration Event
# Find ABNs registered in a specific month and year
results = client.search_by_registration_event(
month=1,
year=2024,
state="QLD",
)
Error Handling
The library uses custom exceptions for predictable error handling.
from abnlookup import (
ABNLookupClient,
ABNNotFoundError,
APIConnectionError,
)
try:
client.search_by_abn("00 000 000 000")
except ABNNotFoundError:
print("That ABN does not exist.")
except APIConnectionError:
print("Could not connect to the ABN Lookup service.")
except Exception as e:
print(f"An unexpected error occurred: {e}")
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file abn_lookup-0.1.0.tar.gz.
File metadata
- Download URL: abn_lookup-0.1.0.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db2b816f6cf598d0c48b15205f5a7632f39b1e6068a86486fab04675f81eb522
|
|
| MD5 |
b62408e617e96b3a73ad9d7662903fe6
|
|
| BLAKE2b-256 |
f70114ab96456767ba4e461f59bc8d28bdca8bf0f5161b4f8a1687bbb1c02ca1
|
File details
Details for the file abn_lookup-0.1.0-py3-none-any.whl.
File metadata
- Download URL: abn_lookup-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb57565f74004ee089840044ba2bd5d2d1060c8783802e4f162492862f6a6176
|
|
| MD5 |
c5e7dbb2ea8001e053686c2ba3fdd859
|
|
| BLAKE2b-256 |
222dc89f9d342307558f241a9f62212bf0f9d4d0d4895bea7856424c3d0649bf
|