Skip to main content

A python client to interact with ABN Lookup services

Project description

GitHub Actions Workflow Status

abn-lookup-service

A python client to interact with ABN Lookup services

This library provides a Python interface to the Australian Business Register (ABR) XML Search API. All API methods are based on the official ABR documentation.

Installation

python3 -m pip install 'abn-lookup-service @ git+https://github.com/tmck-code/abn-lookup-service'

Authentication

You'll need an ABN Lookup GUID from the Australian Business Register. Set it as an environment variable:

export ABN_LOOKUP_GUID="your-guid-here"

CLI

The package includes a command-line interface:

# Search by ABN
abn-lookup-service abn --abn 53004085616

# Search by name
abn-lookup-service name --name "Telstra" --state "VIC" --limit 5

# Search by postcode
abn-lookup-service postcode --postcode "3000" --state "VIC"

# Advanced name search
abn-lookup-service name-advanced --name "Commonwealth Bank" --state "NSW" --legalName "Y"

Run with --help to see all available commands and options:

abn-lookup-service --help
Example help output
usage: lookup.py [-h] {abn-status,charity,registration-event,update-event,name,abn,asic,postcode,name-advanced} ...

ABN Lookup Client

positional arguments:
  {abn-status,charity,registration-event,update-event,name,abn,asic,postcode,name-advanced}
    abn-status          Search by ABN status
    charity             Search by charity
    registration-event  Search by registration event
    update-event        Search by update event
    name                Search by name
    abn                 Search by ABN
    asic                Search by ASIC
    postcode            Search by postcode
    name-advanced       Advanced search by name

options:
  -h, --help            show this help message and exit
abn-lookup-service name --help
Example help output for 'name' command
usage: lookup.py name [-h] --name NAME --state {NSW,ACT,VIC,QLD,SA,WA,TAS,NT} [--limit LIMIT]

options:
  -h, --help            show this help message and exit
  --name NAME           Name to search for
  --state {NSW,ACT,VIC,QLD,SA,WA,TAS,NT}
                        State to filter results by
  --limit LIMIT         Maximum number of results to return

Usage

Python Library

Basic Example

from abn_lookup_service.lookup import ABNLookupClient
import os

# Initialize the client
client = ABNLookupClient(authentication_guid=os.environ['ABN_LOOKUP_GUID'])

# Search by ABN
for result in client.search_by_abn('53004085616'):
    print(result)

# Search by business name
for result in client.search_by_name(name='Telstra', state='VIC'):
    print(result)

# {"ABN": {"identifierValue": "53653884756", "identifierStatus": "Active"}, "mainName": {"organisationName": "MOONTH MOTORS PTY LTD", "score": "98", "isCurrentIndicator": "Y"}, "mainBusinessPhysicalAddress": {"stateCode": "VIC", "postcode": "3031", "isCurrentIndicator": "Y"}}
# ...

Advanced Example

from abn_lookup_service.lookup import ABNLookupClient
import os

client = ABNLookupClient(authentication_guid=os.environ['ABN_LOOKUP_GUID'])

# Advanced name search with filters
results = client.search_by_name_advanced(
    name='Commonwealth Bank',
    state='NSW',
    legalName='Y',
    minimumScore=80,
    maxSearchResults=10
)

for result in results:
    # Access result fields
    abn = result.get('ABN', {}).get('identifierValue')
    name = result.get('mainName', {}).get('organisationName')
    print(f"ABN: {abn}, Name: {name}")

# ABN: 48045546848, Name: COMMONWEALTH BANK OF AUSTRALIA
# ABN: 53004085616, Name: COMMONWEALTH BANK OF AUSTRALIA
# ...

Supported Methods

SearchByABN (docs)

Search for an entity by ABN.

Parameters:

  • abn (str, required): The ABN to search for
  • includeHistoricalDetails (str, optional): 'Y' or 'N' (default: 'N')

SearchByASIC (docs)

Search for an entity by ASIC number (ACN, ARBN, ARSN, ARFN).

