> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prontiq.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeScript SDK

> Type-safe client for the Prontiq API, auto-generated from the OpenAPI spec.

## Installation

<CodeGroup>
  ```bash npm theme={null}
  npm add @prontiq/sdk
  ```

  ```bash pnpm theme={null}
  pnpm add @prontiq/sdk
  ```

  ```bash bun theme={null}
  bun add @prontiq/sdk
  ```
</CodeGroup>

<Note>The SDK is ESM-only. For CommonJS, use `await import("@prontiq/sdk")`.</Note>

## Setup

```typescript theme={null}
import { Prontiq } from "@prontiq/sdk";

const prontiq = new Prontiq({
  serverURL: "https://api.prontiq.dev",
  apiKeyAuth: process.env.PRONTIQ_API_KEY!,
});
```

## Autocomplete

```typescript theme={null}
const autocompleteResponse = await prontiq.address.autocompleteAddress(
  "8 noble way", // q
  "WA", // state (optional)
  5, // limit (optional)
);
const { suggestions, total } = autocompleteResponse.result;
// For Autocomplete, total is the number of suggestions returned.

for (const s of suggestions) {
  console.log(`${s.addressLabel} ${s.localityName} ${s.state} ${s.postcode}`);
}
```

## Validate

```typescript theme={null}
const validateResponse = await prontiq.address.validateAddress("8 noble way success wa 6164");
const { match, prontiqMatchScore, prontiqMatchQuality } = validateResponse.result;

if (prontiqMatchQuality === "high") {
  console.log(`Verified (${prontiqMatchScore}/100): ${match?.addressLabel}`);
}
```

## Enrich

```typescript theme={null}
const enrichResponse = await prontiq.address.enrichAddress("GAWA_147231326");
const address = enrichResponse.result;

console.log(address.geocode); // { latitude, longitude, type, reliability }
console.log(address.boundaries); // { lga, stateElectorate, meshBlock, sa2, ... }
console.log(address.components?.streetNumberFirst);
console.log(address.boundaries?.sa1);
console.log(address.aliases ?? []);
```

## Reverse geocode

```typescript theme={null}
const reverseResponse = await prontiq.address.reverseGeocodeAddress({
  lat: -33.8568,
  lon: 151.2153,
  radius: 200,
  limit: 3,
});
const { results } = reverseResponse.result;

for (const r of results) {
  console.log(`${r.addressLabel} — ${r.distanceM}m away`);
}
```

## Lookups

```typescript theme={null}
// Postcode → localities
const postcodeResponse = await prontiq.address.lookupPostcode("2000");
const { localities } = postcodeResponse.result;

// Suburb → postcodes
const suburbResponse = await prontiq.address.lookupSuburb("bondi beach", "NSW");
const { postcodes, addressCount } = suburbResponse.result;
```

## All methods

| Method                                                                         | Description                      |
| ------------------------------------------------------------------------------ | -------------------------------- |
| `prontiq.address.autocompleteAddress(q, state?, limit?, debug?)`               | Real-time typeahead suggestions  |
| `prontiq.address.validateAddress(q, debug?)`                                   | Verify a full address string     |
| `prontiq.address.enrichAddress(id, debug?)`                                    | Full record by G-NAF ID          |
| `prontiq.address.reverseGeocodeAddress({ lat, lon, radius?, limit?, debug? })` | Coordinates to nearest addresses |
| `prontiq.address.lookupPostcode(postcode, limit?, debug?)`                     | Postcode to localities           |
| `prontiq.address.lookupSuburb(suburb, state?, limit?, debug?)`                 | Suburb to postcodes              |

## Error handling

```typescript theme={null}
import { SDKValidationError } from "@prontiq/sdk/models/errors";

try {
  const result = await prontiq.address.autocompleteAddress("test");
} catch (err) {
  if (err instanceof SDKValidationError) {
    console.error("Validation:", err.message);
  }
  throw err;
}
```

<Info>
  The SDK is auto-generated from the public [OpenAPI spec](/api-reference/autocomplete) by
  [Speakeasy](https://www.speakeasy.com). It stays in sync with public data API changes
  automatically.
</Info>
