# NHL Data Scraper — Stats, Standings, Rosters, Salaries & More (`tempting_finch/nhl-data-scraper`) Actor

- **URL**: https://apify.com/tempting\_finch/nhl-data-scraper.md
- **Developed by:** [Karl Goyer](https://apify.com/tempting_finch) (community)
- **Categories:** Developer tools, Videos, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.00005 / actor start

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## NHL Data Scraper — Apify Actor

Comprehensive NHL data aggregation from official league APIs and selected secondary sources.

### Features

- **Standings** — season-by-season division/conference/league standings
- **Schedule & Scores** — league and per-team schedules, daily scores
- **Rosters** — current and historical team rosters by season
- **Player Stats** — player landing info, season stat leaders, game-by-game logs
- **Team Stats** — per-season team statistics (power play, PK, faceoffs, shots)
- **Game Data** — full boxscores and play-by-play with on-ice coordinates
- **Playoffs** — bracket, series carousel, series schedules
- **Draft** — prospect rankings and draft picks by round
- **EDGE Tracking** — advanced on-ice metrics (shot speed, skating speed, zone time)
- **Team Logos** — CDN URLs for light/dark logos by season range
- **Coaching Records** (opt-in) — career coaching history via Hockey-Reference
- **Advanced Stats** (opt-in) — xG, Corsi, SRS, 5-on-5 analytics via Hockey-Reference
- **Transactions** (opt-in) — player transaction history
- **Salary Data** (opt-in) — team cap sheets, contracts, signings via PuckPedia
- **Trades** (opt-in) — trade tracker with players, picks, cap retention

### Input

See `input_schema.json` for the full schema. Key fields:

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `seasons` | string[] | Yes | NHL seasons (e.g. `["20242025"]`) |
| `teams` | string[] | No | Team abbreviations (empty = all 32) |
| `players` | integer[] | No | Player IDs for targeted stats |
| `endpoints` | string[] | No | Data types to fetch |
| `riskySources` | boolean | No | Enable Hockey-Reference / PuckPedia scrapers (opt-in, use at your own risk) |

### Output

Results are stored in the default dataset. Each item has:
- `dataType` — type of record
- `season` — NHL season identifier
- `source` — data source
- `fetchedAt` — ISO timestamp
- `data` — the payload (schema varies by dataType)

### Pricing (Pay-per-event)

| Event | Price | Trigger |
|-------|-------|---------|
| Actor start | $0.05/1k | Automatic at run start |
| Dataset item | Per result | Automatic per push |
| Advanced stat | ~$0.01 | EDGE/xG enrichment |
| Logo pack | ~$0.005 | Per-team logo history |
| Risky source record | ~$0.01 | Coach/salary/trade record |

### API Usage

#### Synchronous (≤5 min runs)
```bash
POST https://api.apify.com/v2/acts/YOUR_USERNAME/nhl-data-scraper/run-sync-get-dataset-items?token=YOUR_API_TOKEN
Content-Type: application/json

{"seasons": ["20242025"], "endpoints": ["standings", "rosters"]}
````

#### Asynchronous

```bash
POST https://api.apify.com/v2/acts/YOUR_USERNAME/nhl-data-scraper/runs?token=YOUR_API_TOKEN
```

#### Python client

```python
from apify_client import ApifyClient
client = ApifyClient('YOUR_API_TOKEN')
run = client.actor('YOUR_USERNAME/nhl-data-scraper').call(run_input={
    'seasons': ['20242025'],
    'endpoints': ['standings', 'playerStats'],
})
for item in client.dataset(run['defaultDatasetId']).iterate_items():
    print(item['dataType'], item['season'])
```

### Sources

- **NHL Web API** (`api-web.nhle.com`) — primary source, no auth required
- **NHL Stats REST API** (`api.nhle.com/stats/rest`) — league-wide stats
- **NHL CDN** (`assets.nhle.com/logos/nhl/svg`) — team logo SVGs
- **Hockey-Reference** (opt-in, risky) — coaches, advanced stats, transactions
- **PuckPedia** (opt-in, risky) — salary cap, contracts, trades

### Legal Notice

Data from the official NHL APIs is publicly available and free to use. Logo URLs point to NHL's public CDN (logos are NHL trademarks). Hockey-Reference and PuckPedia prohibit automated scraping in their Terms of Service — use the `riskySources` option at your own risk.

### Development

```bash
pip install -r requirements.txt
apify run
```

### MCP Support

This actor exposes an MCP endpoint at `/mcp` for AI agent discovery and payments (x402/Skyfire compatible).

# Actor input Schema

## `seasons` (type: `array`):

NHL seasons to scrape, e.g. \["20232024", "20242025"]. Format: 4-digit start year + 4-digit end year.

## `teams` (type: `array`):

Team abbreviations to fetch (leave empty for all teams).

## `players` (type: `array`):

NHL player IDs to fetch stats for (leave empty to discover from selected seasons/teams).

## `endpoints` (type: `array`):

Select which data types to fetch. Each selected endpoint produces records with a corresponding dataType field.

## `startDate` (type: `string`):

Filter games/events from this date (YYYY-MM-DD).

## `endDate` (type: `string`):

Filter games/events up to this date (YYYY-MM-DD).

## `includeAdvancedStats` (type: `boolean`):

Fetch EDGE tracking data and enhanced analytics (additional charges apply).

## `riskySources` (type: `boolean`):

WARNING: Enables scraping of Hockey-Reference and PuckPedia. These sites prohibit automated scraping in their ToS. Use at your own risk. Heavy rate limiting applied.

## `maxResultsPerEndpoint` (type: `integer`):

Maximum number of records to return per endpoint group.

## `requestDelayMs` (type: `integer`):

Milliseconds between requests (used for rate limiting on risky sources).

## Actor input object example

```json
{
  "seasons": [
    "20242025"
  ],
  "endpoints": [
    "standings",
    "rosters",
    "playerStats"
  ],
  "includeAdvancedStats": false,
  "riskySources": false,
  "maxResultsPerEndpoint": 5000,
  "requestDelayMs": 1000
}
```

# Actor output Schema

## `dataType` (type: `string`):

Record type: standings | schedule | roster | playerStat | ...

## `season` (type: `string`):

NHL season ID, e.g. 20242025

## `source` (type: `string`):

Data source identifier

## `fetchedAt` (type: `string`):

ISO 8601 fetch timestamp

## `data` (type: `string`):

The actual data payload (JSON string). Schema varies by dataType.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "seasons": [
        "20242025"
    ],
    "endpoints": [
        "standings",
        "rosters",
        "playerStats"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("tempting_finch/nhl-data-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "seasons": ["20242025"],
    "endpoints": [
        "standings",
        "rosters",
        "playerStats",
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("tempting_finch/nhl-data-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "seasons": [
    "20242025"
  ],
  "endpoints": [
    "standings",
    "rosters",
    "playerStats"
  ]
}' |
apify call tempting_finch/nhl-data-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=tempting_finch/nhl-data-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "NHL Data Scraper — Stats, Standings, Rosters, Salaries & More",
        "version": "0.1",
        "x-build-id": "ajr7eLJopEpOQY6no"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/tempting_finch~nhl-data-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-tempting_finch-nhl-data-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/tempting_finch~nhl-data-scraper/runs": {
            "post": {
                "operationId": "runs-sync-tempting_finch-nhl-data-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/tempting_finch~nhl-data-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-tempting_finch-nhl-data-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "seasons"
                ],
                "properties": {
                    "seasons": {
                        "title": "Seasons",
                        "type": "array",
                        "description": "NHL seasons to scrape, e.g. [\"20232024\", \"20242025\"]. Format: 4-digit start year + 4-digit end year.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "teams": {
                        "title": "Teams",
                        "type": "array",
                        "description": "Team abbreviations to fetch (leave empty for all teams).",
                        "items": {
                            "type": "string",
                            "enum": [
                                "ANA",
                                "BOS",
                                "BUF",
                                "CAR",
                                "CBJ",
                                "CGY",
                                "CHI",
                                "COL",
                                "DAL",
                                "DET",
                                "EDM",
                                "FLA",
                                "LAK",
                                "MIN",
                                "MTL",
                                "NJD",
                                "NSH",
                                "NYI",
                                "NYR",
                                "OTT",
                                "PHI",
                                "PIT",
                                "SEA",
                                "SJS",
                                "STL",
                                "TBL",
                                "TOR",
                                "UTA",
                                "VAN",
                                "VGK",
                                "WPG",
                                "WSH"
                            ],
                            "enumTitles": [
                                "Anaheim Ducks",
                                "Boston Bruins",
                                "Buffalo Sabres",
                                "Carolina Hurricanes",
                                "Columbus Blue Jackets",
                                "Calgary Flames",
                                "Chicago Blackhawks",
                                "Colorado Avalanche",
                                "Dallas Stars",
                                "Detroit Red Wings",
                                "Edmonton Oilers",
                                "Florida Panthers",
                                "Los Angeles Kings",
                                "Minnesota Wild",
                                "Montreal Canadiens",
                                "New Jersey Devils",
                                "Nashville Predators",
                                "New York Islanders",
                                "New York Rangers",
                                "Ottawa Senators",
                                "Philadelphia Flyers",
                                "Pittsburgh Penguins",
                                "Seattle Kraken",
                                "San Jose Sharks",
                                "St. Louis Blues",
                                "Tampa Bay Lightning",
                                "Toronto Maple Leafs",
                                "Utah Hockey Club",
                                "Vancouver Canucks",
                                "Vegas Golden Knights",
                                "Winnipeg Jets",
                                "Washington Capitals"
                            ]
                        }
                    },
                    "players": {
                        "title": "Player IDs",
                        "type": "array",
                        "description": "NHL player IDs to fetch stats for (leave empty to discover from selected seasons/teams).",
                        "items": {
                            "type": "string"
                        }
                    },
                    "endpoints": {
                        "title": "Data Endpoints",
                        "type": "array",
                        "description": "Select which data types to fetch. Each selected endpoint produces records with a corresponding dataType field.",
                        "items": {
                            "type": "string",
                            "enum": [
                                "standings",
                                "schedule",
                                "scores",
                                "rosters",
                                "playerStats",
                                "playerGameLogs",
                                "teamStats",
                                "boxscores",
                                "playByPlay",
                                "playoffs",
                                "draft",
                                "edge",
                                "logos",
                                "coaches",
                                "advancedStats",
                                "transactions",
                                "salaries",
                                "trades"
                            ],
                            "enumTitles": [
                                "Standings (season-by-season)",
                                "Schedule (league + per-team)",
                                "Daily Scores",
                                "Rosters (current + historical)",
                                "Player Stats & Leaders",
                                "Player Game Logs",
                                "Team Stats",
                                "Game Boxscores",
                                "Play-by-Play (with coordinates)",
                                "Playoff Brackets & Series",
                                "Draft Rankings & Picks",
                                "EDGE Tracking (shot speed, skating, zone time)",
                                "Team Logos (CDN URLs)",
                                "Coaching Records [RISKY]",
                                "Advanced Stats (xG, Corsi, SRS) [RISKY]",
                                "Transactions / Trades [RISKY]",
                                "Salary Cap & Contracts [RISKY]",
                                "Trade Tracker [RISKY]"
                            ]
                        },
                        "default": [
                            "standings",
                            "rosters",
                            "playerStats"
                        ]
                    },
                    "startDate": {
                        "title": "Start Date",
                        "type": "string",
                        "description": "Filter games/events from this date (YYYY-MM-DD)."
                    },
                    "endDate": {
                        "title": "End Date",
                        "type": "string",
                        "description": "Filter games/events up to this date (YYYY-MM-DD)."
                    },
                    "includeAdvancedStats": {
                        "title": "Include Advanced Stats",
                        "type": "boolean",
                        "description": "Fetch EDGE tracking data and enhanced analytics (additional charges apply).",
                        "default": false
                    },
                    "riskySources": {
                        "title": "Enable Risky Sources (Coaches / Salaries / Trades)",
                        "type": "boolean",
                        "description": "WARNING: Enables scraping of Hockey-Reference and PuckPedia. These sites prohibit automated scraping in their ToS. Use at your own risk. Heavy rate limiting applied.",
                        "default": false
                    },
                    "maxResultsPerEndpoint": {
                        "title": "Max Results Per Endpoint",
                        "minimum": 1,
                        "type": "integer",
                        "description": "Maximum number of records to return per endpoint group.",
                        "default": 5000
                    },
                    "requestDelayMs": {
                        "title": "Request Delay (ms)",
                        "minimum": 100,
                        "type": "integer",
                        "description": "Milliseconds between requests (used for rate limiting on risky sources).",
                        "default": 1000
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
