#nhl #openapi #reqwest #hyper #generated-client #api

nhl-stats

NHL Stats API client for Rust created using openapi-generator

3 releases

Uses old Rust 2015

0.1.2 Aug 9, 2019
0.1.1 Aug 8, 2019
0.1.0 Aug 7, 2019

#13 in #generated-client

MIT license

255KB
5K SLoC

NHL Stats API Client for Rust

Crates.io

Rust client for using the NHL Stats API.

Both reqwest and hyper clients are avaialable by default, and behind feature flags sync and async, respectively.

Known Issues

  • The openapi spec being used isn't perfect, neither is the generator for Rust, so expect lots of problems and things that are just wrong. Please open issues so I can fix.
  • Modifiers defined in the openapi spec are currently required within applicable ApiClient methods, only some allow passing blank values. Eventually I'll try to convert these over to Options for better usability.

Example

use nhl_stats::parameters::*;
use nhl_stats::sync::configuration::Configuration;
use nhl_stats::sync::*;
use std::rc::Rc;

fn main() -> Result<(), Error> {
    let config = Rc::from(Configuration::default());
    let teams_client = TeamsApiClient::new(config);

    // First parameter is expand=, use applicable enum from parameters module
    // Second parameter is season (both years included)
    let expand = EnumExpandTeams::TeamRoster;
    let teams = teams_client.get_teams(expand, "20192020")?;
    for team in teams.teams.unwrap() {
        println!("{:#?}", team);
    }
    Ok(())
}

OpenAPI Generator

This API client was generated by the OpenAPI Generator project. By using the openapi-spec from a remote server, you can easily generate an API client.

Documentation for API Endpoints

All URIs are relative to https://statsapi.web.nhl.com/api/v1

Class Method HTTP request Description
ConferencesApi get_conference Get /conferences/{id} Get an NHL conference.
ConferencesApi get_conferences Get /conferences Get all current NHL conferences.
DivisionsApi get_division Get /divisions/{id} Get an NHL division.
DivisionsApi get_divisions Get /divisions Get all current NHL divisions.
DraftApi get_draft Get /draft Get round-by-round data for current year's NHL Entry Draft.
DraftApi get_draft_by_year Get /draft/{year} Get round-by-round data for a specific year's NHL Entry Draft.
DraftApi get_draft_prospect Get /draft/prospects/{id} Get an NHL Entry Draft prospect.
DraftApi get_draft_prospects Get /draft/prospects Get all NHL Entry Draft prospects.
GamesApi get_game Get /game/{id}/feed/live Get all available data for an NHL game.
GamesApi get_game_boxscore Get /game/{id}/boxscore Get the boxscore for an NHL game.
GamesApi get_game_content Get /game/{id}/content Get editorials, video replays and photo highlights for an NHL game.
GamesApi get_game_diff Get /game/{id}/feed/live/diffPatch Get all available data for an NHL game after a specific time.
PlayersApi get_player Get /people/{id} Get an NHL player.
PlayersApi get_player_stats Get /people/{id}/stats Get specific statistics for an NHL player.
ScheduleApi get_schedule Get /schedule Get the NHL game schedule.
StandingsApi get_standing_types Get /standingsTypes Get all available NHL standing types.
StandingsApi get_standings Get /standings Get NHL division standings.
StandingsApi get_standings_by_type Get /standings/{type} Get NHL standings for a specific standing type.
StatsApi get_stat_types Get /statTypes Get all available NHL statistic types.
TeamsApi get_team Get /teams/{id} Get an NHL team.
TeamsApi get_team_roster Get /teams/{id}/roster Get an NHL team's roster.
TeamsApi get_team_stats Get /teams/{id}/stats Get all statistics for an NHL team.
TeamsApi get_teams Get /teams Get all NHL teams.

Documentation For Models

To get access to the crate's generated documentation, use:

cargo doc --open

Author

Dependencies

~1.7–6MB
~141K SLoC