A small FastAPI microservice that fetches hockey schedules from stats.swehockey.se, parses the raw HTML, and exposes a clean JSON API for a specific team. Designed for dashboards like Glance, home-lab widgets, or automation setups.
The API supports any team, based on a configurable substring (e.g., "modo", "aik", "björklöven").
No code changes are required — everything is configured via environment variables.
-
Fetches & parses games from a Swehockey schedule URL
-
Supports any team through a simple environment variable (
TEAM_TAG) -
Returns both last played game and next upcoming game
-
Automatically fetches team badges/logos from TheSportsDB
-
Computes match result from your team’s perspective:
"win","loss","draw"
-
Lightweight, fast, cache-friendly
-
Perfect for use with Glance dashboards, Home Assistant, or custom UIs
-
Stateless → easy to deploy in Docker, Kubernetes, or k3s
Run the API for MoDo Hockey:
docker run -d \
-p 8000:8000 \
-e TEAM_TAG="modo" \
-e SCHEDULE_URL="https://stats.swehockey.se/ScheduleAndResults/Schedule/18266" \
-e THESPORTSDB_API_KEY="YOUR_API_KEY" \
hockey-api:latestThen open:
http://localhost:8000/team
The service is configured entirely with environment variables:
| Variable | Required | Description | Example |
|---|---|---|---|
TEAM_TAG |
Yes | Substring used to identify the team (case-insensitive) | modo, aik, björklöven |
SCHEDULE_URL |
Yes | Swehockey schedule URL for your league/season | https://.../Schedule/18266 |
THESPORTSDB_API_KEY |
Optional | API key for badge/logo fetching | 123 (free tier) |
The API matches all games where TEAM_TAG appears in either team name.
Examples:
| TEAM_TAG | Matches |
|---|---|
modo |
“MoDo Hockey”, “MODO Hockey Dam” |
löven |
“IF Björklöven” |
aik |
“AIK”, “AIK Hockey” |
Returns the last played match and the next upcoming match for TEAM_TAG.
{
"team_tag": "modo",
"team_name": "MoDo Hockey",
"last_game": {
"date": "2025-11-26",
"time": "19:00",
"home_team": "AIK",
"away_team": "MoDo Hockey",
"home_score": 1,
"away_score": 2,
"venue": "Hovet, Johanneshov",
"home_badge": "https://r2.thesportsdb.com/images/media/team/badge123.png",
"away_badge": "https://r2.thesportsdb.com/images/media/team/badge456.png",
"team_result": "win"
},
"next_game": {
"date": "2025-11-28",
"time": "20:30",
"home_team": "MoDo Hockey",
"away_team": "IF Björklöven",
"home_score": null,
"away_score": null,
"venue": "Hägglunds Arena",
"home_badge": "...",
"away_badge": "..."
}
}services:
hockey-api:
image: hockey-api:latest
environment:
TEAM_TAG: "MoDo"
SCHEDULE_URL: "https://stats.swehockey.se/ScheduleAndResults/Schedule/18266"
THESPORTSDB_API_KEY: "YOUR_API_KEY"
ports:
- "8000:8000"Here is a minimal Glance widget example:
- type: custom-api
title: Hockey – Matches
cache: 30m
url: http://hockey-api:8000/teamYou can customize it with logos, score colors, etc.
Install dependencies:
pip install -r requirements.txtRun locally:
uvicorn app:app --reload --host 0.0.0.0 --port 8000-
Fetches Swehockey schedule HTML
-
Extracts text and splits it into logical lines
-
Parses:
- Dates
- Times
- Teams
- Results (if available)
- Spectators
- Venue
-
Filters by your
TEAM_TAG -
Computes last/next games
-
Fetches badges via TheSportsDB
-
Returns clean JSON suited for dashboards
Pull requests and issues are welcome! Ideas for improvements include:
- better parser for irregular Swehockey formats
- multi-team support (
/team/{tag}) - caching layer
- tests
- logo provider fallbacks
- automatic schedule discovery
MIT License – you are free to use, modify and distribute.