dooddyfire/thai-lotto-api-huay
ProductivityA self-hosted Thai government lottery results API plus client examples for a paid multi-category lottery API.
What this is
This repository is a developer guide and code collection for retrieving Thai lottery results as JSON. It covers two distinct things: a free, self-hosted scraper API for Thai government lottery results that runs on your own machine, and client examples for the commercial SweetieSS API (SupapongAI) that serves several lottery categories — government, Hanoi, Laos, Yeekee, stock lottery and Thai evening — behind an API key.
The free part is the only component you can run without an account. It scrapes Sanook's government lottery page and returns four core result groups: first prize, two front three-digit prizes, two back three-digit prizes and the last two digits, as strings so leading zeros survive. Results are cached for five minutes. The paid client examples demonstrate calling /lotto/huay, /lotto, /lotto/yeekee, /lotto/stock and /lotto/thaiyen with an X-API-KEY header.
It is aimed at developers building result pages, notification bots or apps, not at people who just want to look up numbers.
Quick start with the free scraper
Requires Python 3.10 or newer. From the repository root:
python -m pip install -r requirements-free.txt
python -m free_api.server
Then, in another terminal:
curl --fail http://127.0.0.1:8080/latest
curl --fail http://127.0.0.1:8080/lotto/16112569
The second path takes a draw date formatted as DDMMBBBB using the Buddhist year. The response includes first, front_three, back_three, back_two, plus draw_date, source, fetched_at and cached. See the free API guide and the server source.
Quick start with the paid API
Register for a key in the lotto category through the provider's lottery API page, then export it locally:
export LOTTO_API_KEY='YOUR_API_KEY'
On PowerShell use $env:LOTTO_API_KEY = 'YOUR_API_KEY'. With dependencies installed from requirements.txt, run:
python examples/lotto.py --category hanoi
node examples/lotto.mjs government
Categories are all, government, hanoi, laos, yeekee, stock and thaiyen; the Python script also accepts --limit and --date. The Python example, Node.js example and endpoint reference hold the details. The Node.js script relies on fetch, available in Node.js 22 and later.
Constraints
The free scraper depends on the current HTML of the Sanook page; it was checked against live pages on November 30, 2026, but the source page can change. It does not return adjacent prizes or prizes 2–5, and no public hosted free endpoint is offered — you host it yourself, which may cost hosting. The paid client examples have not been verified against a real API key, so quotas, refresh frequency and historical coverage should be confirmed with the provider. Errors documented include 403 for an invalid or expired key, 429 for exceeded quota and 503 when the service is unavailable. Keep keys server-side rather than in browser JavaScript. No license is declared in the repository.
HotRepo's take
The project appears on HotRepo's new-project list on December 1, 2026, adding 18 stars in the observed window, with fork count roughly equal to stars. There is no best daily rank recorded, and the two star samples in the collected curve show no change, so the data supports only that single-day entry, not a trend. The repository's substance is split: the free scraper is a small, runnable component with a documented scope of four prize groups, while the rest of the README is a guide to a paid external service. Developers who need only government results can usefully start with the self-hosted scraper; anyone needing Hanoi, Laos, Yeekee or stock categories is really evaluating the provider's service, not this repository.
Written by AI from the project's public information and HotRepo's records, updated . The project's own docs are the source of truth.