Fixtures, results, tables and team IDs from TheSportsDB, with a local cache that makes the free key go further.
Every TheSportsDB v1 method as a command, plus resolve for team IDs, fixtures and day for schedules, settle for final results and moved for kickoff changes. Works with the free shared key; set THESPORTSDB_API_KEY for premium limits.
Learn more at TheSportsDB.
Created by @surGeonGG (surgeongg).
Authentication
No sign-up needed: the CLI uses TheSportsDB's free shared key 123 by default. The free key caps rows per call (for example one team per search) and allows 30 requests a minute. Set THESPORTSDB_API_KEY to your premium key to lift those caps. On the free key, team schedules (fixtures --team, tv-next, teams next/last) list home games only.
Quick Start
# Check config without calling the API
thesportsdb-pp-cli doctor --dry-run
# Find a team and its ID
thesportsdb-pp-cli teams search --name Arsenal
# Next and last games for that team
thesportsdb-pp-cli fixtures --team 133604
# League table
thesportsdb-pp-cli leagues table --league 4328
Unique Features
Schedules and results
-
resolve — Turn team names into TheSportsDB team IDs, one at a time or in bulk, with the reason each one matched; it never guesses on near-misses.
Reach for this when joining team names from another data source to TheSportsDB IDs.
thesportsdb-pp-cli resolve Arsenal --sport Soccer --country England --agent
-
fixtures — Upcoming and recent games for a team or league in one list, with UTC and local kickoff, status, score and W/D/L. On the free key a team's lists hold home games only.
Use this for 'when does X play next' and 'how did X do' in one call.
thesportsdb-pp-cli fixtures --team 133604 --agent
-
settle — Check whether finished games have a final score, or were postponed, cancelled or abandoned; checks up to 25 games per run.
Use this before trusting a result for settlement or grading.
thesportsdb-pp-cli settle --ids 2052711 --agent
-
tv-next — TV channels for a team's next game and highlight links for its last game. On the free key a team's games are home games only.
Use this for 'when and where can I watch my team'.
thesportsdb-pp-cli tv-next --team 133604 --agent
Change tracking
-
day — Every game on a date for the leagues you pass with --league (all by default); on the free key each league returns at most 3 games and is flagged truncated.
Use this for 'what is on today' across several leagues.
thesportsdb-pp-cli day 2026-12-06 --league 4328 --agent
-
moved — Find games whose kickoff time, venue or status changed since the last saved copy.
Use this to catch reschedules and postponements early.
thesportsdb-pp-cli moved --league 4328 --agent
Recipes
Resolve team IDs in bulk
thesportsdb-pp-cli resolve Arsenal Chelsea --sport Soccer --agent
Maps several names to IDs with a match reason for each.
Narrow a large event payload
thesportsdb-pp-cli leagues next --id 4328 --agent --select idEvent,strEvent,strTimestamp,strStatus
Keeps only ID, name, kickoff and status from the next league events.
Check results before settling
thesportsdb-pp-cli settle --league 4328 --overdue 3h --agent
Checks games saved by an earlier fixtures or day run that kicked off 3 hours to 14 days ago and have no final result; run 'fixtures --league 4328' first.
Usage
Run thesportsdb-pp-cli --help for the full command reference and flag list.
Paths & environment variables
This CLI separates local files into four path kinds:
| Kind | Contents |
|---|
config | User-editable settings such as config.toml and saved profiles |
data | Durable local data such as data.db |
state | Runtime state such as persisted queries, jobs, and teach.log |
cache | Regenerable HTTP/cache files |
Each kind resolves independently. The ladder is:
- Per-kind env var:
THESPORTSDB_CONFIG_DIR, THESPORTSDB_DATA_DIR, THESPORTSDB_STATE_DIR, or THESPORTSDB_CACHE_DIR
--home <dir> for this invocation
THESPORTSDB_HOME for a flat relocated root
- XDG env vars:
XDG_CONFIG_HOME, XDG_DATA_HOME, XDG_STATE_HOME, XDG_CACHE_HOME
- Platform defaults matching existing installs
For containers and agent sandboxes, prefer a single relocated root:
export THESPORTSDB_HOME=/srv/thesportsdb
thesportsdb-pp-cli doctor
Under THESPORTSDB_HOME=/srv/thesportsdb, the four dirs resolve to /srv/thesportsdb/config, /srv/thesportsdb/data, /srv/thesportsdb/state, and /srv/thesportsdb/cache.
On Windows, set the same variable in PowerShell:
$env:THESPORTSDB_HOME = "C:\srv\thesportsdb"
thesportsdb-pp-cli doctor
Under $env:THESPORTSDB_HOME = "C:\srv\thesportsdb", the four dirs resolve to C:\srv\thesportsdb\config, C:\srv\thesportsdb\data, C:\srv\thesportsdb\state, and C:\srv\thesportsdb\cache.
MCP servers do not receive CLI flags from the host. Put relocation in the host env block:
{
"mcpServers": {
"thesportsdb": {
"command": "thesportsdb-pp-mcp",
"env": {
"THESPORTSDB_HOME": "/srv/thesportsdb"
}
}
}
}
Precedence matters in fleets: an ambient per-kind variable such as THESPORTSDB_DATA_DIR overrides an explicit --home for that kind. Use THESPORTSDB_HOME or the per-kind variables for durable fleet relocation; treat --home as the weaker per-invocation lever.
Relocation is one-way. Unsetting THESPORTSDB_HOME does not move files back to platform defaults, and doctor cannot find files left under a former root. Move the files manually before unsetting relocation variables.
Existing installs keep working because the platform-default rung matches the legacy layout. Run thesportsdb-pp-cli doctor --fail-on warn to check path warnings in automation.
Local data
Reads are saved locally by default: in --data-source auto mode every successful read is also written to the SQLite store (data.db, or data-<hash>.db per credential) in the data directory. GET responses are cached for five minutes under http/ in the cache directory. The learn journal lives under learn/ in the state directory. thesportsdb-pp-cli doctor prints the resolved paths, every store file, and the response-cache size.
None of it is encrypted. New files are created owner-only; beyond that the data relies on OS account permissions and full-disk encryption (FileVault, BitLocker, LUKS).
- Erase it:
thesportsdb-pp-cli local-data purge lists the store files, response cache, and learn journal it would delete; add --yes to delete them, or --only store|cache|journal to narrow it. Config and credentials are kept.
- Run without a local copy: set
THESPORTSDB_NO_LOCAL_DATA=1. Reads go to the API (--data-source live; --data-source local still reads an existing store), the response cache is off (--no-cache), nothing new is written to the store, and sync and workflow archive refuse to run. Set it in an MCP host's env block and every command the server runs inherits it.
- Choose the read source without flags:
THESPORTSDB_DATA_SOURCE=auto|live|local sets the --data-source default; an explicit flag wins.
Commands
countries
Manage countries
thesportsdb-pp-cli countries - List all the countries supported on the website.
events
Manage events
thesportsdb-pp-cli events day - See the events on a specific day in the future, past or present.
thesportsdb-pp-cli events get - Get information about a specific event by its unique identifier.
thesportsdb-pp-cli events highlights - YouTube highlight links for events on a date, optionally filtered by league ID or sport.
thesportsdb-pp-cli events lineup - Get information about the lineup of a specific event by its unique identifier.
thesportsdb-pp-cli events results - Get results of events based on search criteria.
thesportsdb-pp-cli events search - Search for any sports event by its title with extra filters for season, date or filename.
thesportsdb-pp-cli events season - See all the events for a particular season and filter by league ID.
thesportsdb-pp-cli events stats - Get statistics for a specific event by its unique identifier.
thesportsdb-pp-cli events timeline - Get information about the timeline of a specific event by its unique identifier.
thesportsdb-pp-cli events tv - TV channels showing an event, by event ID.
thesportsdb-pp-cli events tv-schedule - See all the events for a particular TV station and filter by league ID. A date is required: without filters TheSportsDB returns an empty body.
leagues
Manage leagues
thesportsdb-pp-cli leagues all - List all the leagues supported on the website.
thesportsdb-pp-cli leagues get - Get information about a specific league by its unique identifier.
thesportsdb-pp-cli leagues list - Search for leagues by country and sport name.
thesportsdb-pp-cli leagues next - See the next few upcoming events for a league using the League ID.
thesportsdb-pp-cli leagues past - See the last few events for a league using the League ID.
thesportsdb-pp-cli leagues seasons - List all the seasons available for a specific league ID
thesportsdb-pp-cli leagues table - League table for a league ID, optionally for a season (seasons only for featured soccer leagues).
players
Manage players
thesportsdb-pp-cli players contracts - Contracts of a player, by player ID.
thesportsdb-pp-cli players former-teams - Teams a player played for before, by player ID.
thesportsdb-pp-cli players get - Get information about a specific player by their unique identifier.
thesportsdb-pp-cli players honours - Honours a player won, by player ID.
thesportsdb-pp-cli players milestones - Milestones of a player, by player ID.
thesportsdb-pp-cli players results - All results for a player by player ID.
thesportsdb-pp-cli players search - Search for any sports person by their main or alternate name.
thesportsdb-pp-cli players stats - Statistics for a player by player ID.
sports
Manage sports
thesportsdb-pp-cli sports - List all the sport categories supported on the website.
teams
Manage teams
thesportsdb-pp-cli teams equipment - Current and past kits of a team, by team ID.
thesportsdb-pp-cli teams get - Get information about a specific team by its unique identifier.
thesportsdb-pp-cli teams last - Last events for a team, by team ID. The free key lists home games only.
thesportsdb-pp-cli teams list - List all the teams in a specific league by the leagues name, country and sport or ID.
thesportsdb-pp-cli teams next - Next events for a team, by team ID. The free key lists home games only.
thesportsdb-pp-cli teams players - List all the Players who play for a team by the teams ID.
thesportsdb-pp-cli teams search - Search for any sports team by its main or alternate name.
venues
Manage venues
thesportsdb-pp-cli venues get - Details of a venue, by venue ID.
thesportsdb-pp-cli venues search - Search any venue by its name or alternate name.
day
thesportsdb-pp-cli day - Every game on a date for the leagues you pass with --league (all by default); on the free key each league returns at most 3 games and is flagged truncated.
fixtures
thesportsdb-pp-cli fixtures - Upcoming and recent games for a team or league in one list, with UTC and local kickoff, status, score and W/D/L. On the free key a team's lists hold home games only.
moved
thesportsdb-pp-cli moved - Find games whose kickoff time, venue or status changed since the last saved copy.
resolve
thesportsdb-pp-cli resolve - Turn team names into TheSportsDB team IDs, one at a time or in bulk, with the reason each one matched; it never guesses on near-misses.
settle
thesportsdb-pp-cli settle - Check whether finished games have a final score, or were postponed, cancelled or abandoned; checks up to 25 games per run.
tv-next
thesportsdb-pp-cli tv-next - TV channels for a team's next game and highlight links for its last game. On the free key a team's games are home games only.
Self-learning loop
This CLI caches per-question discovery so repeat queries skip the walk and structurally similar queries get answered via entity substitution. The loop also self-captures: every invocation is journaled locally, and failed-flag corrections plus fresh teaches surface as candidates on the next recall for confirm/reject judgment. Agents call recall before discovery and fire teach & after answering. See the ## Automatic learning section in SKILL.md for the full protocol.
thesportsdb-pp-cli recall <query> - Look up cached resources for a query before running discovery
thesportsdb-pp-cli teach - Record a query -> resource mapping (silent on success, safe to background with &)
thesportsdb-pp-cli learnings list - Inspect taught rows
thesportsdb-pp-cli learnings forget <query> - Undo a teach
thesportsdb-pp-cli learnings candidates - List auto-captured candidates awaiting confirm/reject
thesportsdb-pp-cli learnings stats - Local loop metrics: recall hit rate, teach-to-reuse, playbook resolution, candidate counts
thesportsdb-pp-cli teach-pattern - Install a query/resource template up front
thesportsdb-pp-cli teach-lookup - Add an entity mapping (e.g. country code, team alias) for pattern substitution
Pass --no-learn or set THESPORTSDB_NO_LEARN=true to disable the loop for deterministic flows.
The local store's schema version stamp is one-way: once this version of thesportsdb-pp-cli opens the database, older binaries refuse it with a version error — upgrade the binary rather than downgrading.
Output Formats
# Human-readable table (default in terminal, JSON when piped)
thesportsdb-pp-cli countries
# JSON for scripting and agents
thesportsdb-pp-cli countries --json
# Filter to specific fields
thesportsdb-pp-cli countries --json --select flag_url_32,name_en
# Dry run — show the request without sending
thesportsdb-pp-cli countries --dry-run
# Agent mode — JSON + compact + no prompts in one flag
thesportsdb-pp-cli countries --agent
--csv prefixes a leading ' on cells and header keys that start with =, +, -, @, a tab, or a line break (including fullwidth =+-@) so a spreadsheet does not run them as formulas. Plain signed numbers such as -5 and +2.5e3 are left unchanged.
Agent Usage
This CLI is designed for AI agent consumption:
- Non-interactive - never prompts, every input is a flag
- Pipeable -
--json output to stdout, errors to stderr
- Filterable -
--select <field>[,<field>...] returns only fields you need
- Previewable -
--dry-run shows the request without sending
- Read-only by default - this CLI does not create, update, delete, publish, send, or mutate remote resources
- Offline-friendly - sync/search commands can use the local SQLite store when available
- Agent-safe by default - no colors or formatting unless
--human-friendly is set
Exit codes: 0 success, 2 usage error, 3 not found, 5 API error, 7 rate limited or blocked, 10 config error.
Runtime Endpoint
This CLI resolves endpoint placeholders at runtime, so one installed binary can target different tenants or API versions without regeneration.
Endpoint environment variables:
THESPORTSDB_API_KEY resolves {apikey}
Base URL: https://www.thesportsdb.com/api/v1/json/{apikey}
Health Check
thesportsdb-pp-cli doctor
Verifies configuration and connectivity to the API.
Configuration
Run thesportsdb-pp-cli doctor to see the resolved config, data, state, and cache directories. The platform-default config path is ~/.config/thesportsdb-pp-cli/config.toml on macOS/Linux and %USERPROFILE%\.config\thesportsdb-pp-cli\config.toml on Windows; --home, THESPORTSDB_HOME, and per-kind env vars can relocate it.
Static request headers can be configured under headers; per-command header overrides take precedence.
--ca-cert, THESPORTSDB_CA_CERT, or ca_cert adds a PEM CA bundle to the system trust roots. --tls-server-name, THESPORTSDB_TLS_SERVER_NAME, or tls_server_name is the name checked against the certificate when the dialed address does not match it. Precedence is flag, then environment, then the config file. A config file other users can change does not supply these settings. Certificate verification failures are not retried.
Troubleshooting
Not found errors (exit code 3)
- Check the resource ID is correct
- Run the
list command to see available items
API-specific
- HTTP 429 Too Many Requests — Wait one minute; the free key allows 30 requests a minute. Lower --rate-limit for long runs.
- Search or day returns only one or a few rows — That is the free-key cap; run 'fixtures --league ' for the leagues you need to save more games, or set THESPORTSDB_API_KEY to a premium key.
- A team's next or last game is missing away games — The free key lists only home games for a team; use 'fixtures --league ' or a premium key.
Sources & Inspiration
This CLI was built by studying these projects and resources:
Generated by CLI Printing Press