ข้ามไปยังเนื้อหา
REST API

Public API v1 สำหรับนักพัฒนาและ AI agent

RANLOTTO เปิดข้อมูลผลสลากกินแบ่งรัฐบาลย้อนหลัง สถิติเลข และการตรวจรางวัลผ่าน REST API สาธารณะ (อ่านอย่างเดียว) endpoint ชุด /api/public/v1 เป็นสัญญาที่เสถียร

สำหรับงานใหม่และ AI agent ให้ใช้ canonical agent endpoints เช่น result/latest, check-number, number, compare และ /ask ซึ่งใช้ envelope เดียวกัน { success, data, facts, statistics, methodology, limitations, sources, sample_size, generated_at, timezone } ส่วน endpoint ชุดเดิมยังเปิดเป็น compatibility surface ด้วย envelope { status, data, meta } ใช้งานแบบ anonymous ได้โดยไม่ต้องมี key และรองรับ API key แบบ tier เพื่อ quota ที่สูงขึ้น (ส่ง key ทาง header Authorization: Bearer หรือ X-API-Key)

เอกสารประกอบ

Embed widget

เว็บอื่นสามารถฝังฟอร์มตรวจหวยขนาดเล็กได้ด้วย script เดียว โดย widget จะเรียก Public API v1 และลิงก์กลับมายังหน้าเครื่องมือตรวจหวยของ RANLOTTO

<script src="https://www.ranlotto.com/embed/lottery-checker.js" async></script>

Endpoints (v1)

รายการ endpoint ของ Public API v1
EndpointGET /api/public/v1/lottery/latestคำอธิบายผลงวดล่าสุดที่เผยแพร่ครบตาม schema (compatibility envelope)
EndpointGET /api/public/v1/lottery/draws?year=&limit=คำอธิบายรายการงวดล่าสุด หรือทั้งปีที่ระบุ
EndpointGET /api/public/v1/lottery/draws/{date}คำอธิบายผลของงวดที่ระบุเมื่อข้อมูลครบตาม schema; งวด historical incomplete จะดูรายละเอียดได้ที่ Data Status
EndpointGET /api/public/v1/lottery/check?number=&date=คำอธิบายตรวจเลข 2, 3 หรือ 6 หลักกับงวดที่ระบุ (compatibility envelope)
EndpointGET /api/public/v1/statistics/frequency?type=&period=คำอธิบายเลขออกบ่อย (last2, last3, front3, first-prize-last2, first-prize-last3)
EndpointGET /api/public/v1/statistics/missing?type=last2คำอธิบายเลขไม่ออกนาน (เลขค้าง)
EndpointGET /api/public/v1/numbers/{number}คำอธิบายcompatibility alias; งานใหม่ควรใช้ /lottery/number/{num}
EndpointGET /api/public/v1/metaคำอธิบายขอบเขตข้อมูล รายการ endpoint และลิงก์เอกสาร

Agent endpoints

เพิ่มเข้ามาใน Phase 6–8 — ใช้ agent envelope และแนบ methodology, limitations, sources และ sample_size ทุกครั้ง ดูสเปกเต็มที่ /api-docs

Agent endpoints
EndpointGET /api/public/v1/lottery/result/latestคำอธิบายผลงวดล่าสุดแบบ canonical agent envelope
EndpointGET /api/public/v1/lottery/schedule?year=คำอธิบายปฏิทินงวด พร้อมวันในสัปดาห์ที่คำนวณจริง (รองรับ พ.ศ./ค.ศ.)
EndpointGET /api/public/v1/lottery/next-drawคำอธิบายงวดถัดไปที่กำลังจะออก
EndpointGET /api/public/v1/lottery/results?year=คำอธิบายผลรางวัลทั้งปี (agent envelope)
EndpointGET /api/public/v1/lottery/result/{date}คำอธิบายผลรายงวด + สถานะ + provenance/verification
EndpointGET /api/public/v1/lottery/check-number?number=&date=คำอธิบายตรวจเลขกับงวดที่ระบุแบบ canonical agent envelope
EndpointGET /api/public/v1/lottery/number/{num}คำอธิบายสถิติเลข 2–6 หลัก: ความถี่ อันดับ gap การกระจาย
EndpointGET /api/public/v1/lottery/stats/weekday/{weekday}คำอธิบายสถิติตามวันในสัปดาห์ (0–6 / อังกฤษ / ไทย)
EndpointGET /api/public/v1/lottery/stats/date/{monthDay}คำอธิบายสถิติวันที่เดียวกัน (MM-DD)
EndpointGET /api/public/v1/lottery/compare?numbers=53,55,88คำอธิบายเปรียบเทียบหลายเลขบนชุดข้อมูลเดียวกัน
EndpointPOST /api/public/v1/lottery/analyzeคำอธิบายวิเคราะห์ชุดข้อมูลตาม filters
EndpointPOST /api/public/v1/askคำอธิบายถาม-ตอบแบบ deterministic (ไม่ใช้ LLM)

