# loqate-core-sdk

<div align="left">
    <a href="https://www.speakeasy.com/?utm_source=loqate-core-sdk&utm_campaign=typescript"><img src="https://www.speakeasy.com/assets/badges/built-by-speakeasy.svg" /></a>
    <a href="https://opensource.org/licenses/MIT">
        <img src="https://img.shields.io/badge/License-MIT-blue.svg" style="width: 100px; height: 28px;" />
    </a>
</div>

<!-- Start Summary [summary] -->
## Summary

Loqate SDK: The Loqate TypeScript SDK provides modern, strongly-typed clients and utilities for seamless address capture, verification, and cleansing.
<!-- End Summary [summary] -->

<!-- Start Table of Contents [toc] -->
## Table of Contents
<!-- $toc-max-depth=2 -->
* [loqate-core-sdk](#loqate-core-sdk)
  * [SDK Installation](#sdk-installation)
  * [Requirements](#requirements)
  * [SDK Example Usage](#sdk-example-usage)
  * [Authentication](#authentication)
  * [Available Resources and Operations](#available-resources-and-operations)
  * [Standalone functions](#standalone-functions)
  * [Global Parameters](#global-parameters)
  * [Retries](#retries)
  * [Error Handling](#error-handling)
  * [Server Selection](#server-selection)
  * [Custom HTTP Client](#custom-http-client)
  * [Debugging](#debugging)
* [Development](#development)
  * [Maturity](#maturity)
  * [Contributions](#contributions)

<!-- End Table of Contents [toc] -->

<!-- Start SDK Installation [installation] -->
## SDK Installation

The SDK can be installed with either [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/), [bun](https://bun.sh/) or [yarn](https://classic.yarnpkg.com/en/) package managers.

### NPM

```bash
npm add @loqate/core
```

### PNPM

```bash
pnpm add @loqate/core
```

### Bun

```bash
bun add @loqate/core
```

### Yarn

```bash
yarn add @loqate/core
```

> [!NOTE]
> This package is published with CommonJS and ES Modules (ESM) support.
<!-- End SDK Installation [installation] -->

<!-- Start Requirements [requirements] -->
## Requirements

For supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).
<!-- End Requirements [requirements] -->

<!-- Start SDK Example Usage [usage] -->
## SDK Example Usage

### Example

```typescript
import { Loqate } from "@loqate/core";

const loqate = new Loqate({
  source: "loqate-core-sdk-typescript",
  apiKey: process.env["LOQATE_API_KEY"] ?? "",
});

async function run() {
  const result = await loqate.capture.find({
    key: "AA11-AA11-AA11-AA11",
    text: "wr5 3da",
    container: "GB|RM|ENG|3DA-WR5",
    origin: "52.182,-2.222",
    countries: "GB,US,CA",
    limit: 10,
    language: "10",
    bias: false,
    filters: "",
    geoFence: "",
  });

  console.log(result);
}

run();

```
<!-- End SDK Example Usage [usage] -->

<!-- Start Authentication [security] -->
## Authentication

### Per-Client Security Schemes

This SDK supports the following security scheme globally:

| Name     | Type   | Scheme  | Environment Variable |
| -------- | ------ | ------- | -------------------- |
| `apiKey` | apiKey | API key | `LOQATE_API_KEY`     |

To authenticate with the API the `apiKey` parameter must be set when initializing the SDK client instance. For example:
```typescript
import { Loqate } from "@loqate/core";

const loqate = new Loqate({
  apiKey: process.env["LOQATE_API_KEY"] ?? "",
  source: "loqate-core-sdk-typescript",
});

async function run() {
  const result = await loqate.capture.find({
    key: "AA11-AA11-AA11-AA11",
    text: "wr5 3da",
    container: "GB|RM|ENG|3DA-WR5",
    origin: "52.182,-2.222",
    countries: "GB,US,CA",
    limit: 10,
    language: "10",
    bias: false,
    filters: "",
    geoFence: "",
  });

  console.log(result);
}

run();

```
<!-- End Authentication [security] -->

<!-- Start Available Resources and Operations [operations] -->
## Available Resources and Operations

<details open>
<summary>Available methods</summary>

### [BankAccountValidation](docs/sdks/bankaccountvalidation/README.md)

* [batchValidate](docs/sdks/bankaccountvalidation/README.md#batchvalidate) - BankAccountValidation_Batch_Validate
* [validate](docs/sdks/bankaccountvalidation/README.md#validate) - BankAccountValidation_Interactive_Validate
* [retrieveBySortcode](docs/sdks/bankaccountvalidation/README.md#retrievebysortcode) - BankAccountValidation_Interactive_RetrieveBySortcode

### [BankValidation](docs/sdks/bankvalidation/README.md)

* [validate](docs/sdks/bankvalidation/README.md#validate) - InternationalBankValidation_Interactive_Validate

### [Capture](docs/sdks/capture/README.md)

* [find](docs/sdks/capture/README.md#find) - Capture_Interactive_Find
* [retrieve](docs/sdks/capture/README.md#retrieve) - Capture_Interactive_Retrieve
* [geoLocation](docs/sdks/capture/README.md#geolocation) - Capture_Interactive_GeoLocation

### [Cleansing](docs/sdks/cleansing/README.md)

* [batch](docs/sdks/cleansing/README.md#batch) - Cleansing_International_Batch

### [Directions](docs/sdks/directions/README.md)

* [get](docs/sdks/directions/README.md#get) - DistancesAndDirections_Interactive_Directions

### [Distances](docs/sdks/distances/README.md)

* [get](docs/sdks/distances/README.md#get) - DistancesAndDirections_Interactive_Distance

### [EmailValidation](docs/sdks/emailvalidation/README.md)

* [validateBatch](docs/sdks/emailvalidation/README.md#validatebatch) - EmailValidation_Batch_Validate
* [validate](docs/sdks/emailvalidation/README.md#validate) - EmailValidation_Interactive_Validate

### [Geocoding](docs/sdks/geocoding/README.md)

* [geocode](docs/sdks/geocoding/README.md#geocode) - Geocoding_International_Geocode
* [positionToCountry](docs/sdks/geocoding/README.md#positiontocountry) - Geocoding_International_PositionToCountry
* [retrieveNearestPlaces](docs/sdks/geocoding/README.md#retrievenearestplaces) - Geocoding_International_RetrieveNearestPlaces
* [reverseGeocode](docs/sdks/geocoding/README.md#reversegeocode) - Geocoding_International_ReverseGeocode
* [ip2Country](docs/sdks/geocoding/README.md#ip2country) - Extras_Web_Ip2Country

### [GeocodingUK](docs/sdks/geocodinguk/README.md)

* [find](docs/sdks/geocodinguk/README.md#find) - Geocoding_UK_Find
* [geocode](docs/sdks/geocodinguk/README.md#geocode) - Geocoding_UK_Geocode
* [retrieve](docs/sdks/geocodinguk/README.md#retrieve) - Geocoding_UK_Retrieve
* [retrieveNearestPlaces](docs/sdks/geocodinguk/README.md#retrievenearestplaces) - Geocoding_UK_RetrieveNearestPlaces
* [reverseGeocode](docs/sdks/geocodinguk/README.md#reversegeocode) - Geocoding_UK_ReverseGeocode

### [GovernmentData](docs/sdks/governmentdata/README.md)

* [retrieveByCoordinatesPostzon](docs/sdks/governmentdata/README.md#retrievebycoordinatespostzon) - GovernmentData_Postzon_RetrieveByCoordinates
* [retrievePostzonsByCode](docs/sdks/governmentdata/README.md#retrievepostzonsbycode) - GovernmentData_Postzon_RetrieveByPostcode
* [retrievePostzonsByCodeOrPlace](docs/sdks/governmentdata/README.md#retrievepostzonsbycodeorplace) - GovernmentData_Postzon_RetrieveByPostcodeOrPlace

### [PhoneNumberValidation](docs/sdks/phonenumbervalidation/README.md)

* [validate](docs/sdks/phonenumbervalidation/README.md#validate) - PhoneNumberValidation_Interactive_Validate

### [StoreFinder](docs/sdks/storefinder/README.md)

* [geocodeGlobalTypeAhead](docs/sdks/storefinder/README.md#geocodeglobaltypeahead) - LocationServices_Geocoding_GlobalTypeAhead
* [geocodingGlobal](docs/sdks/storefinder/README.md#geocodingglobal) - LocationServices_Geocoding_Global
* [findNearbyDistance](docs/sdks/storefinder/README.md#findnearbydistance) - LocationServices_DistanceFinder_Nearby
* [getMappingUrl](docs/sdks/storefinder/README.md#getmappingurl) - LocationServices_Mapping_GetUrl
* [findPlaceNames](docs/sdks/storefinder/README.md#findplacenames) - StoreFinder_Interactive_FindPlaceNames
* [retrieveCoordinates](docs/sdks/storefinder/README.md#retrievecoordinates) - StoreFinder_Interactive_RetrieveCoordinates

#### [StoreFinder.LocationManagement](docs/sdks/locationmanagement/README.md)

* [createList](docs/sdks/locationmanagement/README.md#createlist) - LocationServices_LocationManagement_CreateList
* [deleteLocationOrPoint](docs/sdks/locationmanagement/README.md#deletelocationorpoint) - LocationServices_LocationManagement_DeleteListOrPoint
* [updateListOrPoint](docs/sdks/locationmanagement/README.md#updatelistorpoint) - LocationServices_LocationManagement_UpdateListOrPoint
* [getLists](docs/sdks/locationmanagement/README.md#getlists) - LocationServices_LocationManagement_GetLists

</details>
<!-- End Available Resources and Operations [operations] -->

<!-- Start Standalone functions [standalone-funcs] -->
## Standalone functions

All the methods listed above are available as standalone functions. These
functions are ideal for use in applications running in the browser, serverless
runtimes or other environments where application bundle size is a primary
concern. When using a bundler to build your application, all unused
functionality will be either excluded from the final bundle or tree-shaken away.

To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md).

<details>

<summary>Available standalone functions</summary>

- [`bankAccountValidationBatchValidate`](docs/sdks/bankaccountvalidation/README.md#batchvalidate) - BankAccountValidation_Batch_Validate
- [`bankAccountValidationRetrieveBySortcode`](docs/sdks/bankaccountvalidation/README.md#retrievebysortcode) - BankAccountValidation_Interactive_RetrieveBySortcode
- [`bankAccountValidationValidate`](docs/sdks/bankaccountvalidation/README.md#validate) - BankAccountValidation_Interactive_Validate
- [`bankValidationValidate`](docs/sdks/bankvalidation/README.md#validate) - InternationalBankValidation_Interactive_Validate
- [`captureFind`](docs/sdks/capture/README.md#find) - Capture_Interactive_Find
- [`captureGeoLocation`](docs/sdks/capture/README.md#geolocation) - Capture_Interactive_GeoLocation
- [`captureRetrieve`](docs/sdks/capture/README.md#retrieve) - Capture_Interactive_Retrieve
- [`cleansingBatch`](docs/sdks/cleansing/README.md#batch) - Cleansing_International_Batch
- [`directionsGet`](docs/sdks/directions/README.md#get) - DistancesAndDirections_Interactive_Directions
- [`distancesGet`](docs/sdks/distances/README.md#get) - DistancesAndDirections_Interactive_Distance
- [`emailValidationValidate`](docs/sdks/emailvalidation/README.md#validate) - EmailValidation_Interactive_Validate
- [`emailValidationValidateBatch`](docs/sdks/emailvalidation/README.md#validatebatch) - EmailValidation_Batch_Validate
- [`geocodingGeocode`](docs/sdks/geocoding/README.md#geocode) - Geocoding_International_Geocode
- [`geocodingIp2Country`](docs/sdks/geocoding/README.md#ip2country) - Extras_Web_Ip2Country
- [`geocodingPositionToCountry`](docs/sdks/geocoding/README.md#positiontocountry) - Geocoding_International_PositionToCountry
- [`geocodingRetrieveNearestPlaces`](docs/sdks/geocoding/README.md#retrievenearestplaces) - Geocoding_International_RetrieveNearestPlaces
- [`geocodingReverseGeocode`](docs/sdks/geocoding/README.md#reversegeocode) - Geocoding_International_ReverseGeocode
- [`geocodingUKFind`](docs/sdks/geocodinguk/README.md#find) - Geocoding_UK_Find
- [`geocodingUKGeocode`](docs/sdks/geocodinguk/README.md#geocode) - Geocoding_UK_Geocode
- [`geocodingUKRetrieve`](docs/sdks/geocodinguk/README.md#retrieve) - Geocoding_UK_Retrieve
- [`geocodingUKRetrieveNearestPlaces`](docs/sdks/geocodinguk/README.md#retrievenearestplaces) - Geocoding_UK_RetrieveNearestPlaces
- [`geocodingUKReverseGeocode`](docs/sdks/geocodinguk/README.md#reversegeocode) - Geocoding_UK_ReverseGeocode
- [`governmentDataRetrieveByCoordinatesPostzon`](docs/sdks/governmentdata/README.md#retrievebycoordinatespostzon) - GovernmentData_Postzon_RetrieveByCoordinates
- [`governmentDataRetrievePostzonsByCode`](docs/sdks/governmentdata/README.md#retrievepostzonsbycode) - GovernmentData_Postzon_RetrieveByPostcode
- [`governmentDataRetrievePostzonsByCodeOrPlace`](docs/sdks/governmentdata/README.md#retrievepostzonsbycodeorplace) - GovernmentData_Postzon_RetrieveByPostcodeOrPlace
- [`phoneNumberValidationValidate`](docs/sdks/phonenumbervalidation/README.md#validate) - PhoneNumberValidation_Interactive_Validate
- [`storeFinderFindNearbyDistance`](docs/sdks/storefinder/README.md#findnearbydistance) - LocationServices_DistanceFinder_Nearby
- [`storeFinderFindPlaceNames`](docs/sdks/storefinder/README.md#findplacenames) - StoreFinder_Interactive_FindPlaceNames
- [`storeFinderGeocodeGlobalTypeAhead`](docs/sdks/storefinder/README.md#geocodeglobaltypeahead) - LocationServices_Geocoding_GlobalTypeAhead
- [`storeFinderGeocodingGlobal`](docs/sdks/storefinder/README.md#geocodingglobal) - LocationServices_Geocoding_Global
- [`storeFinderGetMappingUrl`](docs/sdks/storefinder/README.md#getmappingurl) - LocationServices_Mapping_GetUrl
- [`storeFinderLocationManagementCreateList`](docs/sdks/locationmanagement/README.md#createlist) - LocationServices_LocationManagement_CreateList
- [`storeFinderLocationManagementDeleteLocationOrPoint`](docs/sdks/locationmanagement/README.md#deletelocationorpoint) - LocationServices_LocationManagement_DeleteListOrPoint
- [`storeFinderLocationManagementGetLists`](docs/sdks/locationmanagement/README.md#getlists) - LocationServices_LocationManagement_GetLists
- [`storeFinderLocationManagementUpdateListOrPoint`](docs/sdks/locationmanagement/README.md#updatelistorpoint) - LocationServices_LocationManagement_UpdateListOrPoint
- [`storeFinderRetrieveCoordinates`](docs/sdks/storefinder/README.md#retrievecoordinates) - StoreFinder_Interactive_RetrieveCoordinates

</details>
<!-- End Standalone functions [standalone-funcs] -->

<!-- Start Global Parameters [global-parameters] -->
## Global Parameters

A parameter is configured globally. This parameter may be set on the SDK client instance itself during initialization. When configured as an option during SDK initialization, This global value will be used as the default on the operations that use it. When such operations are called, there is a place in each to override the global value, if needed.

For example, you can set `SOURCE` to `"loqate-core-sdk-typescript"` at SDK initialization and then you do not have to pass the same value on calls to operations like `find`. But if you want to do so you may, which will locally override the global setting. See the example code below for a demonstration.


### Available Globals

The following global parameter is available.
Global parameters can also be set via environment variable.

| Name   | Type   | Description           | Environment   |
| ------ | ------ | --------------------- | ------------- |
| source | string | The source parameter. | LOQATE_SOURCE |

### Example

```typescript
import { Loqate } from "@loqate/core";

const loqate = new Loqate({
  source: "loqate-core-sdk-typescript",
  apiKey: process.env["LOQATE_API_KEY"] ?? "",
});

async function run() {
  const result = await loqate.capture.find({
    key: "AA11-AA11-AA11-AA11",
    text: "wr5 3da",
    container: "GB|RM|ENG|3DA-WR5",
    origin: "52.182,-2.222",
    countries: "GB,US,CA",
    limit: 10,
    language: "10",
    bias: false,
    filters: "",
    geoFence: "",
  });

  console.log(result);
}

run();

```
<!-- End Global Parameters [global-parameters] -->

<!-- Start Retries [retries] -->
## Retries

Some of the endpoints in this SDK support retries.  If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API.  However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.

To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
```typescript
import { Loqate } from "@loqate/core";

const loqate = new Loqate({
  source: "loqate-core-sdk-typescript",
  apiKey: process.env["LOQATE_API_KEY"] ?? "",
});

async function run() {
  const result = await loqate.capture.find({
    key: "AA11-AA11-AA11-AA11",
    text: "wr5 3da",
    container: "GB|RM|ENG|3DA-WR5",
    origin: "52.182,-2.222",
    countries: "GB,US,CA",
    limit: 10,
    language: "10",
    bias: false,
    filters: "",
    geoFence: "",
  }, {
    retries: {
      strategy: "backoff",
      backoff: {
        initialInterval: 1,
        maxInterval: 50,
        exponent: 1.1,
        maxElapsedTime: 100,
      },
      retryConnectionErrors: false,
    },
  });

  console.log(result);
}

run();

```

If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
```typescript
import { Loqate } from "@loqate/core";

const loqate = new Loqate({
  retryConfig: {
    strategy: "backoff",
    backoff: {
      initialInterval: 1,
      maxInterval: 50,
      exponent: 1.1,
      maxElapsedTime: 100,
    },
    retryConnectionErrors: false,
  },
  source: "loqate-core-sdk-typescript",
  apiKey: process.env["LOQATE_API_KEY"] ?? "",
});

async function run() {
  const result = await loqate.capture.find({
    key: "AA11-AA11-AA11-AA11",
    text: "wr5 3da",
    container: "GB|RM|ENG|3DA-WR5",
    origin: "52.182,-2.222",
    countries: "GB,US,CA",
    limit: 10,
    language: "10",
    bias: false,
    filters: "",
    geoFence: "",
  });

  console.log(result);
}

run();

```
<!-- End Retries [retries] -->

<!-- Start Error Handling [errors] -->
## Error Handling

[`LoqateError`](./src/models/errors/loqateerror.ts) is the base class for all HTTP error responses. It has the following properties:

| Property            | Type       | Description                                                                             |
| ------------------- | ---------- | --------------------------------------------------------------------------------------- |
| `error.message`     | `string`   | Error message                                                                           |
| `error.statusCode`  | `number`   | HTTP response status code eg `404`                                                      |
| `error.headers`     | `Headers`  | HTTP response headers                                                                   |
| `error.body`        | `string`   | HTTP body. Can be empty string if no body is returned.                                  |
| `error.rawResponse` | `Response` | Raw HTTP response                                                                       |
| `error.data$`       |            | Optional. Some errors may contain structured data. [See Error Classes](#error-classes). |

### Example
```typescript
import { Loqate } from "@loqate/core";
import * as errors from "@loqate/core/models/errors";

const loqate = new Loqate({
  source: "loqate-core-sdk-typescript",
  apiKey: process.env["LOQATE_API_KEY"] ?? "",
});

async function run() {
  try {
    const result = await loqate.capture.find({
      key: "AA11-AA11-AA11-AA11",
      text: "wr5 3da",
      container: "GB|RM|ENG|3DA-WR5",
      origin: "52.182,-2.222",
      countries: "GB,US,CA",
      limit: 10,
      language: "10",
      bias: false,
      filters: "",
      geoFence: "",
    });

    console.log(result);
  } catch (error) {
    // The base class for HTTP error responses
    if (error instanceof errors.LoqateError) {
      console.log(error.message);
      console.log(error.statusCode);
      console.log(error.body);
      console.log(error.headers);

      // Depending on the method different errors may be thrown
      if (error instanceof errors.CaptureInteractiveFindError) {
        console.log(error.data$.items); // CaptureInteractiveFindErrorItem[]
      }
    }
  }
}

run();

```

### Error Classes
**Primary error:**
* [`LoqateError`](./src/models/errors/loqateerror.ts): The base class for HTTP error responses.

<details><summary>Less common errors (70)</summary>

<br />

**Network errors:**
* [`ConnectionError`](./src/models/errors/httpclienterrors.ts): HTTP client was unable to make a request to a server.
* [`RequestTimeoutError`](./src/models/errors/httpclienterrors.ts): HTTP request timed out due to an AbortSignal signal.
* [`RequestAbortedError`](./src/models/errors/httpclienterrors.ts): HTTP request was aborted by the client.
* [`InvalidRequestError`](./src/models/errors/httpclienterrors.ts): Any input used to create a request is invalid.
* [`UnexpectedClientError`](./src/models/errors/httpclienterrors.ts): Unrecognised or unexpected error.


**Inherit from [`LoqateError`](./src/models/errors/loqateerror.ts)**:
* [`CleansingInternationalBatchBadRequestErrorResponseSelfContained`](./src/models/errors/cleansinginternationalbatchbadrequesterrorresponseselfcontained.ts): BadRequest. Status code `400`. Applicable to 1 of 36 methods.*
* [`LocationServicesGeocodingGlobalTypeAheadBadRequestErrorResponseSelfContained`](./src/models/errors/locationservicesgeocodingglobaltypeaheadbadrequesterrorresponseselfcontained.ts): BadRequest. Status code `400`. Applicable to 1 of 36 methods.*
* [`LocationServicesGeocodingGlobalBadRequestErrorResponseSelfContained`](./src/models/errors/locationservicesgeocodingglobalbadrequesterrorresponseselfcontained.ts): BadRequest. Status code `400`. Applicable to 1 of 36 methods.*
* [`LocationServicesDistanceFinderNearbyBadRequestErrorResponseSelfContained`](./src/models/errors/locationservicesdistancefindernearbybadrequesterrorresponseselfcontained.ts): BadRequest. Status code `400`. Applicable to 1 of 36 methods.*
* [`LocationServicesMappingGetUrlBadRequestErrorResponseSelfContained`](./src/models/errors/locationservicesmappinggeturlbadrequesterrorresponseselfcontained.ts): BadRequest. Status code `400`. Applicable to 1 of 36 methods.*
* [`LocationServicesLocationManagementCreateListBadRequestErrorResponseSelfContained`](./src/models/errors/locationserviceslocationmanagementcreatelistbadrequesterrorresponseselfcontained.ts): BadRequest. Status code `400`. Applicable to 1 of 36 methods.*
* [`LocationServicesLocationManagementDeleteListOrPointBadRequestErrorResponseSelfContained`](./src/models/errors/locationserviceslocationmanagementdeletelistorpointbadrequesterrorresponseselfcontained.ts): BadRequest. Status code `400`. Applicable to 1 of 36 methods.*
* [`LocationServicesLocationManagementUpdateListOrPointBadRequestErrorResponseSelfContained`](./src/models/errors/locationserviceslocationmanagementupdatelistorpointbadrequesterrorresponseselfcontained.ts): BadRequest. Status code `400`. Applicable to 1 of 36 methods.*
* [`LocationServicesLocationManagementGetListsBadRequestErrorResponseSelfContained`](./src/models/errors/locationserviceslocationmanagementgetlistsbadrequesterrorresponseselfcontained.ts): BadRequest. Status code `400`. Applicable to 1 of 36 methods.*
* [`CaptureInteractiveFindError`](./src/models/errors/captureinteractivefinderror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`CaptureInteractiveRetrieveError`](./src/models/errors/captureinteractiveretrieveerror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`CaptureInteractiveGeoLocationError`](./src/models/errors/captureinteractivegeolocationerror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`StoreFinderInteractiveFindPlaceNamesError`](./src/models/errors/storefinderinteractivefindplacenameserror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`StoreFinderInteractiveRetrieveCoordinatesError`](./src/models/errors/storefinderinteractiveretrievecoordinateserror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`EmailValidationBatchValidateError`](./src/models/errors/emailvalidationbatchvalidateerror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`EmailValidationInteractiveValidateError`](./src/models/errors/emailvalidationinteractivevalidateerror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`PhoneNumberValidationInteractiveValidateError`](./src/models/errors/phonenumbervalidationinteractivevalidateerror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`BankAccountValidationBatchValidateError`](./src/models/errors/bankaccountvalidationbatchvalidateerror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`BankAccountValidationInteractiveValidateError`](./src/models/errors/bankaccountvalidationinteractivevalidateerror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`BankAccountValidationInteractiveRetrieveBySortcoError`](./src/models/errors/bankaccountvalidationinteractiveretrievebysortcoerror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`InternationalBankValidationInteractiveValidateError`](./src/models/errors/internationalbankvalidationinteractivevalidateerror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`DistancesAndDirectionsInteractiveDirectionsError`](./src/models/errors/distancesanddirectionsinteractivedirectionserror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`DistancesAndDirectionsInteractiveDistanceError`](./src/models/errors/distancesanddirectionsinteractivedistanceerror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`GeocodingInternationalGeocodeError`](./src/models/errors/geocodinginternationalgeocodeerror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`GeocodingInternationalPositionToCountryError`](./src/models/errors/geocodinginternationalpositiontocountryerror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`GeocodingInternationalRetrieveNearestPlacesError`](./src/models/errors/geocodinginternationalretrievenearestplaceserror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`GeocodingInternationalReverseGeocodeError`](./src/models/errors/geocodinginternationalreversegeocodeerror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`ExtrasWebIp2CountryError`](./src/models/errors/extraswebip2countryerror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`GeocodingUKFindError`](./src/models/errors/geocodingukfinderror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`GeocodingUKGeocodeError`](./src/models/errors/geocodingukgeocodeerror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`GeocodingUKRetrieveError`](./src/models/errors/geocodingukretrieveerror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`GeocodingUKRetrieveNearestPlacesError`](./src/models/errors/geocodingukretrievenearestplaceserror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`GeocodingUKReverseGeocodeError`](./src/models/errors/geocodingukreversegeocodeerror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`GovernmentDataPostzonRetrieveByCoordinatesError`](./src/models/errors/governmentdatapostzonretrievebycoordinateserror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`GovernmentDataPostzonRetrieveByPostcodeError`](./src/models/errors/governmentdatapostzonretrievebypostcodeerror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`GovernmentDataPostzonRetrieveByPostcodeOrPlaceError`](./src/models/errors/governmentdatapostzonretrievebypostcodeorplaceerror.ts): BadRequest. Applicable to 1 of 36 methods.*
* [`CleansingInternationalBatchUnauthorizedErrorResponseSelfContained`](./src/models/errors/cleansinginternationalbatchunauthorizederrorresponseselfcontained.ts): Unauthorized. Status code `401`. Applicable to 1 of 36 methods.*
* [`LocationServicesGeocodingGlobalTypeAheadUnauthorizedErrorResponseSelfContained`](./src/models/errors/locationservicesgeocodingglobaltypeaheadunauthorizederrorresponseselfcontained.ts): Unauthorized. Status code `401`. Applicable to 1 of 36 methods.*
* [`LocationServicesGeocodingGlobalUnauthorizedErrorResponseSelfContained`](./src/models/errors/locationservicesgeocodingglobalunauthorizederrorresponseselfcontained.ts): Unauthorized. Status code `401`. Applicable to 1 of 36 methods.*
* [`LocationServicesDistanceFinderNearbyUnauthorizedErrorResponseSelfContained`](./src/models/errors/locationservicesdistancefindernearbyunauthorizederrorresponseselfcontained.ts): Unauthorized. Status code `401`. Applicable to 1 of 36 methods.*
* [`LocationServicesMappingGetUrlUnauthorizedErrorResponseSelfContained`](./src/models/errors/locationservicesmappinggeturlunauthorizederrorresponseselfcontained.ts): Unauthorized. Status code `401`. Applicable to 1 of 36 methods.*
* [`LocationServicesLocationManagementCreateListUnauthorizedErrorResponseSelfContained`](./src/models/errors/locationserviceslocationmanagementcreatelistunauthorizederrorresponseselfcontained.ts): Unauthorized. Status code `401`. Applicable to 1 of 36 methods.*
* [`LocationServicesLocationManagementDeleteListOrPointUnauthorizedErrorResponseSelfContained`](./src/models/errors/locationserviceslocationmanagementdeletelistorpointunauthorizederrorresponseselfcontained.ts): Unauthorized. Status code `401`. Applicable to 1 of 36 methods.*
* [`LocationServicesLocationManagementUpdateListOrPointUnauthorizedErrorResponseSelfContained`](./src/models/errors/locationserviceslocationmanagementupdatelistorpointunauthorizederrorresponseselfcontained.ts): Unauthorized. Status code `401`. Applicable to 1 of 36 methods.*
* [`LocationServicesLocationManagementGetListsUnauthorizedErrorResponseSelfContained`](./src/models/errors/locationserviceslocationmanagementgetlistsunauthorizederrorresponseselfcontained.ts): Unauthorized. Status code `401`. Applicable to 1 of 36 methods.*
* [`CleansingInternationalBatchForbiddenErrorResponseSelfContained`](./src/models/errors/cleansinginternationalbatchforbiddenerrorresponseselfcontained.ts): Forbidden. Status code `403`. Applicable to 1 of 36 methods.*
* [`LocationServicesGeocodingGlobalTypeAheadForbiddenErrorResponseSelfContained`](./src/models/errors/locationservicesgeocodingglobaltypeaheadforbiddenerrorresponseselfcontained.ts): Forbidden. Status code `403`. Applicable to 1 of 36 methods.*
* [`LocationServicesGeocodingGlobalForbiddenErrorResponseSelfContained`](./src/models/errors/locationservicesgeocodingglobalforbiddenerrorresponseselfcontained.ts): Forbidden. Status code `403`. Applicable to 1 of 36 methods.*
* [`LocationServicesDistanceFinderNearbyForbiddenErrorResponseSelfContained`](./src/models/errors/locationservicesdistancefindernearbyforbiddenerrorresponseselfcontained.ts): Forbidden. Status code `403`. Applicable to 1 of 36 methods.*
* [`LocationServicesMappingGetUrlForbiddenErrorResponseSelfContained`](./src/models/errors/locationservicesmappinggeturlforbiddenerrorresponseselfcontained.ts): Forbidden. Status code `403`. Applicable to 1 of 36 methods.*
* [`LocationServicesLocationManagementCreateListForbiddenErrorResponseSelfContained`](./src/models/errors/locationserviceslocationmanagementcreatelistforbiddenerrorresponseselfcontained.ts): Forbidden. Status code `403`. Applicable to 1 of 36 methods.*
* [`LocationServicesLocationManagementDeleteListOrPointForbiddenErrorResponseSelfContained`](./src/models/errors/locationserviceslocationmanagementdeletelistorpointforbiddenerrorresponseselfcontained.ts): Forbidden. Status code `403`. Applicable to 1 of 36 methods.*
* [`LocationServicesLocationManagementUpdateListOrPointForbiddenErrorResponseSelfContained`](./src/models/errors/locationserviceslocationmanagementupdatelistorpointforbiddenerrorresponseselfcontained.ts): Forbidden. Status code `403`. Applicable to 1 of 36 methods.*
* [`LocationServicesLocationManagementGetListsForbiddenErrorResponseSelfContained`](./src/models/errors/locationserviceslocationmanagementgetlistsforbiddenerrorresponseselfcontained.ts): Forbidden. Status code `403`. Applicable to 1 of 36 methods.*
* [`NotFoundErrorResponseSelfContained`](./src/models/errors/notfounderrorresponseselfcontained.ts): NotFound. Status code `404`. Applicable to 1 of 36 methods.*
* [`CleansingInternationalBatchInternalServerErrorErrorResponseSelfContained`](./src/models/errors/cleansinginternationalbatchinternalservererrorerrorresponseselfcontained.ts): InternalServerError. Status code `500`. Applicable to 1 of 36 methods.*
* [`LocationServicesGeocodingGlobalTypeAheadInternalServerErrorErrorResponseSelfContained`](./src/models/errors/locationservicesgeocodingglobaltypeaheadinternalservererrorerrorresponseselfcontained.ts): InternalServerError. Status code `500`. Applicable to 1 of 36 methods.*
* [`LocationServicesGeocodingGlobalInternalServerErrorErrorResponseSelfContained`](./src/models/errors/locationservicesgeocodingglobalinternalservererrorerrorresponseselfcontained.ts): InternalServerError. Status code `500`. Applicable to 1 of 36 methods.*
* [`LocationServicesDistanceFinderNearbyInternalServerErrorErrorResponseSelfContained`](./src/models/errors/locationservicesdistancefindernearbyinternalservererrorerrorresponseselfcontained.ts): InternalServerError. Status code `500`. Applicable to 1 of 36 methods.*
* [`LocationServicesMappingGetUrlInternalServerErrorErrorResponseSelfContained`](./src/models/errors/locationservicesmappinggeturlinternalservererrorerrorresponseselfcontained.ts): InternalServerError. Status code `500`. Applicable to 1 of 36 methods.*
* [`LocationServicesLocationManagementCreateListInternalServerErrorErrorResponseSelfContained`](./src/models/errors/locationserviceslocationmanagementcreatelistinternalservererrorerrorresponseselfcontained.ts): InternalServerError. Status code `500`. Applicable to 1 of 36 methods.*
* [`LocationServicesLocationManagementDeleteListOrPointInternalServerErrorErrorResponseSelfContained`](./src/models/errors/locationserviceslocationmanagementdeletelistorpointinternalservererrorerrorresponseselfcontained.ts): InternalServerError. Status code `500`. Applicable to 1 of 36 methods.*
* [`LocationServicesLocationManagementUpdateListOrPointInternalServerErrorErrorResponseSelfContained`](./src/models/errors/locationserviceslocationmanagementupdatelistorpointinternalservererrorerrorresponseselfcontained.ts): InternalServerError. Status code `500`. Applicable to 1 of 36 methods.*
* [`LocationServicesLocationManagementGetListsInternalServerErrorErrorResponseSelfContained`](./src/models/errors/locationserviceslocationmanagementgetlistsinternalservererrorerrorresponseselfcontained.ts): InternalServerError. Status code `500`. Applicable to 1 of 36 methods.*
* [`ResponseValidationError`](./src/models/errors/responsevalidationerror.ts): Type mismatch between the data returned from the server and the structure expected by the SDK. See `error.rawValue` for the raw value and `error.pretty()` for a nicely formatted multi-line string.

</details>

\* Check [the method documentation](#available-resources-and-operations) to see if the error is applicable.
<!-- End Error Handling [errors] -->

<!-- Start Server Selection [server] -->
## Server Selection

### Override Server URL Per-Client

The default server can be overridden globally by passing a URL to the `serverURL: string` optional parameter when initializing the SDK client instance. For example:
```typescript
import { Loqate } from "@loqate/core";

const loqate = new Loqate({
  serverURL: "https://api.addressy.com",
  source: "loqate-core-sdk-typescript",
  apiKey: process.env["LOQATE_API_KEY"] ?? "",
});

async function run() {
  const result = await loqate.capture.find({
    key: "AA11-AA11-AA11-AA11",
    text: "wr5 3da",
    container: "GB|RM|ENG|3DA-WR5",
    origin: "52.182,-2.222",
    countries: "GB,US,CA",
    limit: 10,
    language: "10",
    bias: false,
    filters: "",
    geoFence: "",
  });

  console.log(result);
}

run();

```
<!-- End Server Selection [server] -->

<!-- Start Custom HTTP Client [http-client] -->
## Custom HTTP Client

The TypeScript SDK makes API calls using an `HTTPClient` that wraps the native
[Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). This
client is a thin wrapper around `fetch` and provides the ability to attach hooks
around the request lifecycle that can be used to modify the request or handle
errors and response.

The `HTTPClient` constructor takes an optional `fetcher` argument that can be
used to integrate a third-party HTTP client or when writing tests to mock out
the HTTP client and feed in fixtures.

The following example shows how to use the `"beforeRequest"` hook to to add a
custom header and a timeout to requests and how to use the `"requestError"` hook
to log errors:

```typescript
import { Loqate } from "@loqate/core";
import { HTTPClient } from "@loqate/core/lib/http";

const httpClient = new HTTPClient({
  // fetcher takes a function that has the same signature as native `fetch`.
  fetcher: (request) => {
    return fetch(request);
  }
});

httpClient.addHook("beforeRequest", (request) => {
  const nextRequest = new Request(request, {
    signal: request.signal || AbortSignal.timeout(5000)
  });

  nextRequest.headers.set("x-custom-header", "custom value");

  return nextRequest;
});

httpClient.addHook("requestError", (error, request) => {
  console.group("Request Error");
  console.log("Reason:", `${error}`);
  console.log("Endpoint:", `${request.method} ${request.url}`);
  console.groupEnd();
});

const sdk = new Loqate({ httpClient: httpClient });
```
<!-- End Custom HTTP Client [http-client] -->

<!-- Start Debugging [debug] -->
## Debugging

You can setup your SDK to emit debug logs for SDK requests and responses.

You can pass a logger that matches `console`'s interface as an SDK option.

> [!WARNING]
> Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production.

```typescript
import { Loqate } from "@loqate/core";

const sdk = new Loqate({ debugLogger: console });
```

You can also enable a default debug logger by setting an environment variable `LOQATE_DEBUG` to true.
<!-- End Debugging [debug] -->

<!-- Placeholder for Future Speakeasy SDK Sections -->

# Development

## Maturity

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage
to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally
looking for the latest version.

## Contributions

While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation.
We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.

### SDK Created by [Speakeasy](https://www.speakeasy.com/?utm_source=loqate-core-sdk&utm_campaign=typescript)
