ฐานข้อมูลจังหวัด อำเภอ ตำบล ของประเทศไทย ในรูปแบบ csv json sql xlsx xml
Table of contents
Intro
ข้อมูลจังหวัด อำเภอ ตำบล ของประเทศไทย ที่อยู่ในรูปแบบไฟล์ประเภทต่าง ๆ จัดเก็บไว้ที่ Github
ข้อมูล
ชุดข้อมูล จังหวัด (Province), อำเภอ (District), ตำบล (Sub-district) ของประเทศไทย
รองรับหลายรูปแบบ (CSV, JSON, SQL, XLSX, XML) และมี API JSON ให้เรียกใช้งานได้ทันที
Highlights v2
amphure
→district
,tambon
→sub_district
- ลบ prefix
thai_
ในชื่อ dataset - เพิ่ม spec schema ใน
data/spec/*.json
- pipeline รันง่ายด้วย
scripts/make.py
ดาวน์โหลดข้อมูลทั้งหมดที่
https://github.com/kongvut/thai-province-data
🧾 รูปแบบข้อมูลและสคีมา
- geography.json →
id
,name
- province.json →
id
,name_th
,name_en
,geography_id
, timestamps - district.json →
id
,name_th
,name_en
,province_id
, timestamps - sub_district.json →
id
,zip_code
,name_th
,name_en
,district_id
,lat
,long
, timestamps
ข้อมูลต้นทางอยู่ใน data/raw/*.json
→ export ได้หลายไฟล์ใน formats/*
🔌 ไฟล์ API พร้อมใช้งาน
API endpoints ใช้ไฟล์ใน api/latest สามารถเรียกใช้งานตรงจาก GitHub Raw:
-
province.json
https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/province.json
-
district.json
https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/district.json
-
sub_district.json
https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/sub_district.json
-
province_with_district_and_sub_district.json
https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/province_with_district_and_sub_district.json
-
sub_district_with_district_and_province.json
https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/sub_district_with_district_and_province.json
ตัวอย่าง Raw URL
# ดูจังหวัดแรก ๆ
curl -s https://raw.githubusercontent.com/kongvut/thai-province-data/refs/heads/master/api/latest/province.json | jq '.[0:3]'
Fetch data demo by React
ตัวอย่างการใช้งาน API province_with_district_and_sub_district.json
เพื่อสร้าง DropdownList
https://codesandbox.io/p/sandbox/thailand-province-demo-api-k3st7