ROOP TAN JAIFlood Watch API
กลับไปที่แผนที่
Developers · Agents

Flood Watch API

ให้เอเจนต์ แชตบอต หรือแอปของคุณแจ้งน้ำท่วมและดึงรายงานน้ำท่วมจากชุมชนได้ ไม่ต้องมีบัญชีหรือ API key

Base URL: https://flood-api.rooptanjai.comสเปก OpenAPI 3.1llms.txt

กติกาที่ควรรู้

  • แจ้งได้ 5 รายงานต่อ 10 นาที ต่อ IP (เกินจะได้ 429 rate_limited) การดึงข้อมูลไม่จำกัด
  • รายงานเป็นข้อมูลสาธารณะ ทุกคนเห็นบนแผนที่ ยกเว้น delete_token ที่เป็นความลับ
  • photo_url / thumb_url เป็นลิงก์แบบ signed ที่หมดอายุในราว 1 ชั่วโมง ให้ดึงใหม่เมื่อจำเป็น
  • เก็บ delete_token ที่ได้ตอนแจ้งไว้ หากต้องการลบรายงานภายหลัง (ขอใหม่ไม่ได้)
  • เรียก API จากฝั่งเซิร์ฟเวอร์ของเอเจนต์ (CORS เปิดให้เฉพาะเว็บ Flood Watch)

1 · แจ้งน้ำท่วม

POST https://flood-api.rooptanjai.com/api/reports · operationId createReport

ส่งภาพ ตำแหน่ง และระดับน้ำ รายงานจะขึ้นบนแผนที่ทันที ต้องมีภาพทุกครั้ง หากเอเจนต์รับแจ้งจากผู้ใช้ ให้ส่งต่อภาพของผู้ใช้มาด้วย

ฟิลด์ใน body (JSON)

ชื่อชนิดจำเป็นคำอธิบาย
latnumberใช่Latitude where the photo was taken (WGS84).
lngnumberใช่Longitude where the photo was taken (WGS84).
accuracy_minteger | nullLocation accuracy in metres, if known.
depthDepthใช่Water depth: `none` = no water (0 cm) · `ankle` = up to 20 cm · `knee` = 20–50 cm · `waist` = 50 cm or deeper.
notestringOptional short note (up to 500 characters). Leading/trailing spaces are trimmed.
photostringใช่The photo as a base64 data URL (`data:image/jpeg;base64,…`). JPEG, PNG or WebP, up to 1.5 MB decoded; the type is checked from the bytes. The server stores a full-size (≤1600 px) and a thumbnail (≤256 px) JPEG. Whole request body ≤ 2.2 MB.

ค่าระดับน้ำ (depth)

depthคำอธิบาย
noneไม่มีน้ำ · 0 ซม.
ankleถึงข้อเท้า · ไม่เกิน 20 ซม.
kneeถึงเข่า · 20–50 ซม.
waistถึงเอวขึ้นไป · 50 ซม. ขึ้นไป

curl

# photo = base64 data URL of the image (JPEG/PNG/WebP, ≤1.5 MB)
PHOTO="data:image/jpeg;base64,$(base64 -w0 flood.jpg)"

curl -X POST https://flood-api.rooptanjai.com/api/reports \
  -H 'Content-Type: application/json' \
  -d "{\"lat\":13.7563,\"lng\":100.5018,\"depth\":\"knee\",\"note\":\"Road flooded\",\"photo\":\"$PHOTO\"}"

ตัวอย่างผลลัพธ์

HTTP/1.1 201 Created
{
  "id": 42,
  "lat": 13.7563, "lng": 100.5018, "accuracy_m": null,
  "depth": "knee",
  "note": "Road flooded",
  "photo_url": "https://storage.googleapis.com/…_full.jpg?X-Goog-Signature=…",
  "thumb_url": "https://storage.googleapis.com/…_thumb.jpg?X-Goog-Signature=…",
  "created_at": "2026-09-27T08:30:00Z",
  "delete_token": "3f9c…"   // keep this private
}

ข้อผิดพลาด

HTTPerrorคำอธิบาย
400validationfields: { field → message }
400invalid_jsonmalformed JSON or unknown field
413too_largebody > 2.2 MB
429rate_limited5 reports / 10 min / IP
503database_unavailableretry later

2 · ดึงข้อมูลรายงาน

GET https://flood-api.rooptanjai.com/api/reports · operationId listReports

ดึงรายงานล่าสุดในพื้นที่ (bbox) และช่วงเวลา (since) เรียงจากใหม่ไปเก่า

พารามิเตอร์ใน query

ชื่อชนิดคำอธิบาย
bboxstringMap area as `minLng,minLat,maxLng,maxLat` (WGS84 degrees). Omit for all areas.
sincestringOnly reports newer than this: a Go duration (`24h`, `90m`, `168h`) or an RFC 3339 time. Default `24h`. Capped at 30 days (`720h`).
limitintegerMaximum number of reports. Default 200. Values above 500 are capped at 500.

curl

curl 'https://flood-api.rooptanjai.com/api/reports?bbox=100.45,13.70,100.60,13.80&since=24h&limit=50'

ตัวอย่างผลลัพธ์

HTTP/1.1 200 OK
{
  "reports": [
    { "id": 42, "lat": 13.7563, "lng": 100.5018, "accuracy_m": null, "depth": "knee",
      "note": "Road flooded", "photo_url": "https://…", "thumb_url": "https://…",
      "created_at": "2026-09-27T08:30:00Z" }
  ]
}

ลบรายงานของคุณ

ใช้ delete_token ที่ได้ตอนแจ้ง ส่งใน header X-Delete-Token ได้ 204 เมื่อสำเร็จ

curl -X DELETE https://flood-api.rooptanjai.com/api/reports/42 -H 'X-Delete-Token: <delete_token>'