# Hockey League Scraper — SHL, AHL, DEL & 15 more (`thehockeybrain/tha-hockey-scraper`) Actor

Scrape standings, schedules and player stats from 18 hockey leagues across Europe and North America. Writes clean JSON/CSV to your own S3 or Cloudflare R2. Built by The Hockey Brain (https://www.thehockeybrain.com) for scheduled production use.

- **URL**: https://apify.com/thehockeybrain/tha-hockey-scraper.md
- **Developed by:** [The Hockey Brain](https://apify.com/thehockeybrain) (community)
- **Categories:** Automation, Developer tools, Other
- **Stats:** 2 total users, 1 monthly users, 20.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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

## European + North American Hockey League Scraper

**Production-ready multi-league hockey data Actor** from [The Hockey Brain](https://www.thehockeybrain.com).

Scrapes standings, schedules, player/goalie stats, and game results from **18 professional hockey leagues**, then writes bronze JSON/CSV to **S3-compatible storage** (Cloudflare R2, AWS S3, Hetzner Object Storage, MinIO, …).

***

### Features

- One Actor, many leagues — select `source` in input
- Daily incremental modes (`update` / `both`) plus `test` / `full` where supported
- Playwright where needed (e.g. Metal Ligaen); HTTP/API for HockeyTech, SIHF, CSV portals
- Designed for schedules (cron) — no interactive UI required
- Storage via standard S3 env vars (easy R2 / AWS cutover)

### Supported leagues (`source`)

| `source` | League | Region | Typical stack |
|----------|--------|--------|----------------|
| `met` | Metal Ligaen | Denmark | Playwright |
| `shl` | SHL | Sweden | HTTP / CSV |
| `ha` | HockeyAllsvenskan | Sweden | HTTP / CSV |
| `sdhl` | SDHL | Sweden | HTTP |
| `sui` | National League | Switzerland | SIHF API |
| `elh` | Tipsport Extraliga | Czechia | HTTP |
| `ahl` | AHL | North America | HockeyTech API |
| `echl` | ECHL | North America | HockeyTech API |
| `del` | PENNY DEL | Germany | HTTP / API |
| `del2` | DEL2 | Germany | HTTP / API |
| `skl` | Tipsport / Maxa | Slovakia | HTTP |
| `magnus` | Ligue Magnus | France | HTTP |
| `eihl` | EIHL | UK | HTTP |
| `phl` | TAURON PHL | Poland | HTTP |
| `ice` | ICE HL | Austria | hockeydata |
| `erste` | Alps / Erste | AT/AT/IT | hockeydata |
| `swehockey` | stats.swehockey.se | Sweden | date checkpoint + game\_id set in R2 |
| `nhl` | NHL API | North America | catch-up from last `by_date` in R2 |

> **Not in this Actor (yet):** Elite Prospects full scrape (`ep`), Norwegian EHL bulk — separate Actors / internal jobs.

### Input

```json
{
  "source": "shl",
  "mode": "update",
  "runPipeline": false
}
```

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `source` | enum | `met` | League id (table above) |
| `mode` | enum | `update` | `update`, `both`, `test`, `full`, `daily`, `full-all` |
| `runPipeline` | boolean | `true` | Run MotherDuck load after scrape when a pipeline exists |

For **Store / SaaS buyers**, set `runPipeline: false` and read only from your own S3/R2 — MotherDuck is optional.

### Authentication & storage (Actor environment)

Set these in Actor **Settings → Environment variables** (mark keys as secret):

| Variable | Required | Description |
|----------|----------|-------------|
| `S3_ENDPOINT` or `HETZNER_ENDPOINT` | yes | e.g. `https://<account>.r2.cloudflarestorage.com` or Hetzner |
| `S3_ACCESS_KEY` or `HETZNER_ACCESS_KEY` | yes | Access key |
| `S3_SECRET_KEY` or `HETZNER_SECRET_KEY` | yes | Secret key |
| `S3_REGION` or `HETZNER_REGION` | no | Default `auto` (R2) / `eu-central` (Hetzner) |
| `MOTHERDUCK_TOKEN` | no | Only if `runPipeline: true` |

Per-league bucket overrides (optional): `MET_S3_BUCKET`, `SHL_S3_BUCKET`, `HA_S3_BUCKET`, `AHL_S3_BUCKET`, …

Default bronze buckets use league prefixes (`met-scraper`, `shl-raw`, `ahl-scraper`, …). Override per source if you prefer your own names.

### Output

- Files in your S3/R2 bucket (league-specific prefixes)
- Dataset row on success:

```json
{
  "source": "shl",
  "mode": "update",
  "modeFallbackApplied": false,
  "runPipeline": false,
  "status": "ok",
  "storage": "https://<account>.r2.cloudflarestorage.com"
}
```

If you pass an unsupported `mode` for a source, the Actor falls back to a safe
source-specific default and sets `modeFallbackApplied: true`.

### Memory & cost guidance

| Source class | Suggested memory | Notes |
|--------------|------------------|-------|
| HTTP / API / CSV | **1024 MB** | SHL, HA, AHL, ECHL, DEL, … |
| Playwright | **2048 MB** | `met` |

Avoid large manual runs on Apify Free (~$5/mo). Prefer **Schedules**.

### Scheduling (recommended)

Create one Apify Schedule per league (cron UTC). Example SHL daily:

- Cron: `0 8 * * *`
- Input: `{"source":"shl","mode":"update","runPipeline":false}`
- Memory: 1024 MB

Create one schedule per league. Start weekly; move to daily after you have measured compute cost.

### Commercial positioning

Use this Actor as a **reliable ingestion layer** rather than a one-off scrape:

- Stable source ids and explicit run modes.
- S3/R2-first output (no lock-in to a vendor analytics stack).
- Deterministic success row in dataset for monitoring and support.
- No buyer dependency on MotherDuck when `runPipeline: false`.

#### Suggested buyer offer

- **Pay-per-event:** $0.99 per successful league scrape (`league-scrape-completed`).
- Buyer also pays Apify platform compute for the run.
- Recommended schedule: weekly per league to start; daily after proving costs.
- **Starter packaging:** 1–2 leagues, weekly.
- **Growth:** 3–6 leagues, daily schedules, setup support.
- **Pro:** 7+ leagues, source mix optimization and runbook customization.

### Legal / ToS

Scrapers target **public stats pages and official APIs**. Buyers must ensure their use complies with each site’s terms and applicable law. Respect robots/rate limits; do not overload source sites. This Actor is provided as-is for analytics / research pipelines.

### Changelog

- **0.4** — Public identity is The Hockey Brain (`https://www.thehockeybrain.com`). Crawler User-Agents point at the project site, not a personal GitHub account.
- **0.1** — Multi-league dispatcher; S3/R2-ready env aliases.

### Support

Product: [The Hockey Brain](https://www.thehockeybrain.com)\
Contact: [thehockeybrain.com/contact](https://www.thehockeybrain.com/contact)

# Actor input Schema

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

League id to scrape (see README table).

## `mode` (type: `string`):

Scraper mode. If incompatible with selected source, Actor auto-falls back to a safe default and reports it in dataset.

## `runPipeline` (type: `boolean`):

If true, runs scripts/run\_<source>\_pipeline.py when available. Keep false for Store buyers unless you also set MOTHERDUCK\_TOKEN.

## Actor input object example

```json
{
  "source": "met",
  "mode": "update",
  "runPipeline": false
}
```

# Actor output Schema

## `runSummary` (type: `string`):

Dataset row with league source, mode and scrape status. League files are written to your configured S3/R2 bucket.

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("thehockeybrain/tha-hockey-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 = {}

# Run the Actor and wait for it to finish
run = client.actor("thehockeybrain/tha-hockey-scraper").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{}' |
apify call thehockeybrain/tha-hockey-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,thehockeybrain/tha-hockey-scraper"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/PS0AnP0SyhRByQNtX/builds/zetnwIhDAoVLsSqes/openapi.json