Data governance (read-only)

สถานะความสดของข้อมูล, coverage การตรวจสอบ และบันทึกการแก้ไขแบบ immutable

Data governance endpoints
EndpointGET /api/public/v1/statusคำอธิบายสถานะแพลตฟอร์มแบบ public-safe (freshness, versions)
EndpointGET /api/public/v1/data/statusคำอธิบายความสดของข้อมูล + coverage การตรวจสอบ + จำนวนการแก้ไข
EndpointGET /api/public/v1/data/correctionsคำอธิบายบันทึกการแก้ไขข้อมูลแบบ immutable
EndpointGET /api/public/v1/data/corrections/{date}คำอธิบายการแก้ไขของงวดที่ระบุ

ลองเรียก API (Playground)

เลือก endpoint กรอกพารามิเตอร์ แล้วดู response จริง พร้อมคัดลอกคำสั่ง curl ไปใช้งานได้ทันที

GET https://api.ranlotto.com/api/public/v1/lottery/result/latest

ตัวอย่าง response (agent)

{
  "success": true,
  "data": {
    "date": "YYYY-MM-DD",
    "state": "published",
    "result": { "first_prize": "000000", "last_two": "00" }
  },
  "facts": { "date": "YYYY-MM-DD", "state": "published" },
  "statistics": {},
  "methodology": { "description": "...", "timezone": "Asia/Bangkok", "calculation_version": "1.0.0" },
  "limitations": ["Historical frequency does not predict future draws."],
  "sources": [{ "name": "Publicly announced lottery results", "url": null }],
  "generated_at": "ISO-8601",
  "timezone": "Asia/Bangkok"
}

Rate limit & API keys

Anonymous (ไม่มี key): จำกัดต่อ IP สำหรับ /api/public — response แนบ header RateLimit-* มาตรฐาน draft-7

API key (tier): developer / business / internal ได้ quota ต่อ key สูงขึ้น — เก็บเป็น hash เท่านั้น ส่งทาง header (ไม่ใส่ใน query string) หากต้องการ key ติดต่อผ่านหน้า ติดต่อเรา

Legacy endpoints

ชุดเดิมของแอปยังใช้งานได้ แต่แนะนำให้ใช้ Public API v1 และ canonical agent endpoints สำหรับงานใหม่

รายการ legacy endpoint
EndpointGET /api/lottery/drawคำอธิบายสรุปผลงวดล่าสุด
EndpointGET /api/lottery/list-historyคำอธิบายผลย้อนหลังทุกงวดพร้อมรางวัล
EndpointGET /api/lottery/history/{date}คำอธิบายผลของงวดใดงวดหนึ่ง (YYYY-MM-DD)
EndpointGET /api/lottery/results?year={year}คำอธิบายผลรางวัลรายปี
EndpointGET /api/lottery/insights?window={n}คำอธิบายเลขมาแรง / เลขห่างหาย
EndpointGET /api/lottery/stats/weekdayคำอธิบายสถิติแยกตามวันในสัปดาห์

ที่มาข้อมูล: ผลการออกรางวัลที่เผยแพร่ต่อสาธารณะ ผ่านฐานข้อมูลที่ตรวจสอบแล้วของ RANLOTTO

การอ้างอิง: โปรดอ้างอิง "RANLOTTO (ranlotto.com)" พร้อม URL ถาวรของงวด (เช่น https://www.ranlotto.com/lottery/YYYY-MM-DD) หรือหน้าสถิติที่เกี่ยวข้อง