sXAPI Lotto API v1.0.0
บริการ API สำหรับดึงข้อมูลผลหวยและเลขปิด/เลขอั้นแบบ Real-time
ความเร็วสูง หน่วงต่ำ พร้อมให้บริการตลอด 24/7
High-performance lottery results & closed numbers API — Real-time data, low latency, always on 24/7.
ບໍລິການ API ສຳລັບດຶງຂໍ້ມູນຜົນຫວຍ ແລະ ເລກປິດ/ເລກອັ້ນແບບ Real-time
ຄວາມໄວສູງ ພ້ອມໃຫ້ບໍລິການ 24/7
การยืนยันตัวตน (Authentication) Authentication ການຢືນຢັນຕົວຕົນ
ทุก endpoint ใน /api/v1/* ต้องส่ง API Key ผ่าน header X-API-KEY หรือ query parameter api_key
All /api/v1/* endpoints require a valid API Key via X-API-KEY header or api_key query parameter.
ທຸກ endpoint ໃນ /api/v1/* ຕ້ອງສົ່ງ API Key ຜ່ານ header X-API-KEY ຫຼື query parameter api_key
| Method | Example |
|---|---|
| Header (recommended) | X-API-KEY: YOUR_KEY |
| Query Param | ?api_key=YOUR_KEY |
API สำหรับผู้ใช้งาน Consumer API API ສຳລັບຜູ້ໃຊ້
ดึงผลรางวัลหวยตามรหัส — ต้องระบุ date หรือ from/to ครบถ้วน
Fetch lottery results by code — must provide complete date or from/to params.
ດຶງຜົນຫວຍຕາມລະຫັດ — ຕ້ອງລະບຸ date ຫຼື from/to ຄົບຖ້ວນ
| Parameter | Type | Required | Description |
|---|---|---|---|
lottery_code | string | Yes | รหัสหวย (เช่น thai, hanoi, lao) |
date | string | Conditional | YYYY-MM-DD (ใช้แทน from/to) |
from | string | Conditional | Start date (ต้องคู่กับ to) |
to | string | Conditional | End date (ต้องคู่กับ from) |
ดึงเลขปิด/เลขอั้น/เลขเต็ม — ต้องระบุ type และวันที่ครบถ้วน
Fetch closed/restricted/full numbers — requires type and complete date params.
ດຶງເລກປິດ/ເລກອັ້ນ/ເລກເຕັມ — ຕ້ອງລະບຸ type ແລະວັນທີຄົບຖ້ວນ
| Parameter | Type | Required | Description |
|---|---|---|---|
lottery_code | string | Yes | รหัสหวย (เช่น thai, hanoi, lao) |
type | string | Yes | all | close | half |
date | string | Conditional | YYYY-MM-DD (ใช้แทน from/to) |
from | string | Conditional | Start date (ต้องคู่กับ to) |
to | string | Conditional | End date (ต้องคู่กับ from) |
รหัสข้อผิดพลาด Error Codes ລະຫັດຂໍ້ຜິດພາດ
| HTTP | Code | ความหมาย Meaning ຄວາມໝາຍ |
|---|---|---|
| 400 | DATE_REQUIRED |
ต้องระบุ date ในการเรียก
The date parameter is required for this request
ຕ້ອງລະບຸ date
|
| 400 | INVALID_DATE_FORMAT | รูปแบบวันที่ไม่ถูกต้อง ต้องเป็น YYYY-MM-DD Date format must be YYYY-MM-DD ຮູບແບບວັນທີບໍ່ຖືກຕ້ອງ ຕ້ອງເປັນ YYYY-MM-DD |
| 400 | DATE_RANGE_TOO_LARGE | ช่วงวันที่เกินขีดจำกัดของ Key นี้ Date range exceeds the limit for your API key ຊ່ວງວັນທີເກີນຂີດຈຳກັດຂອງ Key ນີ້ |
| 400 | INVALID_DATE_RANGE |
enddate ต้องไม่น้อยกว่า date
enddate must be ≥ date
enddate ຕ້ອງ ≥ date
|
| 401 | MISSING_API_KEY | ไม่พบ API Key ในคำขอ No API Key provided in the request ບໍ່ພົບ API Key ໃນຄຳຂໍ |
| 401 | INVALID_API_KEY | API Key ไม่ถูกต้องหรือถูกระงับ API Key is invalid or has been disabled API Key ບໍ່ຖືກຕ້ອງ ຫຼື ຖືກລະງັບ |
| 401 | API_KEY_EXPIRED | API Key หมดอายุแล้ว — ติดต่อผู้ให้บริการเพื่อต่ออายุ API Key has expired — contact your provider to renew API Key ໝົດອາຍຸແລ້ວ — ຕິດຕໍ່ຜູ້ໃຫ້ບໍລິການ |
| 403 | INSUFFICIENT_PERMISSIONS | Key ของคุณไม่มีสิทธิ์เข้าถึง endpoint นี้ — ติดต่อผู้ให้บริการ Your key does not have permission for this endpoint — contact your provider Key ຂອງທ່ານບໍ່ມີສິດໃຊ້ endpoint ນີ້ |
| 403 | IP_NOT_ALLOWED | IP ของคุณไม่ได้รับอนุญาต — แจ้ง IP กับผู้ให้บริการ Your IP is not whitelisted — inform your provider of your IP IP ຂອງທ່ານບໍ່ໄດ້ຮັບອະນຸຍາດ |
| 429 | RATE_LIMIT_EXCEEDED | ส่งคำขอเร็วเกินไป — ลดความถี่การเรียก Too many requests — reduce your call frequency ສົ່ງຄຳຂໍໄວເກີນໄປ — ຫຼຸດຄວາມຖີ່ |
| 500 | SERVICE_UNAVAILABLE | ระบบไม่สามารถประมวลผลได้ชั่วคราว — ลองใหม่อีกครั้งหลังจากนี้ The service is temporarily unable to process your request — please retry shortly ລະບົບບໍ່ສາມາດປະມວນຜົນໄດ້ຊົ່ວຄາວ — ກະລຸນາລອງໃໝ່ |
รูปแบบ Response Response Format ຮູບແບບ Response
ทุก response ใช้ JSON envelope รูปแบบเดียวกัน:
All responses share a consistent JSON envelope:
ທຸກ response ໃຊ້ JSON envelope ຮູບແບບດຽວກັນ:
// ✅ Success
{
"success": true,
"lotto_date": "2026-04-18",
"lottery_id": "1",
"room_name": "Lotto Room",
"data": {
"3_up": "123",
"2_up": "23",
"2_down": "45"
},
"timestamp": "2026-04-14T18:30:00+07:00"
}
// ❌ Error
{
"success": false,
"error": {
"code": "DATE_REQUIRED",
"message": "date parameter is required"
},
"timestamp": "2026-04-14T18:30:00+07:00"
}
ตัวอย่างการใช้งาน Code Examples ຕົວຢ່າງການໃຊ້ງານ
YOUR_KEY ด้วย API Key ที่ได้รับจากผู้ให้บริการ และ API_BASE_URL ด้วย endpoint จริงYOUR_KEY with your actual API Key and API_BASE_URL with the endpoint from your provider.YOUR_KEY ດ້ວຍ API Key ຈິງ ແລະ API_BASE_URL ດ້ວຍ endpoint ຂອງທ່ານ1. ดึงผลหวยตามรหัสและวันที่ 1. Fetch results by lottery code and date 1. ດຶງຜົນຫວຍຕາມລະຫັດແລະວັນທີ
# ดึงผลหวยรัฐบาลไทยวันนี้ (ใช้รหัสหวย)
curl -H "X-API-KEY: YOUR_KEY" \
"https://API_BASE_URL/api/v1/lotteries/thai/results?date=2026-04-18"
# ดึงผลหวยโดยใช้ Lottery ID (Professional Standard)
curl -H "X-API-KEY: YOUR_KEY" \
"https://API_BASE_URL/api/v1/lotteries/15291/results?date=2026-04-18"
# ดึงข้อมูลรอบเจาะจงโดยใช้ Draw ID
curl -H "X-API-KEY: YOUR_KEY" \
"https://API_BASE_URL/api/v1/draws/492021001"
<?php
$apiKey = 'YOUR_KEY';
$baseUrl = 'https://API_BASE_URL';
$lottery = 'thai';
$date = '2026-04-18';
$ch = curl_init("{$baseUrl}/api/v1/lotteries/{$lottery}/results?date={$date}");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["X-API-KEY: {$apiKey}"],
CURLOPT_TIMEOUT => 10,
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode === 200) {
$data = json_decode($response, true);
foreach ($data['data'] as $result) {
echo $result['name'] . ': ' . $result['3_up'] . PHP_EOL;
}
} else {
$error = json_decode($response, true);
echo 'Error: ' . $error['error']['code'] . PHP_EOL;
}
?>
// Browser (Fetch API)
const API_KEY = 'YOUR_KEY';
const BASE_URL = 'https://API_BASE_URL';
async function getLotteryResults(lotteryCode, date) {
const res = await fetch(`${BASE_URL}/api/v1/lotteries/${lotteryCode}/results?date=${date}`, {
headers: { 'X-API-KEY': API_KEY }
});
const json = await res.json();
if (!json.success) throw new Error(json.error.code);
return json.data;
}
getLotteryResults('thai', '2026-04-18')
.then(data => data.forEach(r => console.log(r.name, r['3_up'])))
.catch(err => console.error('Error:', err.message));
import requests
API_KEY = 'YOUR_KEY'
BASE_URL = 'https://API_BASE_URL'
def get_results(lottery_code: str, date: str):
resp = requests.get(
f'{BASE_URL}/api/v1/lotteries/{lottery_code}/results',
params={'date': date},
headers={'X-API-KEY': API_KEY},
timeout=10
)
resp.raise_for_status()
data = resp.json()
if not data['success']:
raise Exception(data['error']['code'])
return data['data']
results = get_results('thai', '2026-04-18')
for r in results:
print(f"{r['name']}: {r.get('3_up', '-')}")
// Node.js (built-in fetch, v18+)
const API_KEY = 'YOUR_KEY';
const BASE_URL = 'https://API_BASE_URL';
async function getResults(lotteryCode, date) {
const url = `${BASE_URL}/api/v1/lotteries/${lotteryCode}/results?date=${date}`;
const res = await fetch(url, { headers: { 'X-API-KEY': API_KEY } });
const json = await res.json();
if (!json.success) throw new Error(json.error.code);
return json.data;
}
getResults('thai', '2026-04-18')
.then(data => data.forEach(r => console.log(r.name, r['3_up'])))
.catch(console.error);
2. ดึงเลขปิด/เลขอั้น/เลขเต็ม 2. Fetch closed/restricted/full numbers 2. ດຶງເລກປິດ/ເລກອັ້ນ/ເລກເຕັມ
# ── เลขปิดรับ (close) หวยไทยวันนี้ ──
curl -H "X-API-KEY: YOUR_KEY" \
"https://API_BASE_URL/api/v1/lotteries/thai/numbers?type=close&date=2026-04-18"
# ── เลขอั้นจ่ายครึ่ง (half) หวยฮานอย ──
curl -H "X-API-KEY: YOUR_KEY" \
"https://API_BASE_URL/api/v1/lotteries/hanoi/numbers?type=half&date=2026-04-18"
# ── เลขเต็มทั้งหมด (all) ──
curl -H "X-API-KEY: YOUR_KEY" \
"https://API_BASE_URL/api/v1/lotteries/thai/numbers?type=all&date=2026-04-18"
<?php
function getNumbers(string $apiKey, string $baseUrl, string $lottery, string $type, string $date): array {
$url = "{$baseUrl}/api/v1/lotteries/{$lottery}/numbers?type={$type}&date={$date}";
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["X-API-KEY: {$apiKey}"],
]);
$body = curl_exec($ch);
curl_close($ch);
$data = json_decode($body, true);
return $data['success'] ? $data['data'] : [];
}
// ดึงเลขปิดหวยไทย
$closed = getNumbers('YOUR_KEY', 'https://API_BASE_URL', 'thai', 'close', '2026-04-18');
foreach ($closed as $item) {
echo $item['name'] . ' — 3บน: ' . $item['close_3up'] . PHP_EOL;
}
?>
const API_KEY = 'YOUR_KEY';
const BASE_URL = 'https://API_BASE_URL';
async function getNumbers(lotteryCode, type, date) {
const url = `${BASE_URL}/api/v1/lotteries/${lotteryCode}/numbers?type=${type}&date=${date}`;
const res = await fetch(url, { headers: { 'X-API-KEY': API_KEY } });
const json = await res.json();
return json.success ? json.data : [];
}
// ดึงเลขปิดหวยฮานอย
getNumbers('hanoi', 'close', '2026-04-18').then(data => {
data.forEach(item => console.log(item.name, '3บน:', item.close_3up));
});
import requests
def get_numbers(api_key, base_url, lottery, type_param, date):
resp = requests.get(
f'{base_url}/api/v1/lotteries/{lottery}/numbers',
params={'type': type_param, 'date': date},
headers={'X-API-KEY': api_key},
timeout=10
)
data = resp.json()
return data['data'] if data['success'] else []
# ดึงเลขปิดหวยไทย
closed = get_numbers('YOUR_KEY', 'https://API_BASE_URL', 'thai', 'close', '2026-04-18')
for item in closed:
print(f"{item['name']} — 3บน: {item.get('close_3up', '-')}")
ประเภทหวยที่รองรับ (100+ ประเภท) Supported Lottery Types (100+ types) ປະເພດຫວຍທີ່ຮອງຮັບ (100+ ປະເພດ)
| ID | Name |
|---|---|
| 1 | รัฐบาลไทย |
| 48 | หวยออมสิน |
| 67 | หวย ธกส. |
| 73 | หวยไทย (ไม่อั้น) |
| ID | Name |
|---|---|
| 31 | หวยมาเลย์ (Magnum4D) |
| 75 | หวยมาเลเซีย |
| ID | Standard | ID | VIP |
|---|---|---|---|
| 2 | นิเคอิรอบเช้า | 18 | นิเคอิ VIP รอบเช้า |
| 3 | จีนรอบเช้า | 19 | จีน VIP รอบเช้า |
| 4 | ฮั่งเส็งรอบเช้า | 20 | ฮั่งเส็ง VIP รอบเช้า |
| 5 | ไต้หวัน | 21 | ไต้หวัน VIP |
| 6 | เกาหลี | 22 | เกาหลี VIP |
| 7 | นิเคอิรอบบ่าย | 23 | นิเคอิ VIP รอบบ่าย |
| 8 | จีนรอบบ่าย | 24 | จีน VIP รอบบ่าย |
| 9 | ฮั่งเส็งรอบบ่าย | 25 | ฮั่งเส็ง VIP รอบบ่าย |
| 10 | สิงคโปร์ | 26 | สิงคโปร์ VIP |
| 11 | หุ้นไทยเย็น | ||
| 12 | อินเดีย | ||
| 13 | อียิปต์ | ||
| 14 | รัสเซีย | 27 | รัสเซีย VIP |
| 15 | อังกฤษ | 28 | อังกฤษ VIP |
| 16 | เยอรมัน | 29 | เยอรมัน VIP |
| 17 | ดาวโจนส์ | 30 | ดาวโจนส์ VIP |
| ID | Name |
|---|---|
| 32 | ฮานอยพิเศษ |
| 33 | ฮานอย |
| 34 | ฮานอย VIP |
| 37 | ฮานอย HD |
| 38 | ฮานอยสตาร์ |
| 40 | ฮานอย TV |
| 43 | ฮานอยกาชาด |
| 46 | ฮานอย Extra |
| 49 | ฮานอยอาเซียน |
| 50 | ฮานอยสามัคคี |
| 51 | ฮานอยพัฒนา |
| 56 | ฮานอยเฉพาะกิจ |
| 60 | ฮานอยเช้าVIP |
| 64 | ฮานอยตรุษจีน |
| ID | Name |
|---|---|
| 35 | ลาวพัฒนา |
| 36 | ลาว TV |
| 39 | ลาว HD |
| 41 | ลาวสตาร์ |
| 42 | ลาวอาเซียน |
| 44 | ลาวสามัคคี |
| 45 | ลาว VIP |
| 47 | ลาวกาชาด |
| 52 | ลาวสามัคคี vip |
| 53 | ลาวสตาร์ vip |
| 54 | ลาวพิเศษ |
| 55 | ลาวดาว |
| 58 | ลาว Extra |
| 59 | ลาวเวียงจันทน์ |
| 65 | ลาวนครเวียง |
| 66 | ลาวพันธมิตร |
| 68 | ลาวประตูชัย |
| 69 | ลาวสันติภาพ |
| 70 | ประชาชนลาว |
| ID | Name |
|---|---|
| 61 | หวยเวียดนามพิเศษ |
| 62 | หวยเวียดนาม |
| 63 | หวยเวียดนามVIP |
| ID | Name |
|---|---|
| 57 | ดาวโจนส์ Star |
| 71 | ดาวโจนส์ Mid Night |
| 72 | ดาวโจนส์ Extra |
| 74 | ดาวโจนส์ TV |
ประเภทการเดิมพัน (Bet Types) Bet Types (Closed Numbers fields) ປະເພດການເດີມພັນ
| Field | ชื่อ Name ຊື່ | Description |
|---|---|---|
3_up | 3 ตัวบน | 3-digit top — exact match |
3_tod | 3 ตัวโต๊ด | 3-digit permutation |
2_up | 2 ตัวบน | 2-digit top — last 2 digits |
2_down | 2 ตัวล่าง | 2-digit bottom |
run_up | วิ่งบน | Single digit top runner |
run_down | วิ่งล่าง | Single digit bottom runner |