theeyoo
v1.0.3
Published
A package for auto-filling addresses in Thailand based on postal codes.
Maintainers
Readme
Theeyoo – Thai Address Autocomplete
A comprehensive npm package for auto-completing Thai addresses based on postal codes. This package provides easy access to Thailand's complete address database including provinces, districts, and subdistricts with both English and Thai names. Data from @thailand-geography-data. See Github repo
Features
- 🏛️ Complete Database: 77 provinces, thousands of districts and subdistricts
- 🌐 Bilingual Support: Both English and Thai names
- 📮 Postal Code Lookup: Find all addresses for any postal code
- 🔍 Search Functionality: Search by location names
- 🏗️ Hierarchical Data: Province → District → Subdistrict structure
Installation
npm install theeyooAPI Reference
Functions
autocompleteAddress(postalCode: string): PostalCodeResponse
- postalCode: A string representing the 5-digit postal code to search for
- Returns: A
PostalCodeResponseobject containing an array of matching addresses
Classes
AddressService
A service class for advanced address operations and queries.
Methods:
getAddressesByPostalCode(postalCode: string): Address[]: Returns addresses for a postal codegetProvinces(): ProvinceData[]: Returns all provincesgetDistrictsByProvince(provinceCode: number): DistrictData[]: Returns districts in a provincegetSubdistrictsByDistrict(provinceCode: number, districtCode: number): SubdistrictData[]: Returns subdistricts in a districtsearchByName(searchTerm: string, language: 'en' | 'th'): Address[]: Search addresses by name
Interfaces
Address
interface Address {
district: string; // District name in English
districtTh: string; // District name in Thai
province: string; // Province name in English
provinceTh: string; // Province name in Thai
subdistrict: string; // Subdistrict name in English
subdistrictTh: string; // Subdistrict name in Thai
postalCode: string; // 5-digit postal code
provinceCode: number; // Numeric province code
districtCode: number; // Numeric district code
}PostalCodeResponse
interface PostalCodeResponse {
addresses: Address[];
}ProvinceData
interface ProvinceData {
id: number;
provinceCode: number;
provinceNameEn: string;
provinceNameTh: string;
}DistrictData
interface DistrictData {
id: number;
provinceCode: number;
districtCode: number;
districtNameEn: string;
districtNameTh: string;
postalCode: number;
}SubdistrictData
interface SubdistrictData {
id: number;
provinceCode: number;
districtCode: number;
subdistrictCode: number;
subdistrictNameEn: string;
subdistrictNameTh: string;
postalCode: number;
}Data Coverage
- 77 Provinces - All provinces in Thailand
- 928 Districts - Complete district coverage
- 7,410+ Subdistricts - Comprehensive subdistrict data
- Bilingual Names - Both English and Thai names
- Accurate Postal Codes - Up-to-date postal code mappings
Data Sources
This package uses Thai address data from @thailand-geography-data. See Github repo