Parameters:

  • asic (str, required): The ASIC number to search for
  • includeHistoricalDetails (str, optional): 'Y' or 'N' (default: 'N')

SearchByName (docs)

Search for entities by name (simple protocol).

Parameters:

  • name (str, required): Name to search for
  • postcode (str, optional): Filter by postcode
  • legalName (str, optional): 'Y' to search legal names only
  • businessName (str, optional): 'Y' to search business names only
  • tradingName (str, optional): 'Y' to search trading names only
  • state (str, optional): Filter by state (NSW, ACT, VIC, QLD, SA, WA, TAS, NT)

SearchByNameAdvanced (docs)

Advanced search for entities by name with additional filters.

Parameters:

  • name (str, required): Name to search for
  • postcode (str, optional): Filter by postcode
  • legalName (str, optional): 'Y' to search legal names only
  • businessName (str, optional): 'Y' to search business names only
  • tradingName (str, optional): 'Y' to search trading names only
  • state (str, optional): Filter by state
  • searchWidth (str, optional): Search width (narrow, typical, wide)
  • minimumScore (int, optional): Minimum matching score (0-100)
  • maxSearchResults (int, optional): Maximum number of results to return
  • activeABNsOnly (str, optional): 'Y' to return only active ABNs

SearchByPostcode (docs)

Search for entities by postcode.

Parameters:

  • postcode (str, required): The postcode to search for

SearchByABNStatus (docs)

Search for entities by ABN status.

Parameters:

  • postcode (str, optional): Filter by postcode
  • activeABNsOnly (str, optional): 'Y' to return only active ABNs
  • currentGSTRegistrationOnly (str, optional): 'Y' to return only GST registered entities
  • entityTypeCode (str, optional): Filter by entity type code

SearchByUpdateEvent (docs)

Search for entities by update event.

Parameters:

  • updatedate (str, required): Update date (YYYY-MM-DD format)
  • postcode (str, optional): Filter by postcode
  • state (str, optional): Filter by state
  • entityTypeCode (str, optional): Filter by entity type code

SearchByRegistrationEvent (docs)

Search for entities by registration event.

Parameters:

  • month (str, required): Month (1-12)
  • year (str, required): Year (YYYY format)
  • postcode (str, optional): Filter by postcode
  • state (str, optional): Filter by state
  • entityTypeCode (str, optional): Filter by entity type code

SearchByCharity (docs)

Search for charities.

Parameters:

  • postcode (str, optional): Filter by postcode
  • state (str, optional): Filter by state
  • charityTypeCode (str, optional): Filter by charity type code
  • concessionTypeCode (str, optional): Filter by concession type code

Development

This doc section is for developers contributing to the project.

Testing

Docker

Build the docker image

 docker build -f test/Dockerfile -t abn-lookup-service .

Run the tests with

docker run \
    -it \
    -v "$PWD":/app \
    abn-lookup-service:latest \
    bash -c 'pytest -vv test'

Host Machine

uv sync --all-groups
. .venv/bin/activate

pytest -vv -s test/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

abn_lookup_service-0.1.1.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

abn_lookup_service-0.1.1-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file abn_lookup_service-0.1.1.tar.gz.

File metadata

  • Download URL: abn_lookup_service-0.1.1.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for abn_lookup_service-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2cfb332187affb9ad739855bac697221839d94340184346fee55a3b88f681dda
MD5 ee7d1240a8ba74fbb6d7db7daccb9c0a
BLAKE2b-256 520c5f29d873287dcc4baf89087c39e218be05543b24473a149bfcb89ce56140

See more details on using hashes here.

File details

Details for the file abn_lookup_service-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for abn_lookup_service-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 99af73e37c9c9abf00ba35ca487becb49e07d50363aa28f6cd2dfb19ccba0386
MD5 f6b935eeab1fc5b8c9db7b9e11ea5a0c
BLAKE2b-256 374f8dc1b4c12cc4dea93277d9119510c36de0e97cda2f5247d6681990920ab3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page