pub struct TheOddsApiClient { /* private fields */ }Expand description
The main client for interacting with The Odds API.
Implementations§
Source§impl TheOddsApiClient
impl TheOddsApiClient
Sourcepub fn builder(api_key: impl Into<String>) -> TheOddsApiClientBuilder
pub fn builder(api_key: impl Into<String>) -> TheOddsApiClientBuilder
Create a builder for more advanced configuration.
Sourcepub async fn get_sports(&self) -> Result<Response<Vec<Sport>>>
pub async fn get_sports(&self) -> Result<Response<Vec<Sport>>>
Get all in-season sports.
This endpoint does not count against your usage quota.
§Example
let client = the_odds_api::TheOddsApiClient::new("your-api-key");
let sports = client.get_sports().await?;
for sport in sports.data {
println!("{}: {}", sport.key, sport.title);
}Sourcepub async fn get_all_sports(&self) -> Result<Response<Vec<Sport>>>
pub async fn get_all_sports(&self) -> Result<Response<Vec<Sport>>>
Get all sports, including out-of-season ones.
This endpoint does not count against your usage quota.
Sourcepub fn get_events(&self, sport: impl Into<String>) -> GetEventsRequest<'_>
pub fn get_events(&self, sport: impl Into<String>) -> GetEventsRequest<'_>
Get events for a sport without odds.
This endpoint does not count against your usage quota.
Sourcepub fn get_odds(&self, sport: impl Into<String>) -> GetOddsRequest<'_>
pub fn get_odds(&self, sport: impl Into<String>) -> GetOddsRequest<'_>
Sourcepub fn get_upcoming_odds(&self) -> GetOddsRequest<'_>
pub fn get_upcoming_odds(&self) -> GetOddsRequest<'_>
Get odds for upcoming events across all sports.
Sourcepub fn get_scores(&self, sport: impl Into<String>) -> GetScoresRequest<'_>
pub fn get_scores(&self, sport: impl Into<String>) -> GetScoresRequest<'_>
Sourcepub fn get_event_odds(
&self,
sport: impl Into<String>,
event_id: impl Into<String>,
) -> GetEventOddsRequest<'_>
pub fn get_event_odds( &self, sport: impl Into<String>, event_id: impl Into<String>, ) -> GetEventOddsRequest<'_>
Get detailed odds for a single event.
This endpoint supports all available markets including player props.
Sourcepub fn get_event_markets(
&self,
sport: impl Into<String>,
event_id: impl Into<String>,
) -> GetEventMarketsRequest<'_>
pub fn get_event_markets( &self, sport: impl Into<String>, event_id: impl Into<String>, ) -> GetEventMarketsRequest<'_>
Sourcepub async fn get_participants(
&self,
sport: impl Into<String>,
) -> Result<Response<Vec<Participant>>>
pub async fn get_participants( &self, sport: impl Into<String>, ) -> Result<Response<Vec<Participant>>>
Sourcepub fn get_historical_odds(
&self,
sport: impl Into<String>,
) -> GetHistoricalOddsRequest<'_>
pub fn get_historical_odds( &self, sport: impl Into<String>, ) -> GetHistoricalOddsRequest<'_>
Get historical odds for a sport at a specific timestamp.
§Quota Cost
10 × number of markets × number of regions
Sourcepub fn get_historical_events(
&self,
sport: impl Into<String>,
) -> GetHistoricalEventsRequest<'_>
pub fn get_historical_events( &self, sport: impl Into<String>, ) -> GetHistoricalEventsRequest<'_>
Sourcepub fn get_historical_event_odds(
&self,
sport: impl Into<String>,
event_id: impl Into<String>,
) -> GetHistoricalEventOddsRequest<'_>
pub fn get_historical_event_odds( &self, sport: impl Into<String>, event_id: impl Into<String>, ) -> GetHistoricalEventOddsRequest<'_>
Get historical odds for a single event at a specific timestamp.
Trait Implementations§
Source§impl Clone for TheOddsApiClient
impl Clone for TheOddsApiClient
Source§fn clone(&self) -> TheOddsApiClient
fn clone(&self) -> TheOddsApiClient
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TheOddsApiClient
impl !RefUnwindSafe for TheOddsApiClient
impl Send for TheOddsApiClient
impl Sync for TheOddsApiClient
impl Unpin for TheOddsApiClient
impl UnsafeUnpin for TheOddsApiClient
impl !UnwindSafe for TheOddsApiClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more