เอกสารการใช้งาน API

API ทุกตัวตอบกลับเป็น JSON ในรูปแบบ { success, data } เมื่อสำเร็จ และ { success: false, message } เมื่อเกิดข้อผิดพลาด

Base URL: https://lottery.thiti.dev

เริ่มต้นใช้งาน

สมัครสมาชิกและออก API key ที่หน้าสมาชิก แล้วลองเรียกผลงวดล่าสุดด้วยคำสั่งนี้

bash
curl https://lottery.thiti.dev/api/v1/latest \
  -H "X-API-Key: YOUR_API_KEY"
รับ API key

การยืนยันตัวตน

ทุกคำขอต้องส่ง API key ใน header X-API-Key

HTTP header
X-API-Key: YOUR_API_KEY

Endpoints

GET/api/v1/latest

ดึงผลรางวัลงวดล่าสุด

ตัวอย่างคำขอ
curl https://lottery.thiti.dev/api/v1/latest \
  -H "X-API-Key: YOUR_API_KEY"
ตัวอย่างคำตอบ
{
  "success": true,
  "data": {
    "resultDate": "2026-12-01",
    "results": [
      {
        "fieldName": "first",
        "nameTh": "",
        "nameEn": "",
        "price": 6000000,
        "numbers": [{ "value": "123456", "round": 1 }]
      }
    ]
  }
}

GET/api/v1/result/{date}

ดึงผลรางวัลตามวันที่ออกรางวัล (รูปแบบ YYYY-MM-DD)

ตัวอย่างคำขอ
curl https://lottery.thiti.dev/api/v1/result/2026-12-01 \
  -H "X-API-Key: YOUR_API_KEY"

POST/api/v1/check

ตรวจเลขสลาก 6 หลักได้สูงสุด 100 เลขต่อคำขอ ถ้าไม่ส่ง date จะใช้งวดล่าสุด

ตัวอย่างคำขอ
const res = await fetch('https://lottery.thiti.dev/api/v1/check', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'YOUR_API_KEY',
  },
  body: JSON.stringify({ numbers: ['123456', '654321'], date: '2026-12-01' }),
});
const { success, data } = await res.json();
ตัวอย่างคำตอบ
{
  "success": true,
  "data": {
    "resultDate": "2026-12-01",
    "results": [
      {
        "number": "123456",
        "won": true,
        "totalAmount": 6000000,
        "prizes": [
          {
            "fieldName": "first",
            "prizeNameTh": "",
            "prizeNameEn": "",
            "prize": "first",
            "amount": 6000000,
            "matchedNumber": "123456",
            "round": 1
          }
        ]
      },
      { "number": "654321", "won": false, "totalAmount": 0, "prizes": [] }
    ]
  }
}

รหัสข้อผิดพลาด

400ข้อมูลไม่ถูกต้อง เช่น รูปแบบวันที่หรือเลขสลากผิด
401ไม่มี API key, key ไม่ถูกต้อง, ถูกยกเลิก หรือหมดอายุ
403บัญชีถูกระงับ (Account is suspended.) หรือยังไม่มีแพ็กเกจที่ใช้งานได้ (Subscription is not active.)
404ไม่พบผลรางวัล (ของวันที่ที่ขอ หรือยังไม่มีผลในระบบ)
500เกิดข้อผิดพลาดภายในระบบ (รวมถึงระหว่างตรวจ API key)
JSON
{ "success": false, "message": "Invalid API key." }

เอกสารแบบ interactive

ดู schema ทั้งหมดและลองเรียก API ได้ที่หน้า Swagger /swagger (เปิดในแท็บใหม่)