ระบบรายงานสาธารณภัยจังหวัดแม่ฮ่องสอน
Version 2.0
API ของระบบรายงานสาธารณภัยจังหวัดแม่ฮ่องสอน ถูกออกแบบมาเพื่อให้หน่วยงานต่างๆ สามารถเชื่อมต่อและนำข้อมูลไปใช้ประโยชน์ต่อได้
https://acdm.mhs-pao.go.th/api/v1/
ปัจจุบัน API เป็นแบบ Public API ไม่ต้องใช้ API Key
ดึงข้อมูลเหตุการณ์สาธารณภัย
| Parameter | Type | Required | Description |
|---|---|---|---|
year |
integer | No | ปี ค.ศ. (เช่น 2025) |
start_date |
date | No | วันที่เริ่มต้น (YYYY-MM-DD) |
end_date |
date | No | วันที่สิ้นสุด (YYYY-MM-DD) |
incident_type |
string | No | ประเภทเหตุการณ์ (อัคคีภัย, อุทกภัย, ฯลฯ) |
district |
string | No | อำเภอ |
severity |
string | No | ความรุนแรง (เล็กน้อย, ปานกลาง, รุนแรง) |
status |
string | No | สถานะ (pending, in_progress, completed) |
limit |
integer | No | จำนวนข้อมูลต่อหน้า (default: 100, max: 1000) |
offset |
integer | No | เริ่มต้นจากข้อมูลลำดับที่ (default: 0) |
curl "https://acdm.mhs-pao.go.th/api/v1/incidents.php?year=2025&limit=10"
{
"success": true,
"version": "2.0",
"timestamp": "2025-11-20T12:00:00+07:00",
"meta": {
"total": 41,
"limit": 10,
"offset": 0,
"returned": 10
},
"data": [
{
"id": "123",
"incident_type": "อัคคีภัย",
"report_time": "2025-11-20 08:30:00",
"district": "เมืองแม่ฮ่องสอน",
"sub_district": "จองคำ",
"village": "บ้านห้วยปูลิง",
"latitude": "19.3025",
"longitude": "97.9647",
"severity": "ปานกลาง",
"affected_people": 5,
"affected_households": 1,
"deaths": 0,
"injuries": 0,
"status_key": "in_progress",
"status_name": "กำลังดำเนินการ",
"damage_estimate": 50000
}
]
}
ดึงข้อมูลสถิติสาธารณภัย
| Parameter | Type | Required | Description |
|---|---|---|---|
year |
integer | No | ปี ค.ศ. |
start_date |
date | No | วันที่เริ่มต้น |
end_date |
date | No | วันที่สิ้นสุด |
group_by |
string | No | จัดกลุ่มตาม (type, district, severity, month, all) |
ดึงข้อมูลรายชื่ออำเภอและตำบล
ดึงข้อมูลประเภทเหตุการณ์สาธารณภัย
API สำหรับเข้าถึงข้อมูลสถานีตรวจวัดปริมาณน้ำฝนและรายงานปริมาณน้ำฝน
ดึงข้อมูลสถานีตรวจวัดปริมาณน้ำฝน
| Parameter | Type | Required | Description |
|---|---|---|---|
district |
string | No | กรองตามอำเภอ |
sub_district |
string | No | กรองตามตำบล |
station_type |
string | No | กรองตามประเภทสถานี (manual, automatic) |
is_active |
string | No | กรองตามสถานะ (1=ใช้งาน, 0=ไม่ใช้งาน, all=ทั้งหมด) Default: all |
station_id |
integer | No | ID ของสถานีที่ต้องการ |
// JavaScript
fetch('http://localhost/api/v1/rainfall/stations.php?district=เมืองแม่ฮ่องสอน&is_active=1')
.then(response => response.json())
.then(data => console.log(data));
ดึงข้อมูลรายงานปริมาณน้ำฝน
| Parameter | Type | Required | Description |
|---|---|---|---|
station_id |
integer | No | กรองตาม ID ของสถานี |
district |
string | No | กรองตามอำเภอ |
start_date |
date | No | วันที่เริ่มต้น (YYYY-MM-DD) |
end_date |
date | No | วันที่สิ้นสุด (YYYY-MM-DD) |
min_rainfall |
number | No | ปริมาณน้ำฝนขั้นต่ำ (มม.) |
limit |
integer | No | จำนวนผลลัพธ์ต่อหน้า (Default: 100, Max: 1000) |
offset |
integer | No | ข้ามผลลัพธ์กี่รายการ (สำหรับ pagination) |
# Python
import requests
url = "http://localhost/api/v1/rainfall/reports.php"
params = {
"start_date": "2024-01-01",
"end_date": "2024-12-31",
"min_rainfall": 50,
"limit": 20
}
response = requests.get(url, params=params)
data = response.json()
print(data)
ดึงข้อมูลสถิติปริมาณน้ำฝน
| Parameter | Type | Required | Description |
|---|---|---|---|
group_by |
string | No | จัดกลุ่มตาม: station, district, day, month, all (Default: all) |
district |
string | No | กรองตามอำเภอ (ใช้ได้เมื่อ group_by=station) |
start_date |
date | No | วันที่เริ่มต้น (YYYY-MM-DD) |
end_date |
date | No | วันที่สิ้นสุด (YYYY-MM-DD) |
station - สถิติแยกตามสถานีตรวจวัดdistrict - สถิติแยกตามอำเภอday - สถิติรายวัน (30 วันล่าสุด)month - สถิติรายเดือน (12 เดือนล่าสุด)all - สถิติภาพรวมทั้งหมด// PHP
$url = "http://localhost/api/v1/rainfall/statistics.php?group_by=district";
$data = json_decode(file_get_contents($url), true);
if ($data['success']) {
foreach ($data['data'] as $stat) {
echo "{$stat['district']}: {$stat['total_rainfall']} mm\n";
}
}
API สำหรับดึงข้อมูลจุดความร้อน (Fire Hotspot) จาก NASA FIRMS และ GISTDA VIIRS พร้อมระบบ Deduplication อัตโนมัติ
ดึงข้อมูลจุดความร้อนจาก NASA FIRMS และ/หรือ GISTDA VIIRS พร้อม Dedup อัตโนมัติ
nocache=1)
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
hours | integer | No | 24 | ชั่วโมงย้อนหลัง (ใช้เมื่อไม่ระบุ start_date/end_date) |
start_date | date | No | — | วันเริ่มต้น YYYY-MM-DD (override hours) |
end_date | date | No | — | วันสิ้นสุด YYYY-MM-DD (override hours) |
district | string | No | — | กรองตามอำเภอ (ชื่อภาษาไทย) |
source | string | No | — | แหล่งข้อมูล FIRMS: VIIRS หรือ MODIS |
include_firms | boolean | No | true | รวมข้อมูล NASA FIRMS |
include_gistda | boolean | No | false | รวมข้อมูล GISTDA VIIRS |
resolve_admin | boolean | No | false | Resolve อำเภอ/ตำบล/หมู่บ้าน ผ่าน PostGIS |
resolve_level | string | No | full | full = อำเภอ+ตำบล+หมู่บ้าน, district = อำเภอเท่านั้น (เร็วกว่า) |
include_outside | boolean | No | false | รวมจุดนอกเขตแม่ฮ่องสอน |
nocache | boolean | No | false | ข้าม cache 5 นาที |
curl "https://acdm.mhs-pao.go.th/get_fire_hotspots_api.php?include_firms=1&include_gistda=1&start_date=2026-03-01&end_date=2026-03-10"
{
"success": true,
"fires": [
{
"id": 123,
"latitude": 19.123,
"longitude": 98.456,
"brightness": 312.5,
"acq_date": "2026-03-09",
"acq_time": "0654",
"satellite": "N20",
"instrument": "VIIRS",
"confidence": "nominal",
"frp": 2.4,
"daynight": "N",
"district": "เมืองแม่ฮ่องสอน",
"tambon": "ปางหมู",
"source": "VIIRS",
"provider": "FIRMS"
}
],
"stats": {
"total": 1673,
"last_24h": 279,
"last_48h": 1664,
"high_confidence": 1287,
"moderate_confidence": 386,
"by_district": { "แม่ฮ่องสอน": 220, "แม่สะเรียง": 7, "ไม่ระบุอำเภอ": 1446 },
"by_source": { "VIIRS": 205, "MODIS": 22, "GISTDA": 1446 }
},
"meta": {
"firms_db_max_acq_date": "2026-03-09",
"gistda_db_max_acq_date": "2026-03-09"
}
}
ดึงรายชื่อปีที่มีข้อมูลจุดความร้อน พร้อมจำนวนรวมรายปี
| Parameter | Type | Required | Description |
|---|---|---|---|
source | string | No | กรองแหล่ง: VIIRS, MODIS |
include_gistda | boolean | No | รวมจำนวนปีของ GISTDA VIIRS |
{
"success": true,
"years": [2023, 2024, 2025, 2026],
"year_totals": {
"2023": 15420,
"2024": 18310,
"2025": 22100,
"2026": 5030
}
}
ดึงสแนปชอตรายวันของจำนวนจุดความร้อน (บันทึกอัตโนมัติทุกวัน)
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
date | date | No | เมื่อวาน | วันที่ต้องการ YYYY-MM-DD |
{
"success": true,
"found": true,
"date": "2026-03-09",
"snapshot": {
"snapshot_date": "2026-03-09",
"total_count": 1673,
"firms_count": 227,
"gistda_count": 1446,
"captured_at": "2026-03-10 00:05:00"
}
}
Proxy ไปยัง GISTDA Sphere Disaster API — ค้นหาจุดความร้อนรอบพิกัดที่ระบุ
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
lon | float | Yes | — | ลองจิจูด (-180 ถึง 180) |
lat | float | Yes | — | ละติจูด (-90 ถึง 90) |
radius | float | No | 1000 | รัศมีค้นหา (เมตร) |
curl "https://acdm.mhs-pao.go.th/get_gistda_disaster_hotspot_api.php?lat=19.30&lon=97.97&radius=5000"
API สำหรับคำนวณและแสดงผลพื้นที่เผาไหม้จากข้อมูลดาวเทียม GISTDA รองรับทั้ง GeoJSON Features และ WMS Image Analysis
คำนวณพื้นที่เผาไหม้รวม จาก GISTDA GeoJSON features หรือ WMS PNG cache
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
source | string | No | features | features = GISTDA GeoJSON, png/wms = cached WMS image |
bbox | string | No | — | Bounding box: minLon,minLat,maxLon,maxLat |
pv_tn | string | No | แม่ฮ่องสอน | จังหวัด (ภาษาไทย) |
start_date | date | No | — | วันเริ่มต้น |
end_date | date | No | — | วันสิ้นสุด |
limit | integer | No | — | จำนวน features สูงสุด |
พื้นที่เผาไหม้แยกตามเขตการปกครอง (อำเภอ/ตำบล/หมู่บ้าน) จาก WMS Pixel Analysis
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
level | string | No | districts | ระดับ: district / subdistrict / village |
cache_id | integer | No | ล่าสุด | ID ของ burn_scar_cache |
include_zero | boolean | No | true | รวมพื้นที่ที่ไม่มีเผาไหม้ |
page | integer | No | 1 | หน้า |
page_size | integer | No | 0 (ทั้งหมด) | จำนวนต่อหน้า (สูงสุด 200) |
min_area_rai | float | No | 0 | พื้นที่เผาไหม้ขั้นต่ำ (ไร่) |
stride | integer | No | 8 | Pixel sampling stride (1-32) |
color_threshold | integer | No | 40 | Burn pixel detection threshold (0-765) |
รายการ cache ข้อมูลเผาไหม้รายสัปดาห์ (metadata เท่านั้น) พร้อมความเปลี่ยนแปลงรายสัปดาห์
{
"success": true,
"count": 12,
"data": [
{
"id": 5,
"week_start": "2026-01-06",
"week_end": "2026-01-12",
"iso_week": "2026-W02",
"width": 1024,
"height": 768,
"burn_area_rai": 1234.56,
"weekly_change_rai": 150.30,
"fetched_at": "2026-01-13 01:00:00"
}
]
}
ส่งภาพ PNG เผาไหม้ล่าสุด สำหรับ overlay แผนที่
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
id | integer | No | ล่าสุด | Cache ID ที่ต้องการ |
render | string | No | — | boost = เพิ่มความชัด, red = แสดงพิกเซลเผาเป็นสีแดง |
Content-Type: image/png) ไม่ใช่ JSON
| Endpoint | Description |
|---|---|
/get_burn_scar_latest_meta.php | Metadata ภาพเผาไหม้ล่าสุด (JSON) |
/get_burn_scar_cumulative_image.php?weeks=4 | ภาพเผาไหม้สะสมหลายสัปดาห์ (PNG) |
/get_burn_scar_cumulative_meta.php?weeks=4 | Metadata ภาพเผาไหม้สะสม (JSON) |
วิเคราะห์พื้นที่เผาไหม้จำแนกตามประเภทการใช้ที่ดิน (ป่าไม้, เกษตร, ฯลฯ)
| Endpoint | ระดับ | Parameters หลัก |
|---|---|---|
/get_burn_scar_landuse_by_district.php | อำเภอ | district_code, cache_id |
/get_burn_scar_landuse_by_subdistrict.php | ตำบล | district_code, subdistrict_code, cache_id |
/get_burn_scar_landuse_by_village_wms.php | หมู่บ้าน | district_code, subdistrict_code, village_id, cache_id |
{
"success": true,
"district_code": "01",
"district_name": "เมืองแม่ฮ่องสอน",
"cache_id": 15,
"rows": [
{
"category": "ป่าไม้",
"description": "ป่าเบญจพรรณ",
"area_m2": 1600000,
"area_rai": 1000.0,
"pct": 45.5
}
],
"total": { "area_m2": 3520000, "area_rai": 2200.0 }
}
วิเคราะห์เผาไหม้จำแนกตามประเภทพื้นที่กฎหมาย (ป่าสงวนแห่งชาติ, เขตอุทยานแห่งชาติ, ฯลฯ)
| Endpoint | ระดับ | Parameters หลัก |
|---|---|---|
/get_burn_scar_legal_area_by_district.php | อำเภอ | district_code, cache_id |
/get_burn_scar_legal_area_by_subdistrict.php | ตำบล | district_code, subdistrict_code, cache_id |
/get_burn_scar_legal_area_by_village_wms.php | หมู่บ้าน | district_code, subdistrict_code, village_id, cache_id |
| Endpoint | Description | Parameters |
|---|---|---|
/get_legal_area_hotspot_stats_api.php | สถิติรายเดือน + GeoJSON geometry | year, month, category |
/get_legal_area_hotspot_stats_realtime_api.php | สถิติ Realtime ผ่าน PostGIS | days, category, format |
วิเคราะห์เผาไหม้จำแนกตามชั้นคุณภาพลุ่มน้ำ (1A, 1B, 2, 3, 4, 5)
| Endpoint | ระดับ | Parameters หลัก |
|---|---|---|
/get_burn_scar_watershed_by_admin.php | Router | district_code, cache_id, subdistrict_code(optional) |
/get_burn_scar_watershed_by_district.php | อำเภอ | district_code, cache_id |
/get_burn_scar_watershed_by_subdistrict.php | ตำบล | district_code, subdistrict_code, cache_id |
/get_burn_scar_watershed_by_village_wms.php | หมู่บ้าน | district_code, subdistrict_code, village_id, cache_id |
| Parameter | Type | Default | Description |
|---|---|---|---|
GET /get_watershed_hotspot_stats_realtime_api.php | |||
days | integer | 30 | ย้อนหลังกี่วัน (สูงสุด 365) |
start_date | date | — | วันเริ่มต้น |
end_date | date | — | วันสิ้นสุด |
category | string | — | ชั้นลุ่มน้ำ: 1A, 1B, 2, 3, 4, 5 |
format | string | geojson | json หรือ geojson |
include_burn_scar | boolean | false | รวมพื้นที่เผาไหม้ overlay |
API สำหรับดึงข้อมูลคุณภาพอากาศ PM2.5 / PM10 / AQI จากหลายแหล่ง (Air4Thai, DustBoy)
ดึงข้อมูลคุณภาพอากาศ Real-time จาก Air4Thai (กรมควบคุมมลพิษ) กรองเฉพาะสถานีในแม่ฮ่องสอน
{
"success": true,
"data": [
{
"station_id": "58t",
"station_name": "ต.จองคำ อ.เมือง จ.แม่ฮ่องสอน",
"lat": 19.303,
"lng": 97.965,
"aqi": { "value": 120, "level": "มีผลกระทบต่อสุขภาพ", "color": "#FF7E00" },
"pm25": { "value": 45.2, "unit": "µg/m³" },
"pm10": { "value": 62.0, "unit": "µg/m³" }
}
],
"statistics": {
"pm25": { "max": 45.2, "min": 30.1, "avg": 37.6 },
"aqi": { "max": 120, "min": 85, "avg": 102 }
},
"source": "Air4Thai - กรมควบคุมมลพิษ"
}
ข้อมูลคุณภาพอากาศย้อนหลัง รายวัน/รายเดือน/รายปี พร้อมเปรียบเทียบปีก่อน
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
period | string | No | daily | daily / monthly / yearly |
start_date | date | No | 30 วันก่อน | วันเริ่มต้น |
end_date | date | No | วันนี้ | วันสิ้นสุด |
compare_year | integer | No | — | เปรียบเทียบกี่ปีก่อน (เช่น 1 = ปีที่แล้ว) |
detail | string | No | summary | summary = รวม, stations = แยกสถานี |
รวมข้อมูล PM2.5 จากทุกแหล่ง — Air4Thai + DustBoy (CMUCCDC) พร้อมคำนวณ AQI และระดับภาษาไทย
{
"success": true,
"total_sensors": 35,
"sensors": [
{
"id": "air4thai_58t",
"lat": 19.303,
"lon": 97.965,
"pm25": 45.2,
"aqi": 120,
"color": "#FF7E00",
"level": "มีผลกระทบต่อสุขภาพ",
"name": "สถานี Air4Thai จองคำ",
"source": "Air4Thai",
"update_time": "2026-03-10 10:00:00"
},
{
"id": "dustboy_5621",
"lat": 19.350,
"lon": 98.020,
"pm25": 68.0,
"aqi": 155,
"color": "#FF0000",
"level": "เริ่มมีผลกระทบต่อสุขภาพ",
"name": "DustBoy ID-5621",
"source": "DustBoy"
}
],
"sources": { "Air4Thai": 3, "DustBoy": 32 }
}
API สนามลม GFS, วิเคราะห์ PM2.5 Spike, และ Environment Insights สำหรับการตัดสินใจ
ข้อมูลสนามลม GFS 10m สำหรับ Leaflet Velocity overlay (ไม่มี parameter)
{
"success": true,
"meta": {
"source": "GFS",
"ref_time": "2026-03-10T00:00:00Z",
"forecast_hour": 0
},
"field": [
{ "header": { "lo1": 97.0, "la1": 21.0, "dx": 0.25, "dy": 0.25, "nx": 10, "ny": 15 }, "data": ["..."] },
{ "header": { "...":"..." }, "data": ["..."] }
]
}
วิเคราะห์ลม (GFS + Open-Meteo) รวมกับ PM2.5 Spike Detection สำหรับประเมินการเคลื่อนตัวของควัน
| Parameter | Type | Default | Description |
|---|---|---|---|
province | string | แม่ฮ่องสอน | จังหวัด |
threshold | float | 5.0 | Spike threshold PM2.5 (µg/m³) |
hours | integer | 3 | ย้อนหลังกี่ชั่วโมง (1-24) |
include_open_meteo | boolean | 1 | รวมข้อมูลลม Open-Meteo |
cache_ttl | integer | 120 | Cache TTL (วินาที) |
วิเคราะห์ความสัมพันธ์จุดความร้อน × PM2.5 × สภาพอากาศรายวัน พร้อม Pearson Correlation
| Parameter | Type | Required | Description |
|---|---|---|---|
start_date | date | Yes | วันเริ่มต้น YYYY-MM-DD |
end_date | date | Yes | วันสิ้นสุด YYYY-MM-DD |
include_gistda | boolean | No | รวม GISTDA VIIRS |
province | string | No | กรองจังหวัด |
district | string | No | กรองอำเภอ |
tambon | string | No | กรองตำบล |
curl "https://acdm.mhs-pao.go.th/get_hotspot_environment_insights.php?start_date=2026-02-01&end_date=2026-03-10&include_gistda=1"
Response ทั้งหมดจะอยู่ในรูปแบบ JSON และมีโครงสร้างพื้นฐานดังนี้:
{
"success": true, // สถานะการทำงาน (true/false)
"version": "2.0", // เวอร์ชัน API
"timestamp": "...", // เวลาที่สร้าง response (ISO 8601)
"meta": {}, // ข้อมูล metadata (ถ้ามี)
"data": [], // ข้อมูลที่ร้องขอ
"error": {} // ข้อมูล error (ถ้ามี)
}
| HTTP Code | Error Code | Description |
|---|---|---|
400 |
BAD_REQUEST | Request ไม่ถูกต้อง |
404 |
NOT_FOUND | ไม่พบข้อมูลที่ร้องขอ |
429 |
RATE_LIMIT_EXCEEDED | เรียกใช้ API เกินจำนวนที่กำหนด |
500 |
INTERNAL_ERROR | เกิดข้อผิดพลาดภายในระบบ |
fetch('https://acdm.mhs-pao.go.th/api/v1/incidents.php?year=2025&limit=10')
.then(response => response.json())
.then(data => {
console.log('Total incidents:', data.meta.total);
console.log('Incidents:', data.data);
})
.catch(error => console.error('Error:', error));
import requests
url = 'https://acdm.mhs-pao.go.th/api/v1/incidents.php'
params = {'year': 2025, 'limit': 10}
response = requests.get(url, params=params)
data = response.json()
print(f"Total incidents: {data['meta']['total']}")
for incident in data['data']:
print(f"- {incident['incident_type']} at {incident['district']}")
$url = 'https://acdm.mhs-pao.go.th/api/v1/incidents.php?year=2025&limit=10';
$response = file_get_contents($url);
$data = json_decode($response, true);
echo "Total incidents: " . $data['meta']['total'] . "\n";
foreach ($data['data'] as $incident) {
echo "- {$incident['incident_type']} at {$incident['district']}\n";
}