Skip to main content

the_odds_api/
lib.rs

1//! # The Odds API Rust SDK
2//!
3//! A comprehensive Rust SDK for [The Odds API](https://the-odds-api.com/), providing
4//! access to sports betting odds, scores, and related data from bookmakers worldwide.
5//!
6//! ## Features
7//!
8//! - Full coverage of The Odds API v4 endpoints
9//! - Strongly-typed request parameters and responses
10//! - Builder pattern for flexible request configuration
11//! - Async/await support with `reqwest`
12//! - API usage tracking via response headers
13//! - Comprehensive error handling
14//!
15//! ## Quick Start
16//!
17//! ```no_run
18//! use the_odds_api::{TheOddsApiClient, Region, Market};
19//!
20//! #[tokio::main]
21//! async fn main() -> the_odds_api::Result<()> {
22//!     // Create a client with your API key
23//!     let client = TheOddsApiClient::new("your-api-key");
24//!
25//!     // Get all in-season sports
26//!     let sports = client.get_sports().await?;
27//!     println!("Found {} sports", sports.data.len());
28//!
29//!     // Get NFL odds from US bookmakers
30//!     let odds = client
31//!         .get_odds("americanfootball_nfl")
32//!         .regions(&[Region::Us])
33//!         .markets(&[Market::H2h, Market::Spreads])
34//!         .send()
35//!         .await?;
36//!
37//!     // Check API usage
38//!     println!("Requests remaining: {:?}", odds.usage.requests_remaining);
39//!
40//!     Ok(())
41//! }
42//! ```
43//!
44//! ## Endpoints
45//!
46//! | Endpoint | Method | Quota Cost |
47//! |----------|--------|------------|
48//! | Sports | `get_sports()` | Free |
49//! | Events | `get_events(sport)` | Free |
50//! | Odds | `get_odds(sport)` | markets × regions |
51//! | Scores | `get_scores(sport)` | 1 (or 2 with `days_from`) |
52//! | Event Odds | `get_event_odds(sport, event_id)` | markets × regions |
53//! | Event Markets | `get_event_markets(sport, event_id)` | 1 |
54//! | Participants | `get_participants(sport)` | 1 |
55//! | Historical Odds | `get_historical_odds(sport)` | 10 × markets × regions |
56//! | Historical Events | `get_historical_events(sport)` | 1 |
57//! | Historical Event Odds | `get_historical_event_odds(sport, event_id)` | markets × regions |
58//!
59//! ## Configuration
60//!
61//! Use the builder pattern for advanced configuration:
62//!
63//! ```no_run
64//! use the_odds_api::TheOddsApiClient;
65//!
66//! let client = TheOddsApiClient::builder("your-api-key")
67//!     .use_ipv6()  // Use IPv6 endpoint
68//!     .build();
69//! ```
70
71mod client;
72mod error;
73mod models;
74mod types;
75
76pub use client::*;
77pub use error::{Error, Result};
78pub use models::*;
79pub use types::*;