Skip to main content

Crate taiwan_lottery

Crate taiwan_lottery 

Source
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 D423F dataset) - 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§

download

Structs§

BonusDrawNumbers
Draw numbers with an optional bonus number.
DrawNumbers
Base structure shared by draw and history number models.
HistoryDrawItem
A single lottery draw result from historical data.
HistoryDrawPage
Paginated result set from a historical lottery draw query.
HistoryDrawQuery
Query parameters for historical lottery draw searches.
LotteryGameDateQueryRange
Queryable date range for a game in YYYY-MM-DD format.
LotteryGameMetadata
Static metadata for rendering lottery game information in UI layers.
LotteryGameNumberRule
One number selection segment for a lottery game.
LotteryGameQueryRange
Queryable month range for a game in YYYY-MM format.
RemoteQueryParamSupport
Remote query parameter support for one lottery game endpoint.
SortedDrawNumbers
Draw numbers with an optional sorted view.

Enums§

DownloadError
Error types that can occur during download, parsing, or API operations.
LotteryDisplayLanguage
Supported display-name languages.
LotteryGame
Supported lottery games for historical draw queries and random draws.

Functions§

download_history_drawDeprecated
Downloads history draw files from FinancialPlanning OpenData (D423F).
download_history_draw_from_taiwan_lotteryDeprecated
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§

BingoBingoNumbers
Bingo Bingo draw numbers with super number.
Daily539Numbers
Daily 539 draw numbers with bonus.
DrawResult
Draw result for a random draw outcome.
HistoryGameDeprecated
HistoryGameMetadataDeprecated
HistoryGameNumberRuleDeprecated
Lotto3DNumbers
Lotto 3D draw numbers without bonus.
Lotto4DNumbers
Lotto 4D draw numbers without bonus.
Lotto38M6Numbers
Lotto 38/6 draw numbers without bonus.
Lotto39M5Numbers
Lotto 39/5 draw numbers without bonus.
Lotto49M6Numbers
Lotto 49/6 draw numbers without bonus.
Lotto638Numbers
Lotto 638 draw numbers with bonus.
Lotto649Numbers
Lotto 649 draw numbers with bonus.
Lotto740Numbers
Lotto 740 draw numbers with bonus.
Lotto1224Numbers
Lotto 1224 draw numbers without bonus.
SuperLotto638Numbers
SuperLotto 638 draw numbers with bonus.
TicTacToeNumbers
Tic-Tac-Toe draw numbers without bonus.