default

Functions

f
formatAddress(
parts: AddressParts,
options?: FormatAddressOptions
): string

Assembles a single address string from its parts — the inverse of splitAddress.

f
getByGeocode(code: string): Promise<AddressEntry | null>

Looks up a single unit by its exact geocode. The length of code selects the level: GEOCODE_LENGTH.PROVINCE, .DISTRICT or .SUB_DISTRICT. Returns null for an unknown code or an unrecognised length.

f
getDatabase(): IExpanded[]

Every decoded sub-district row of the active dataset.

f
getDistrictByProvince(province: string): Promise<string[]>

District names within province (empty array if it is unknown).

f
getEngMode(): boolean

Whether the active dataset is the English one.

f
getGeoMode(): boolean

Whether the geocode overlay is currently attached.

f
getPostalCodeBySubDistrict(subDistrict: string): Promise<string[]>

Postal codes used by subDistrict (empty array if it is unknown).

f
getProvinces(): Promise<AddressEntry[]>

Every province, in both languages, with its 2-digit code.

f
getSubDistrictByDistrict(district: string): Promise<string[]>

Sub-district names within district (empty array if it is unknown).

f
getSubDistricts(district: string): Promise<AddressEntry[]>

Sub-districts of one district, each with its postal code.

f
preload(options?: PreloadOptions): Promise<void>

Fetches the data chunks ahead of time so the first real lookup does not have to wait on the network. Purely a warm-up: it never changes the active language or geo mode.

f
searchAddressByDistrict(
query: string,
limit?: number
): Promise<IExpanded[]>

Rows whose district contains query (case-insensitive substring).

f
searchAddressByPostalCode(
query: string | number,
limit?: number
): Promise<IExpanded[]>

Rows whose postal code contains query (accepts a number).

f
searchAddressByProvince(
query: string,
limit?: number
): Promise<IExpanded[]>

Rows whose province contains query (case-insensitive substring).

f
searchAddressBySubDistrict(
query: string,
limit?: number
): Promise<IExpanded[]>

Rows whose sub-district contains query (case-insensitive substring).

f
setEngMode(enabled: boolean): Promise<void>

Switches the active dataset between English and Thai.

f
setGeoMode(enabled: boolean): Promise<void>

Attaches or detaches the geocode overlay. While on, every row also carries province_code / district_code / sub_district_code.

f
splitAddress(fullAddress: string): Promise<IExpanded | null>

Splits a free-text address into { province, district, sub_district, postal_code, address }, or null when it cannot be resolved confidently.

f
translateWord(text: string): Promise<string>

Translates a single place name between Thai and English, returning the input unchanged when it has no counterpart.

f
validateAddress(
input: AddressInput,
options?: ValidateAddressOptions
): Promise<AddressValidationResult>

Checks that the parts of an address exist and belong together — a valid province, a district that sits in it, a sub-district that sits in the district, and a postal code that serves that sub-district.

Interfaces

I
AddressEntry

One administrative unit, with its name in both languages and its official geocode. Unlike IExpanded (kept in the historical snake_case), this newer structured API uses camelCase.

I
AddressParts

The pieces of an address that formatAddress assembles.

I
AddressValidationResult

Outcome of validateAddress.

I
FormatAddressOptions

Options for formatAddress.

  • language: Language

    Language of the component-introducing words ("ตำบล" vs "Tambon"). Defaults to Thai. Only affects output when prefix is true.

  • prefix: boolean

    Prefix each component with its administrative word (ตำบล / อำเภอ / …, or แขวง / เขต for Bangkok). Defaults to true.

  • separator: string

    String placed between components. Defaults to a single space.

I
IExpanded
I
PreloadOptions

Options for preload.

I
ValidateAddressOptions

Options for validateAddress.

Type Aliases

T
AddressField = keyof AddressInput

Fields validateAddress can report an error against.

T
ILanguage = Language

Language of a loaded dataset. Alias of Language, kept for the public API.