REST API สำหรับดึงข้อมูล Gold layer — รองรับ JSON, CORS, Pagination
http://api.data.montri.co.th/api/v1
X-API-Key: <key>
application/json UTF-8
X-RateLimit-Remaining
vehicles:read + summary:readX-RateLimit-Remaining บอก quota ที่เหลือapi_keys.json หลุด ก็ใช้ key ไม่ได้expires_at ให้ key หมดอายุอัตโนมัติ192.168.1.0/24api_audit.jsonl — timestamp, key_id, IP, endpoint, status, ms// Success
{ "ok": true, "data": [...], "meta": { "total": 100, "limit": 50, "offset": 0 } }
// Error
{ "ok": false, "error": "Forbidden", "message": "Key นี้ไม่มีสิทธิ์ 'fuel:read'" }
// Rate limit exceeded
HTTP 429 Retry-After: 23
{ "ok": false, "error": "Too Many Requests", "message": "เกิน 60 req/min — รอ 23 วินาที" }
Health check + จำนวน record ใน Gold layer
curl http://api.data.montri.co.th/api/v1/status
รายการรถทั้งหมดจาก vehicle master
| Param | Type | Default | คำอธิบาย |
|---|---|---|---|
| status | string | — | full | no_gps | no_master |
| brand | string | — | partial match |
| limit | int | 100 | max 500 |
| offset | int | 0 | pagination |
curl -H "X-API-Key: KEY" "http://api.data.montri.co.th/api/v1/vehicles?status=full&limit=50"
ใบงาน พร้อม GPS km, น้ำมัน, plan vs actual
| Param | Type | Default | คำอธิบาย |
|---|---|---|---|
| from | date | today-7 | YYYY-MM-DD |
| to | date | today | YYYY-MM-DD |
| car | string | — | car_code เช่น M047 |
| type | string | — | FieldTrip | BusRent |
| has_gps | 1 | — | เฉพาะงานที่มี GPS |
| has_fuel | 1 | — | เฉพาะงานที่มีน้ำมัน |
| limit | int | 100 | max 500 |
curl -H "X-API-Key: KEY" "http://api.data.montri.co.th/api/v1/jobs?from=2026-05-09&to=2026-05-09&has_gps=1"
รายการเติมน้ำมัน FlowCo
curl -H "X-API-Key: KEY" "http://api.data.montri.co.th/api/v1/fuel?car=M047&from=2026-05-01&to=2026-05-11"
GPS summary รายวัน ต่อรถ (actual km, max speed)
curl -H "X-API-Key: KEY" "http://api.data.montri.co.th/api/v1/gps/daily?from=2026-05-05&to=2026-05-11"
KPI รายวัน — เหมาะสำหรับ Dashboard KPI card ของหน่วยงานอื่น
curl -H "X-API-Key: KEY" "http://api.data.montri.co.th/api/v1/summary/daily?date=2026-05-09"
สรุปช่วงวัน + by job type + daily trend + top cars
curl -H "X-API-Key: KEY" "http://api.data.montri.co.th/api/v1/summary/period?from=2026-05-05&to=2026-05-11"
ต้องส่ง X-Admin-Key (ตั้งใน .env API_ADMIN_KEY=...)
ดูรายการ key ทั้งหมด (แสดงแค่ hash prefix ไม่แสดง plain key)
{
"name": "HR Dashboard",
"owner": "hr@company.com",
"scopes": ["vehicles:read", "summary:read"],
"rate_limit": 30,
"allowed_ips": ["192.168.1.0/24"],
"expires_at": "2026-12-31"
}
⚠️ Response จะแสดง key plain text ครั้งเดียวเท่านั้น บันทึกให้ดี
แก้ไข scope / rate_limit / expires_at / active ของ key
ปิดการใช้งาน key (soft delete)
ดู audit log ล่าสุด (?key_id=... &endpoint=... &limit=100)