Class library to query the Australian Business Register web services.
$ dotnet add package Universal.AustralianBusinessRegisterA .NET client library for interacting with the Australian Business Register (ABR) web services to search for Australian Business Numbers (ABN) and Australian Company Numbers (ACN).
using Universal.AustralianBusinessRegister;
// Using default authentication GUID
using (var client = new AustralianBusinessRegisterClient())
{
var results = await client.SearchABNAsync("50616294781");
Console.WriteLine($"ABN: {results.Response.BusinessEntity.ABN.IdentifierValue}");
Console.WriteLine($"Name: {results.Response.BusinessEntity.MainNames[0].OrganisationName}");
}
// Using custom authentication GUID
using (var client = new AustralianBusinessRegisterClient("your-auth-guid-here"))
{
var results = await client.SearchABNAsync("50616294781");
// Process results...
}
using (var client = new AustralianBusinessRegisterClient())
{
var results = await client.SearchACNAsync("010249966");
Console.WriteLine($"ACN: {results.Response.BusinessEntity.ASICNumber}");
Console.WriteLine($"Name: {results.Response.BusinessEntity.MainNames[0].OrganisationName}");
}
using (var client = new AustralianBusinessRegisterClient())
{
// Basic name search
var results = await client.SearchNameAsync("Commonwealth Bank");
// Advanced name search with options
var options = new NameSearchOptions
{
Postcode = "2000",
LegalName = true,
TradingName = true,
BusinessName = true,
ActiveABNsOnly = true,
NewSouthWales = true,
SearchWidth = NameSearchOptions.SearchWidths.Typical,
MinimumScore = 50,
MaximumSearchResults = 100
};
var results = await client.SearchNameAsync("Commonwealth Bank", options);
foreach (var entity in results.Response.BusinessEntity)
{
Console.WriteLine($"ABN: {entity.ABN.IdentifierValue}");
Console.WriteLine($"Name: {entity.MainNames[0].OrganisationName}");
}
}
// Include historical details (default: true)
var results = await client.SearchABNAsync("50616294781", includeHistoricalDetails: true);
// Exclude historical details
var results = await client.SearchABNAsync("50616294781", includeHistoricalDetails: false);
using (var client = new AustralianBusinessRegisterClient())
{
// Download as streams
await foreach (Stream zipStream in client.DownloadABNBulkExtractsAsync())
{
// Process each ZIP archive stream
}
// Save ZIP archives to disk
await client.SaveABNBulkExtractsAsync("C:\\ABN\\Downloads");
}
using (var client = new AustralianBusinessRegisterClient())
{
// Download and extract files as streams
await foreach (Stream fileStream in client.DownloadABNBulkExtractFilesAsync())
{
// Process each extracted XML file stream
}
// Save extracted files to disk
await client.SaveABNBulkExtractFilesAsync("C:\\ABN\\Extracts");
}
using (var client = new AustralianBusinessRegisterClient())
{
// Parse a ZIP archive
using (FileStream zipStream = File.OpenRead("abn-bulk-extract.zip"))
{
foreach (Transfer transfer in client.ParseABNBulkExtractArchive(zipStream))
{
// Process transfer data
foreach (var abn in transfer.ABR)
{
Console.WriteLine($"ABN: {abn.ABN}");
}
}
}
// Parse an individual XML file
using (FileStream xmlStream = File.OpenRead("abn-extract.xml"))
{
Transfer transfer = client.ParseABNBulkExtractFile(xmlStream);
// Process transfer data
}
}
using Universal.Common.Net.Http;
try
{
var results = await client.SearchABNAsync("50616294781");
}
catch (HttpException<ABRPayloadSearchResults.ExceptionSection> ex)
{
Console.WriteLine($"Error: {ex.Content.ExceptionDescription}");
}