Assembles a single address string from its parts — the inverse of
splitAddress.
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.
Every decoded sub-district row of the active dataset.
District names within province (empty array if it is unknown).
Districts of one province.
Whether the active dataset is the English one.
Whether the geocode overlay is currently attached.
Postal codes used by subDistrict (empty array if it is unknown).
All province names.
Every province, in both languages, with its 2-digit code.
Sub-district names within district (empty array if it is unknown).
Sub-districts of one district, each with its postal code.
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.
Rows whose district contains query (case-insensitive substring).
Rows whose postal code contains query (accepts a number).
Rows whose province contains query (case-insensitive substring).
Rows whose sub-district contains query (case-insensitive substring).
Switches the active dataset between English and Thai.
Attaches or detaches the geocode overlay. While on, every row also carries
province_code / district_code / sub_district_code.
Splits a free-text address into { province, district, sub_district, postal_code, address }, or null when it cannot be resolved confidently.
Translates a single place name between Thai and English, returning the input unchanged when it has no counterpart.
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.
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.
-
code: string
Standard geocode: 2 digits for a province, 4 for a district, 6 for a sub-district.
-
nameEn: string
Romanised name.
-
nameTh: string
Thai name.
-
postalCode: string
Postal code — present on sub-district entries only.
The address a caller wants checked. Every field is optional.
The pieces of an address that formatAddress assembles.
-
address: string
House number / street / village — printed first, verbatim.
-
district: string
อำเภอ / เขต.
-
postalCode: string | number
5-digit postal code — printed last.
-
province: string
จังหวัด.
-
subDistrict: string
ตำบล / แขวง.
Outcome of validateAddress.
-
errors: Partial<Record<AddressField, string>>
A message per field that broke the chain (usually zero or one entry).
-
match: IExpanded
The dataset row that satisfies every provided field, when
valid. -
valid: boolean
truewhen every provided field is mutually consistent.
Options for formatAddress.
-
language: Language
Language of the component-introducing words ("ตำบล" vs "Tambon"). Defaults to Thai. Only affects output when
prefixistrue. -
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.
-
address: string
Only populated on the object returned by
splitAddress— the leftover part of the input string after the matched province / district / sub-district (and the postal code) have been stripped out. - district: string
- district_code: string
- postal_code: string
- province: string
- province_code: string
- sub_district: string
- sub_district_code: string
Options for preload.
-
geo: boolean
Also fetch the geocode chunk (without turning geo mode on).
-
language: Language | "both"
Which dataset(s) to fetch:
'thai','eng', or'both'. Defaults to the host's default language.
Options for validateAddress.
-
language: Language
Dataset language the names are in. Defaults to Thai.
Fields validateAddress can report an error against.
Language of a loaded dataset. Alias of Language, kept for the public API.