Thai Postcode API

Look up Thai postcodes, provinces, districts and regions via a simple JSON REST API

1,229 records77 provincesJSON · UTF-8Base URL: https://datacenter.ok9.net/api/v1/

Authentication

Every request needs an API key, sent as the X-API-KEY header (recommended) or the ?key= parameter. Contact the administrator to get a key.

Endpoints

GEThttps://datacenter.ok9.net/api/v1/zipcode.php?code=50200
Look up a 5-digit postcode (one postcode can cover several districts)
GEThttps://datacenter.ok9.net/api/v1/search.php?q=เชียงใหม่
Search by (partial) postcode, province, district or English province name · optional: region, province, limit (≤1000)
GEThttps://datacenter.ok9.net/api/v1/provinces.php?region=ภาคเหนือ
All provinces (optionally filtered by region)
GEThttps://datacenter.ok9.net/api/v1/districts.php?province=ภูเก็ต
Districts in a province with their postcodes (English names such as Phuket also work)
GEThttps://datacenter.ok9.net/api/v1/regions.php
The 6 regions

Example response

{
    "ok": true,
    "zipcode": "50200",
    "count": 1,
    "items": [
        {
            "zipcode": "50200",
            "district": "เมือง",
            "province": "เชียงใหม่",
            "province_en": "Chiang Mai",
            "region": "ภาคเหนือ",
            "region_en": "Northern",
            "note": "ที่ทำการนำจ่าย ชม.3"
        }
    ]
}

Code examples

curl -H "X-API-KEY: YOUR_KEY" "https://datacenter.ok9.net/api/v1/zipcode.php?code=50200"

Error codes

HTTPerror
400empty_query invalid_zipcodeMissing / invalid parameter
401missing_key invalid_keyAPI key missing or wrong
403key_disabled domain_not_allowedKey disabled / domain not allowed
404not_foundNo data
429daily_limitDaily request limit reached
503service_disabledService under maintenance