=============== LIBRARY RULES =============== From library maintainers: - Always import from nhlpy: from nhlpy import NHLClient - Game IDs format: YYYYTTNNNN (e.g., 2023020280 = 2023 season, regular season game 280) - Season format: YYYYYYYY (e.g., 20242025) - Method names have no get_ prefix (e.g., boxscore() not get_boxscore()) - Team abbreviations are 3 letters (e.g., BUF, TOR, EDM) - Many name fields use localized format: {"default": "English", "fr": "French"} ### Install nhl-api-py Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Install the package using pip or uv. ```bash pip install nhl-api-py ``` ```bash # - OR - uv add nhl-api-py ``` -------------------------------- ### Install Development Dependencies with Poetry Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Installs project dependencies, including development tools, using Poetry. This command ensures all necessary packages for development are available. ```bash $ poetry install --with dev ``` -------------------------------- ### Find Division Leaders Example Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Example demonstrating how to find division leaders from the current league standings by iterating through the standings data and comparing points. ```python from nhlpy import NHLClient client = NHLClient() # Get current standings standings = client.standings.league_standings() # Find division leaders divisions = {} for team in standings['standings']: division = team['divisionName'] if division not in divisions: divisions[division] = team elif team['points'] > divisions[division]['points']: divisions[division] = team # Display division leaders for division, team in divisions.items(): print(f"{division}: {team['teamName']['default']} ({team['points']} pts)") ``` -------------------------------- ### Get Daily Schedule - Python Source: https://github.com/coreyjs/nhl-api-py/blob/main/docs/schedule.md Retrieve the NHL game schedule for a specific date. Defaults to today's date if omitted. The response includes game details, team information, and start times. ```python from nhlpy import NHLClient client = NHLClient() # Get today's schedule today = client.schedule.daily_schedule() # Get schedule for a specific date schedule = client.schedule.daily_schedule(date="2024-01-15") print(f"Games on {schedule['date']}: {schedule['numberOfGames']}") for game in schedule.get("games", []): away = game["awayTeam"] home = game["homeTeam"] print(f"{away['abbrev']} @ {home['abbrev']} - {game['startTimeUTC']}") ``` -------------------------------- ### Get Season Information Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Fetches season-specific rules and information. Requires an initialized NHLClient. ```python # Get season-specific rules and information season_info = client.misc.season_specific_rules_and_info() ``` -------------------------------- ### Get Historical Season Rules with season_specific_rules_and_info Source: https://github.com/coreyjs/nhl-api-py/blob/main/docs/misc.md Fetches configuration and rules for all historical NHL seasons. Includes game counts, date ranges, and active rules for each season. Requires nhlpy to be installed. ```python from nhlpy import NHLClient client = NHLClient() seasons = client.misc.season_specific_rules_and_info() for season in seasons: ties = "Yes" if season["tiesInUse"] else "No" print(f"{season['formattedSeasonId']}: {season['numberOfGames']} games, Ties: {ties}") ``` -------------------------------- ### Get Goalie Statistics Summary Source: https://github.com/coreyjs/nhl-api-py/blob/main/docs/stats.md Retrieve default summary statistics for goalies starting from a specified season. Ensure the NHLClient is initialized before making the call. ```python from nhlpy import NHLClient client = NHLClient() # Default summary stats goalies = client.stats.goalie_stats_summary( start_season="20242025" ) ``` -------------------------------- ### Get API Configuration Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Retrieves available filter options and general API configuration settings. ```APIDOC ## Get API Configuration ### Description Fetches available filter options and API configuration details. ### Method `client.misc.config()` ### Parameters None ### Request Example ```python from nhlpy import NHLClient client = NHLClient() config = client.misc.config() ``` ### Response #### Success Response (200) - **config**: A dictionary containing various configuration settings and available filter options for the API. ``` -------------------------------- ### Example: Finding Top Scorers Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Demonstrates how to retrieve current season skater statistics and display the top 5 scorers. ```APIDOC ### Example: Finding Top Scorers ```python from nhlpy import NHLClient client = NHLClient() # Get current season skater stats stats = client.stats.skater_stats_summary( start_season="20242025", end_season="20242025" ) # Show top 5 scorers for i, player in enumerate(stats[:5]): print(f"{i+1}. {player['skaterFullName']}: {player['points']} points") # Expected Output: # 1. Nikita Kucherov: 121 points # 2. Nathan MacKinnon: 116 points # 3. Leon Draisaitl: 106 points # 4. David Pastrnak: 106 points # 5. Mitch Marner: 102 points ``` ``` -------------------------------- ### Get Season Information Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Retrieves season-specific rules and information. ```APIDOC ## Get Season Information ### Description Fetches season-specific rules and information. ### Method `client.misc.season_specific_rules_and_info()` ### Parameters None ### Request Example ```python from nhlpy import NHLClient client = NHLClient() season_info = client.misc.season_specific_rules_and_info() ``` ### Response #### Success Response (200) - **season_info**: Information regarding rules and details specific to NHL seasons. ``` -------------------------------- ### Get Play-by-Play Data Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Retrieve detailed play-by-play data for a specific game using its game ID. ```python # Get detailed play-by-play data play_by_play = client.game_center.play_by_play(game_id="2023020280") ``` -------------------------------- ### Get Draft Information Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Retrieves draft years and round information. Requires an initialized NHLClient. ```python # Get draft years and round information draft_info = client.misc.draft_year_and_rounds() ``` -------------------------------- ### Get NHL Glossary Definitions Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Retrieves definitions for NHL terms and statistics. Requires an initialized NHLClient. ```python # Get definitions of NHL terms and statistics glossary = client.misc.glossary() ``` -------------------------------- ### Get Team Summary Statistics Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Retrieves team statistics for a specified season range. Both start and end seasons are required. ```python # Get team stats for a season team_stats = client.stats.team_summary( start_season="20232024", end_season="20232024" ) ``` -------------------------------- ### Get Playoff Bracket Data Source: https://github.com/coreyjs/nhl-api-py/blob/main/docs/schedule.md Use this snippet to retrieve and print playoff series information for a given year. Ensure the nhlpy library is installed. ```python from nhlpy import NHLClient client = NHLClient() bracket = client.schedule.playoff_bracket(year="2024") for series in bracket["series"]: top = series["topSeedTeam"] bottom = series["bottomSeedTeam"] print(f"Round {series['playoffRound']}: " f"({series['topSeedRank']}) {top['abbrev']} {series['topSeedWins']} - " f"{series['bottomSeedWins']} {bottom['abbrev']} ({series['bottomSeedRank']})") ``` -------------------------------- ### Find Specific Team Information and Roster Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Example demonstrating how to initialize the client, fetch all current teams, find a specific team by abbreviation, and then retrieve that team's roster for a given season. Prints team name, division, franchise ID, and roster counts. ```python from nhlpy import NHLClient client = NHLClient() # Get all current teams teams = client.teams.teams() # Find a specific team for team in teams: if team['abbr'] == 'TOR': print(f"Team: {team['name']}") print(f"Division: {team['division']['name']}") print(f"Franchise ID: {team['franchise_id']}") break # Get that team's roster roster = client.teams.team_roster(team_abbr="TOR", season="20242025") print(f"Forwards: {len(roster['forwards'])}") print(f"Defensemen: {len(roster['defensemen'])}") print(f"Goalies: {len(roster['goalies'])}") ``` -------------------------------- ### Get Player Career Stats Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Retrieves a player's complete career statistics using their player ID. Example uses Connor McDavid's ID. ```python # Get a player's full career statistics career_stats = client.stats.player_career_stats(player_id="8478402") # Connor McDavid ``` -------------------------------- ### Build and Publish to Test PyPI Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Builds the project package and publishes it to the TestPyPI repository. This is useful for testing the distribution process before releasing to the main PyPI. ```bash poetry build poetry publish -r test-pypi ``` -------------------------------- ### Get Hockey Nations with countries Source: https://github.com/coreyjs/nhl-api-py/blob/main/docs/misc.md Retrieves a list of countries associated with NHL hockey. Useful for filtering players by nationality or building country selector UIs. Requires nhlpy to be installed. ```python from nhlpy import NHLClient client = NHLClient() countries = client.misc.countries() for country in countries: if country["hasPlayerStats"]: print(f"{country['countryName']} ({country['id']})") ``` -------------------------------- ### Find Tonight's NHL Games Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Example demonstrating how to initialize the client and retrieve daily game schedules, defaulting to today's games if no date is specified. Shows fetching games for a specific date. ```python from nhlpy import NHLClient client = NHLClient() # Get games by date. Leave date blank to get today's games games = client.schedule.daily_schedule(date="2024-10-08") ``` -------------------------------- ### Game Analysis Example Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Demonstrates how to fetch game data like boxscore and play-by-play, and then analyze it to display final scores and shots by period. ```APIDOC ## Get Boxscore and Play-by-Play Data ### Description Fetches the complete boxscore and play-by-play data for a given game ID. ### Method `client.game_center.boxscore(game_id)` `client.game_center.play_by_play(game_id)` ### Parameters #### Path Parameters - **game_id** (string) - Required - The unique identifier for the game. ### Request Example ```python from nhlpy import NHLClient client = NHLClient() game_id = "2023020280" boxscore = client.game_center.boxscore(game_id) play_by_play = client.game_center.play_by_play(game_id) ``` ### Response #### Success Response (200) - **boxscore**: Dictionary containing detailed boxscore information. - **play_by_play**: Dictionary containing play-by-play events. ### Example Usage ```python away_team = boxscore['awayTeam']['abbrev'] home_team = boxscore['homeTeam']['abbrev'] away_score = boxscore['awayTeam']['score'] home_score = boxscore['homeTeam']['score'] print(f"Final: {away_team} {away_score} - {home_team} {home_score}") shots_by_period = {} for play in play_by_play.get('plays', []): if play['typeDescKey'] == 'shot-on-goal': period = play['periodDescriptor'].get('number', 'Unknown') if period not in shots_by_period: shots_by_period[period] = 0 shots_by_period[period] += 1 for period, shots in shots_by_period.items(): print(f"Period {period}: {shots} shots") ``` ``` -------------------------------- ### Fetch Skater Stats with QueryBuilder Source: https://github.com/coreyjs/nhl-api-py/blob/main/docs/stats.md This example demonstrates how to use the QueryBuilder to create a complex filter for skater statistics and then retrieve the data using the `skater_stats_with_query_context` method. It shows how to specify report types, apply filters like game type, draft year, season range, and player position, and aggregate results. ```APIDOC ## Fetch Skater Stats with QueryBuilder ### Description Retrieves advanced skater statistics using a pre-built `QueryContext`. This method allows for detailed filtering and aggregation of player data across various report types. ### Method `client.stats.skater_stats_with_query_context( report_type: str, query_context: QueryContext, aggregate: bool = False, sort_expr: list[dict] = None, start: int = 0, limit: int = 25 )` ### Parameters - `report_type` (str, required): Specifies the type of statistical report to retrieve. Available options include: - `"summary"`: General stats overview - `"bios"`: Biographical information - `"faceoffpercentages"`: Faceoff statistics - `"faceoffwins"`: Faceoff win counts - `"goalsForAgainst"`: Goals for/against breakdown - `"realtime"`: Real-time tracking stats - `"penalties"`: Penalty statistics - `"penaltykill"`: Penalty kill stats - `"penaltyShots"`: Penalty shot stats - `"powerplay"`: Power play stats - `"puckPossessions"`: Puck possession metrics - `"summaryshooting"`: Shooting summary - `"percentages"`: Percentage-based stats - `"scoringRates"`: Scoring rate stats - `"scoringpergame"`: Per-game scoring - `"shootout"`: Shootout stats - `"shottype"`: Shot type breakdown - `"timeonice"`: Time on ice breakdown - `query_context` (QueryContext, required): A `QueryContext` object built using `QueryBuilder` with one or more filters applied. - `aggregate` (bool, optional, default: `False`): If `True`, combines multiple seasons per player into a single aggregated result. - `sort_expr` (list[dict], optional): A list of dictionaries specifying custom sorting criteria. - `start` (int, optional, default: `0`): The offset for pagination, determining the starting point of the results. - `limit` (int, optional, default: `25`): The maximum number of results to return per page. ### Returns A dictionary containing a `"data"` key, which holds a list of skater stat dictionaries. The specific fields within these dictionaries vary based on the `report_type` requested. Common fields across all report types include `playerId`, `skaterFullName`, `teamAbbrevs`, `seasonId`, and `gamesPlayed`. ### Request Example ```python from nhlpy import NHLClient from nhlpy.api.query.builder import QueryBuilder, QueryContext from nhlpy.api.query.filters.game_type import GameTypeQuery from nhlpy.api.query.filters.season import SeasonQuery from nhlpy.api.query.filters.draft import DraftQuery from nhlpy.api.query.filters.position import PositionQuery, PositionTypes client = NHLClient() filters = [ GameTypeQuery(game_type="2"), DraftQuery(year="2020", draft_round="2"), SeasonQuery(season_start="20202021", season_end="20242025"), PositionQuery(position=PositionTypes.ALL_FORWARDS), ] query_builder = QueryBuilder() query_context: QueryContext = query_builder.build(filters=filters) data = client.stats.skater_stats_with_query_context( report_type="summary", query_context=query_context, aggregate=True ) ``` ### Response Example (Summary Report) ```json { "data": [ { "playerId": 8476454, "skaterFullName": "Sidney Crosby", "teamAbbrevs": "PIT", "seasonId": 20232024, "gamesPlayed": 79, "goals": 42, "assists": 77, "points": 119, "shots": 355 } // ... more player stats ] } ``` ``` -------------------------------- ### Get Advanced Goalie Statistics for a Franchise Source: https://github.com/coreyjs/nhl-api-py/blob/main/docs/stats.md Fetch advanced goalie statistics for a specific franchise, starting from a given season. This allows for in-depth analysis of goalie performance within a particular team's history. ```python from nhlpy import NHLClient client = NHLClient() # Advanced goalie stats for a specific franchise goalies = client.stats.goalie_stats_summary( start_season="20242025", stats_type="advanced", franchise_id="10" ) ``` -------------------------------- ### Find Top Scorers Example Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Demonstrates how to fetch current season skater stats and display the top 5 scorers. Requires initializing NHLClient and specifying the season. ```python from nhlpy import NHLClient client = NHLClient() # Get current season skater stats stats = client.stats.skater_stats_summary( start_season="20242025", end_season="20242025" ) # Show top 5 scorers for i, player in enumerate(stats[:5]): print(f"{i+1}. {player['skaterFullName']}: {player['points']} points") ``` -------------------------------- ### Configure NHL API Client Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Instantiate the NHLClient with default or custom configurations, including debug logging, request timeout, and SSL verification. ```python from nhlpy import NHLClient # Default configuration client = NHLClient() # With debug logging client = NHLClient(debug=True) # All available configurations client = NHLClient( debug=True, # Enable debug logging timeout=30, # Request timeout in seconds ssl_verify=True, # SSL certificate verification follow_redirects=True # Follow HTTP redirects ) ``` -------------------------------- ### Get Skater EDGE Profile Source: https://github.com/coreyjs/nhl-api-py/blob/main/docs/edge.md Retrieves a comprehensive EDGE tracking profile for a skater. Use this to get detailed skating and shooting analytics, including league comparisons. Defaults to the current season if no season is specified. ```python from nhlpy import NHLClient client = NHLClient() # Current season (uses /now endpoint) detail = client.edge.skater_detail(player_id="8478402") # Specific season and game type detail = client.edge.skater_detail( player_id="8478402", season="20242025", game_type=2 ) print(f"Top shot speed: {detail['topShotSpeed']['imperial']} mph") print(f"Max skating speed: {detail['skatingSpeed']['speedMax']['imperial']} mph") ``` -------------------------------- ### Get API Configuration Data Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Fetches available filter options and API configuration details. Requires an initialized NHLClient. ```python # Get available filter options and API configuration config = client.misc.config() ``` -------------------------------- ### Get Daily Scores Source: https://github.com/coreyjs/nhl-api-py/blob/main/docs/game_center.md Retrieve scores for all NHL games on a specific date. You can omit the date parameter to get scores for the current day. The response includes game details, team scores, and game state. ```APIDOC ## Get Daily Scores ### Description Retrieve scores for all NHL games on a specific date, including goal scorers, game state, and links to recaps. Pass a date string or omit it to get today's scores. ### Method GET ### Endpoint `/gamecenter/daily_scores` ### Parameters #### Query Parameters - **date** (str, optional): Date in "YYYY-MM-DD" format. Omit or pass `None` for current day. ### Response #### Success Response (200) - **prevDate** (str): Previous date with games - **currentDate** (str): Requested date - **nextDate** (str): Next date with games - **gameWeek** (list): 7-day schedule window - **oddsPartners** (list): Odds partner information - **games** (list): All games for the date **`games[]` item fields:** - **id** (int): Game ID - **season** (int): Season identifier - **gameType** (int): Game type (1=preseason, 2=regular, 3=playoffs) - **gameDate** (str): Date in YYYY-MM-DD format - **venue** (object) - **default** (str): Arena name - **startTimeUTC** (str): ISO 8601 start time - **gameState** (str): One of `"FUT"`, `"LIVE"`, `"OFF"`, `"FINAL"` - **awayTeam** (object) - **id** (int): Team ID - **name** (object) with **default** (str): Team name - **abbrev** (str): Three-letter abbreviation - **score** (int): Goals scored - **sog** (int): Shots on goal - **logo** (str): URL to team logo - **homeTeam** (object): Same structure as `awayTeam` - **gameCenterLink** (str): Relative link to game center page - **threeMinRecap** (str): URL to three-minute recap video - **condensedGame** (str): URL to condensed game video - **clock** (object): Clock state (see boxscore clock fields) - **periodDescriptor** (object): Current period info - **gameOutcome** (object): Outcome info if game is final **`goals[]` item fields (nested within each game):** - **period** (int): Period number - **timeInPeriod** (str): Time of goal in period - **playerId** (int): Scoring player's ID - **name** (object) - **default** (str): Scorer's name - **goalModifier** (str): Modifier (e.g., empty net, penalty shot) - **assists** (list): List of assisting players - **teamAbbrev** (str): Scoring team abbreviation - **goalsToDate** (int): Scorer's season goal total - **awayScore** (int): Away team score after this goal - **homeScore** (int): Home team score after this goal - **strength** (str): One of `"ev"` (even strength), `"pp"` (power play), `"sh"` (shorthanded) ### Request Example ```python client.game_center.daily_scores(date="2024-01-15") ``` ### Response Example ```json { "prevDate": "2024-01-14", "currentDate": "2024-01-15", "nextDate": "2024-01-16", "gameWeek": [ { "date": "2024-01-15", "games": [ { "id": 2023020780, "season": 20232024, "gameType": 2, "gameDate": "2024-01-15", "venue": {"default": "TD Garden"}, "startTimeUTC": "2024-01-16T00:00:00Z", "gameState": "FINAL", "awayTeam": { "id": 15, "name": {"default": "Los Angeles Kings"}, "abbrev": "LAK", "score": 3, "sog": 25, "logo": "..." }, "homeTeam": { "id": 6, "name": {"default": "Boston Bruins"}, "abbrev": "BOS", "score": 5, "sog": 30, "logo": "..." }, "gameCenterLink": "/analysis/gamecenter/2023020780", "threeMinRecap": "...", "condensedGame": "...", "clock": {}, "periodDescriptor": {}, "gameOutcome": {} } ] } ], "oddsPartners": [], "games": [ { "id": 2023020780, "season": 20232024, "gameType": 2, "gameDate": "2024-01-15", "venue": {"default": "TD Garden"}, "startTimeUTC": "2024-01-16T00:00:00Z", "gameState": "FINAL", "awayTeam": { "id": 15, "name": {"default": "Los Angeles Kings"}, "abbrev": "LAK", "score": 3, "sog": 25, "logo": "..." }, "homeTeam": { "id": 6, "name": {"default": "Boston Bruins"}, "abbrev": "BOS", "score": 5, "sog": 30, "logo": "..." }, "gameCenterLink": "/analysis/gamecenter/2023020780", "threeMinRecap": "...", "condensedGame": "...", "clock": {}, "periodDescriptor": {}, "gameOutcome": {} } ] } ``` ``` -------------------------------- ### Get Daily Game Schedule Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Fetches and prints a list of today's games, including away team, home team, and game time. Requires the 'games' key to be present in the response. ```python for game in games.get('games', []): away_team = game['awayTeam']['abbrev'] home_team = game['homeTeam']['abbrev'] game_time = game['startTimeUTC'] print(f"{away_team} @ {home_team} - {game_time}") ``` -------------------------------- ### Get League-Wide Team EDGE Leaders Source: https://github.com/coreyjs/nhl-api-py/blob/main/docs/edge.md Retrieve league leaders and rankings across all team EDGE categories. This endpoint can be called without parameters to get current season data, or with optional season and game type parameters. ```python from nhlpy import NHLClient client = NHLClient() leaders = client.edge.team_landing() ``` ```python leaders = client.edge.team_landing(season="20242025", game_type=2) ``` -------------------------------- ### Run Project Build Pipeline Commands Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Executes the project's build pipeline, which includes code formatting with Black, linting with Ruff, and running tests with Pytest. These commands should pass before submitting a pull request. ```bash # You can then run the following $ pytest $ ruff . $ black . ``` -------------------------------- ### Basic Usage of NHL API Python Wrapper Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Instantiate the client and fetch basic data like teams, standings, and daily schedules. ```python from nhlpy import NHLClient # Basic usage client = NHLClient() # Get all teams teams = client.teams.teams() # Get current standings standings = client.standings.league_standings() # Get today's games games = client.schedule.daily_schedule() ``` -------------------------------- ### Get Playoff Bracket Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Fetches the playoff bracket for a specified year. ```APIDOC ## Get Playoff Bracket ### Description Fetches the playoff bracket for a specified year. ### Method ```python bracket = client.schedule.playoff_bracket(year="2024") ``` ``` -------------------------------- ### Import Query Filters for QueryBuilder Source: https://github.com/coreyjs/nhl-api-py/blob/main/docs/stats.md Import necessary filter classes for constructing detailed queries. These filters allow precise data retrieval based on game type, season, position, draft, franchise, and nationality. ```python from nhlpy.api.query.filters.game_type import GameTypeQuery from nhlpy.api.query.filters.season import SeasonQuery from nhlpy.api.query.filters.position import PositionQuery, PositionTypes from nhlpy.api.query.filters.draft import DraftQuery from nhlpy.api.query.filters.franchise import FranchiseQuery from nhlpy.api.query.filters.nationality import NationalityQuery ``` -------------------------------- ### Get Weekly NHL Schedule Source: https://github.com/coreyjs/nhl-api-py/blob/main/docs/schedule.md Retrieve the full NHL schedule for a week, including metadata about preseason, regular season, and playoff date ranges. This returns the raw API response without transformation. Use this to get a full week's game data or specific date ranges. ```python from nhlpy import NHLClient client = NHLClient() # Get current week's schedule week = client.schedule.weekly_schedule() # Get a specific week's schedule week = client.schedule.weekly_schedule(date="2024-01-15") for day in week["gameWeek"]: print(f"{day['date']} ({day['dayAbbrev']}): {day['numberOfGames']} games") for game in day["games"]: print(f" {game['awayTeam']['abbrev']} @ {game['homeTeam']['abbrev']}") ``` -------------------------------- ### Get Draft Information Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Retrieves information about NHL draft years and rounds. ```APIDOC ## Get Draft Information ### Description Fetches information about NHL draft years and the number of rounds in each draft. ### Method `client.misc.draft_year_and_rounds()` ### Parameters None ### Request Example ```python from nhlpy import NHLClient client = NHLClient() draft_info = client.misc.draft_year_and_rounds() ``` ### Response #### Success Response (200) - **draft_info**: Data containing draft years and corresponding round information. ``` -------------------------------- ### Understand NHL Terms with Glossary Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Fetches the NHL glossary and then searches for definitions of specific statistical terms. Requires an initialized NHLClient. ```python from nhlpy import NHLClient client = NHLClient() # Get NHL glossary glossary = client.misc.glossary() # Find specific stats definitions stat_terms = ["BENCH", "BKS", "A", "ENA", "EV GA"] for term in stat_terms: for entry in glossary: if entry['abbreviation'].upper() == term: print(f"{term}: {entry['definition']}") continue ``` -------------------------------- ### Get Daily NHL Schedule Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Fetches the schedule for a specific date or defaults to today's games. Requires the client to be initialized. ```python # Get today's games games = client.schedule.daily_schedule() # Get games for a specific date games = client.schedule.daily_schedule(date="2024-01-01") ``` -------------------------------- ### Get Country Data Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Retrieves a list of countries recognized in the NHL data. ```APIDOC ## Get Country Data ### Description Fetches a list of countries present in the NHL data. ### Method `client.misc.countries()` ### Parameters None ### Request Example ```python from nhlpy import NHLClient client = NHLClient() countries = client.misc.countries() ``` ### Response #### Success Response (200) - **countries**: A list of country names or identifiers. ``` -------------------------------- ### Manage Poetry Project Version Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Commands for viewing and updating the project's version using Poetry. Supports bumping to patch, minor, major, or setting a specific version, including pre-release versions. ```bash # View current version poetry version # Bump version poetry version patch # 0.1.0 -> 0.1.1 poetry version minor # 0.1.0 -> 0.2.0 poetry version major # 0.1.0 -> 1.0.0 # Set specific version poetry version 2.0.0 # Set pre-release versions poetry version prepatch # 0.1.0 -> 0.1.1-alpha.0 poetry version preminor # 0.1.0 -> 0.2.0-alpha.0 poetry version premajor # 0.1.0 -> 1.0.0-alpha.0 # Specify pre-release identifier poetry version prerelease # 0.1.0 -> 0.1.0-alpha.0 poetry version prerelease beta # 0.1.0-alpha.0 -> 0.1.0-beta.0 ``` -------------------------------- ### Define Query Filters for Stats Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Demonstrates how to construct a list of filters for advanced stats queries using the QueryBuilder. Imports necessary filter classes. ```python from nhlpy.api.query.filters.franchise import FranchiseQuery from nhlpy.api.query.filters.shoot_catch import ShootCatchesQuery from nhlpy.api.query.filters.draft import DraftQuery from nhlpy.api.query.filters.season import SeasonQuery from nhlpy.api.query.filters.game_type import GameTypeQuery from nhlpy.api.query.filters.position import PositionQuery, PositionTypes from nhlpy.api.query.filters.status import StatusQuery from nhlpy.api.query.filters.opponent import OpponentQuery from nhlpy.api.query.filters.home_road import HomeRoadQuery from nhlpy.api.query.filters.experience import ExperienceQuery from nhlpy.api.query.filters.decision import DecisionQuery filters = [ GameTypeQuery(game_type="2"), DraftQuery(year="2020", draft_round="2"), SeasonQuery(season_start="20202021", season_end="20232024"), PositionQuery(position=PositionTypes.ALL_FORWARDS), ShootCatchesQuery(shoot_catch="L"), HomeRoadQuery(home_road="H"), FranchiseQuery(franchise_id="1"), StatusQuery(is_active=True),#for active players OR for HOF players StatusQuery(is_hall_of_fame=True), OpponentQuery(opponent_franchise_id="2"), ExperienceQuery(is_rookie=True), # for rookies || ExperienceQuery(is_rookie=False) #for veteran DecisionQuery(decision="W") # OR DecisionQuery(decision="L") OR DecisionQuery(decision="O") ] ``` -------------------------------- ### Get Team Statistics Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Retrieves a summary of team statistics for a specified season range. ```APIDOC ## Get Team Statistics ### Description Retrieves team statistics for a given season or range of seasons. ### Method `client.stats.team_summary(start_season, end_season)` ### Parameters #### Path Parameters - **start_season** (string) - Required - The starting season identifier (e.g., "20232024"). - **end_season** (string) - Required - The ending season identifier (e.g., "20232024"). ### Request Example ```python team_stats = client.stats.team_summary( start_season="20232024", end_season="20232024" ) ``` ``` -------------------------------- ### Get Game Matchup Information Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Retrieve game matchup information and key statistics for a specific game using its game ID. ```python # Get game matchup info and key stats game_info = client.game_center.match_up(game_id="2023020280") ``` -------------------------------- ### Get Team Monthly Schedule Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Retrieves the schedule for a specific team for a given month. ```APIDOC ## Get Team Monthly Schedule ### Description Retrieves the schedule for a specific team for a given month. ### Method ```python # Get team's games for a specific month team_schedule = client.schedule.team_monthly_schedule(team_abbr="BUF", month="2024-10") ``` ``` -------------------------------- ### Get Team Roster Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Fetches the roster for a specific NHL team for a given season. ```APIDOC ## Get Team Roster ### Description Fetches the roster for a specific NHL team for a given season. ### Method ```python # Get current season roster roster = client.teams.team_roster(team_abbr="BUF", season="20242025") ``` ``` -------------------------------- ### Compare Skater Against League with skater_comparison Source: https://github.com/coreyjs/nhl-api-py/blob/main/docs/edge.md Retrieve comparison statistics for a specific skater against league averages for all EDGE metrics. Requires player ID and optionally a season and game type. ```python from nhlpy import NHLClient client = NHLClient() comparison = client.edge.skater_comparison(player_id="8478402", season="20242025") ``` -------------------------------- ### Get Game Center Shift Chart Data (All Fields) Source: https://github.com/coreyjs/nhl-api-py/blob/main/docs/game_center.md Fetches all shift-by-shift data for a given game ID, including event details by passing an empty excludes list. Use when comprehensive data is required. ```python # Get shift data without any exclusions shifts_full = client.game_center.shift_chart_data(game_id="2023020280", excludes=[]) ``` -------------------------------- ### Get Team Roster Source: https://github.com/coreyjs/nhl-api-py/blob/main/docs/players.md Retrieves the full roster for a given team and season. This is an alias for `client.teams.team_roster()`. ```APIDOC ## Get Team Roster with players_by_team ### Description Retrieves the full roster for a given team and season. This is an alias for `client.teams.team_roster()` and returns the same data structure. Use whichever access pattern fits your code organization. ### Method client.players.players_by_team ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - `team_abbr` (str, required): Three-letter team abbreviation (e.g., "BUF", "TOR", "EDM") - `season` (str, required): Season in YYYYYYYY format (e.g., "20242025") ### Response structure - `forwards` (list): List of forward player objects - `defensemen` (list): List of defensemen player objects - `goalies` (list): List of goalie player objects ### Player fields within each list: - `id` (int): Unique NHL player identifier - `headshot` (str): URL to the player's headshot image - `firstName` (object): - `default` (str): Player's first name - `lastName` (object): - `default` (str): Player's last name - `sweaterNumber` (int): Jersey number - `positionCode` (str): Position code (e.g., "C", "L", "R", "D", "G") - `shootsCatches` (str): Handedness ("L" or "R") - `heightInInches` (int): Height in inches - `weightInPounds` (int): Weight in pounds - `heightInCentimeters` (int): Height in centimeters - `weightInKilograms` (int): Weight in kilograms - `birthDate` (str): Date of birth in "YYYY-MM-DD" format - `birthCity` (object): - `default` (str): City of birth - `birthCountry` (str): Three-letter country code (e.g., "CAN", "USA") - `birthStateProvince` (object, optional): - `default` (str): State or province of birth. Only present for some countries. ``` -------------------------------- ### Get Stats Configuration Options Source: https://github.com/coreyjs/nhl-api-py/blob/main/docs/misc.md Retrieves available filter and report options for the stats endpoints. Use this to discover supported report types, columns, and aggregations when building stats queries. ```python from nhlpy import NHLClient client = NHLClient() config = client.misc.config() # List available skater report types for report_type in config["playerReportData"]: print(f"Skater report: {report_type}") # List available goalie report types for report_type in config["goalieReportData"]: print(f"Goalie report: {report_type}") ``` -------------------------------- ### Get Game Boxscore Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Retrieve the complete boxscore for a specific game using its game ID. ```python # Get complete boxscore for a game boxscore = client.game_center.boxscore(game_id="2023020280") ``` -------------------------------- ### Get Game Matchup and Scoring Summary Source: https://github.com/coreyjs/nhl-api-py/blob/main/docs/game_center.md Use this snippet to retrieve detailed game matchup information, including three stars and scoring summaries. Requires a valid game ID. ```python from nhlpy import NHLClient client = NHLClient() matchup = client.game_center.match_up(game_id="2023020280") # Get three stars for star in matchup["summary"]["threeStars"]: print(f"Star #{star['star']}: {star['name']['default']} ({star['teamAbbrev']})") # Get scoring summary by period for period in matchup["summary"]["scoring"]: for goal in period.get("goals", []): print(goal) ``` -------------------------------- ### Get Goalie Statistics Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Retrieves basic or advanced goalie statistics for a specified season range. ```APIDOC ## Get Goalie Statistics ### Description Retrieves basic or advanced goalie statistics for a specified season range. ### Method `client.stats.goalie_stats_summary(start_season, end_season, stats_type)` ### Parameters #### Path Parameters - **start_season** (string) - Required - The starting season identifier (e.g., "20232024"). - **end_season** (string) - Required - The ending season identifier (e.g., "20232024"). - **stats_type** (string) - Optional - The type of stats to retrieve ('basic' or 'advanced'). Defaults to 'basic'. ### Request Example ```python # Get basic goalie stats goalie_stats = client.stats.goalie_stats_summary( start_season="20232024", end_season="20232024" ) # Get advanced goalie stats goalie_stats = client.stats.goalie_stats_summary( start_season="20232024", end_season="20232024", stats_type="advanced" ) ``` ``` -------------------------------- ### Get Playoff Schedule Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Fetches the playoff schedule for a given season, presented in a carousel format. ```APIDOC ## Get Playoff Schedule ### Description Fetches the playoff schedule for a given season, presented in a carousel format. ### Method ```python games = client.schedule.playoff_carousel(season="20242025") ``` ``` -------------------------------- ### Get Team Season Schedule Source: https://github.com/coreyjs/nhl-api-py/blob/main/README.md Retrieves the complete schedule for a specific team for a given season. ```APIDOC ## Get Team Season Schedule ### Description Retrieves the complete schedule for a specific team for a given season. ### Method ```python full_schedule = client.schedule.team_season_schedule(team_abbr="BUF", season="20242025") ``` ``` -------------------------------- ### Get Player Career Statistics and Biography Source: https://github.com/coreyjs/nhl-api-py/blob/main/docs/stats.md Fetch a player's complete profile, including biographical details, career statistics, recent games, and awards. Requires a player ID. ```python from nhlpy import NHLClient client = NHLClient() player = client.stats.player_career_stats(player_id="8478402") ```