the-odds-api-rs
A Rust SDK for The Odds API, providing access to sports betting odds, scores, and related data from bookmakers worldwide.
Features
- Full coverage of The Odds API v4 endpoints
- Strongly-typed request parameters and responses
- Builder pattern for flexible request configuration
- Async/await support with
reqwest - API usage tracking via response headers
- Comprehensive error handling
Installation
Or add to your Cargo.toml:
[]
= "0.1"
= { = "1", = ["full"] }
Quick Start
use ;
async
API Endpoints
Sports
Get all available sports. Free - does not count against quota.
// Get in-season sports only
let sports = client.get_sports.await?;
// Get all sports including out-of-season
let all_sports = client.get_all_sports.await?;
Events
Get events for a sport without odds. Free - does not count against quota.
let events = client
.get_events
.commence_time_from
.commence_time_to
.send
.await?;
Options:
date_format(DateFormat)- Response date format (ISO or Unix)event_ids(ids)- Filter by specific event IDscommence_time_from(DateTime)- Filter events starting after this timecommence_time_to(DateTime)- Filter events starting before this time
Odds
Get odds for a sport. Quota cost: markets x regions
let odds = client
.get_odds
.regions
.markets
.odds_format
.bookmakers
.include_links
.send
.await?;
Options:
regions(&[Region])- Required. Bookmaker regions (Us, Us2, Uk, Au, Eu)markets(&[Market])- Market types (H2h, Spreads, Totals, Outrights)odds_format(OddsFormat)- Decimal or Americandate_format(DateFormat)- ISO or Unixevent_ids(ids)- Filter by event IDsbookmakers(keys)- Filter by bookmaker keyscommence_time_from/to(DateTime)- Time range filterinclude_links(bool)- Include deep links to bookmaker pagesinclude_sids(bool)- Include site IDsinclude_bet_limits(bool)- Include betting limits
Scores
Get live and completed scores. Quota cost: 1 (or 2 with days_from)
// Live/upcoming scores
let scores = client
.get_scores
.send
.await?;
// Include completed games from past 3 days
let scores = client
.get_scores
.days_from
.send
.await?;
Options:
days_from(u8)- Include games from past 1-3 days (costs 2 instead of 1)date_format(DateFormat)- ISO or Unixevent_ids(ids)- Filter by event IDs
Event Odds
Get detailed odds for a single event, including player props. Quota cost: markets x regions
let event_odds = client
.get_event_odds
.regions
.markets
.custom_market // Player props
.include_multipliers // DFS multipliers
.send
.await?;
Options:
regions(&[Region])- Required. Bookmaker regionsmarkets(&[Market])- Standard market typescustom_market(key)- Add player prop or alternate markets by keyodds_format(OddsFormat)- Decimal or Americanbookmakers(keys)- Filter by bookmaker keysinclude_links(bool)- Deep linksinclude_sids(bool)- Site IDsinclude_multipliers(bool)- DFS multipliers
Event Markets
Discover available markets for an event. Quota cost: 1
let markets = client
.get_event_markets
.regions
.send
.await?;
// Returns list of available market keys per bookmaker
for bookmaker in markets.data.bookmakers
Participants
Get all teams/players for a sport. Quota cost: 1
let participants = client
.get_participants
.await?;
Historical Odds
Get odds snapshot at a specific point in time. Quota cost: 10 x markets x regions
use ;
let historical = client
.get_historical_odds
.date
.regions
.markets
.send
.await?;
// Navigate through time
println!;
println!;
println!;
Historical Events
Get events that existed at a specific point in time. Quota cost: 1
let historical_events = client
.get_historical_events
.date
.send
.await?;
Historical Event Odds
Get historical odds for a specific event. Quota cost: markets x regions
let historical_event = client
.get_historical_event_odds
.date
.regions
.markets
.send
.await?;
Types
Regions
Markets
Odds Format
Configuration
Custom Client
use TheOddsApiClient;
// Use IPv6 endpoint
let client = builder
.use_ipv6
.build;
// Custom base URL
let client = builder
.base_url
.build;
// Custom reqwest client
let http_client = builder
.timeout
.build?;
let client = builder
.client
.build;
API Usage Tracking
Every response includes usage information from the API headers:
let response = client.get_odds
.regions
.send
.await?;
println!;
println!;
println!;
Error Handling
use Error;
match client.get_odds.regions.send.await
License
MIT