Expand description
Taiwan Lottery library providing download, query, and random draw capabilities.
This library offers both Rust and C APIs for:
- Download: Fetch lottery datasets from Taiwan’s open data sources
- Query: Search historical lottery results by period, month, or month range
- Draw: Generate random lottery draws for supported games
§Overview
The library uses two primary data sources:
- FinancialPlanning OpenData (via
D423Fdataset) - Primary source for historical draws - Taiwan Lottery API - Fallback source for recent results
§Quick Start
§Download historical data
ⓘ
use taiwan_lottery::download_history_draw;
download_history_draw("./data")?;§Query results
ⓘ
use taiwan_lottery::{query_history_draw, HistoryDrawQuery, LotteryGame};
let query = HistoryDrawQuery::by_month("2023-12");
let results = query_history_draw("./data", LotteryGame::Lotto649, query)?;§Generate random draw
ⓘ
use taiwan_lottery::{draw_by_game, LotteryGame};
let result = draw_by_game(LotteryGame::Lotto649);Re-exports§
pub use download::build_csv_url;pub use download::download_all;pub use download::download_api_doc;pub use download::download_dataset;pub use download::parse_codes_from_api_docs;
Modules§
Structs§
- Bonus
Draw Numbers - Draw numbers with an optional bonus number.
- Draw
Numbers - Base structure shared by draw and history number models.
- History
Draw Item - A single lottery draw result from historical data.
- History
Draw Page - Paginated result set from a historical lottery draw query.
- History
Draw Query - Query parameters for historical lottery draw searches.
- Lottery
Game Date Query Range - Queryable date range for a game in
YYYY-MM-DDformat. - Lottery
Game Metadata - Static metadata for rendering lottery game information in UI layers.
- Lottery
Game Number Rule - One number selection segment for a lottery game.
- Lottery
Game Query Range - Queryable month range for a game in
YYYY-MMformat. - Remote
Query Param Support - Remote query parameter support for one lottery game endpoint.
- Sorted
Draw Numbers - Draw numbers with an optional sorted view.
Enums§
- Download
Error - Error types that can occur during download, parsing, or API operations.
- Lottery
Display Language - Supported display-name languages.
- Lottery
Game - Supported lottery games for historical draw queries and random draws.
Functions§
- download_
history_ draw Deprecated - Downloads history draw files from FinancialPlanning OpenData (
D423F). - download_
history_ draw_ from_ taiwan_ lottery Deprecated - Downloads history draw files from Taiwan Lottery yearly ZIP API.
- draw_
by_ game - Perform a random draw based on the game type and return the drawn numbers.
- query_
history_ draw - Query historical lottery draw results from locally downloaded data.
- query_
history_ draw_ from_ taiwan_ lottery - Query historical lottery draw results directly from Taiwan Lottery API.
Type Aliases§
- Bingo
Bingo Numbers - Bingo Bingo draw numbers with super number.
- Daily539
Numbers - Daily 539 draw numbers with bonus.
- Draw
Result - Draw result for a random draw outcome.
- History
Game Deprecated - History
Game Metadata Deprecated - History
Game Number Rule Deprecated - Lotto3D
Numbers - Lotto 3D draw numbers without bonus.
- Lotto4D
Numbers - Lotto 4D draw numbers without bonus.
- Lotto38
M6Numbers - Lotto 38/6 draw numbers without bonus.
- Lotto39
M5Numbers - Lotto 39/5 draw numbers without bonus.
- Lotto49
M6Numbers - Lotto 49/6 draw numbers without bonus.
- Lotto638
Numbers - Lotto 638 draw numbers with bonus.
- Lotto649
Numbers - Lotto 649 draw numbers with bonus.
- Lotto740
Numbers - Lotto 740 draw numbers with bonus.
- Lotto1224
Numbers - Lotto 1224 draw numbers without bonus.
- Super
Lotto638 Numbers - SuperLotto 638 draw numbers with bonus.
- TicTac
ToeNumbers - Tic-Tac-Toe draw numbers without bonus.