Skip to content

PitchAPI ​

PitchAPI is a football data API covering 77 leagues: matches, shot-level expected goals with pitch coordinates, events, lineups, per-player and per-team match statistics, live snapshots and advanced analytics. The free plan is complete — every league and every endpoint — so the paid tiers add capacity and bulk delivery, not data.

ingestr supports PitchAPI as a keyed source. The REST tables read a date range or a league-season one match at a time; the _bulk tables read the Data plan's export API, which builds one Parquet file per dataset — the only practical way to load a full history.

Implementation: pkg/source/pitchapi. For the API surface, plan limits and implementation notes, see the PitchAPI source research.

URI format ​

plaintext
pitchapi://?api_key=<api-key>

URI parameters:

  • api_key: PitchAPI key, pk_live_... or pk_test_.... Required.
  • days: How many days the REST tables look back when no interval is given. Defaults to 3.
  • league: An l_ league id, for example l_B8x2K9. Narrows discovery to that league-season instead of a date range.
  • season: 2025/2026 for a season that crosses the new year, or 2026 for a calendar year. Used with league, and as the filter for the _bulk tables.
  • base_url: Overrides the API base URL. Defaults to https://api.pitchapi.dev/v1.

The API key is sent in the X-API-KEY header, not Authorization.

Examples ​

Load the last three days of matches into DuckDB:

sh
ingestr ingest \
  --source-uri 'pitchapi://?api_key=<api-key>' \
  --source-table 'matches' \
  --dest-uri 'duckdb:///pitch.duckdb' \
  --dest-table 'football.matches'

Load one league-season of shots, refreshing as it goes:

sh
ingestr ingest \
  --source-uri 'pitchapi://?api_key=<api-key>&league=l_B8x2K9&season=2025/2026' \
  --source-table 'shots' \
  --dest-uri 'duckdb:///pitch.duckdb' \
  --dest-table 'football.shots'

Backfill every shot in a season from a bulk export (Data plan):

sh
ingestr ingest \
  --source-uri 'pitchapi://?api_key=<api-key>&season=2025/2026' \
  --source-table 'shots_bulk' \
  --dest-uri 'duckdb:///pitch.duckdb' \
  --dest-table 'football.shots'

Tables ​

TablePKInc KeyInc StrategyDetails
leaguesid-replaceThe league catalogue from GET /leagues.
teamsid-replaceEvery team in every league, taken from the match lists (name, image_url).
playersid-mergeThe players of the matches in the window, hydrated through GET /players/{id}.
matchesiddatemergeMatches for the date range, or for league+season when given.
shotsmatch_id, iddatedelete+insertPer-match shots, with xG, xGOT, coordinates and the scorer as JSON.
eventsmatch_id, event_type, minute, minute_added, team_id, player_iddatedelete+insertGoals, cards and substitutions, with player names as JSON.
lineupsmatch_id, team_id-mergeOne row per team: formation, coach, confirmed, and starters/subs as JSON.
player_statsmatch_id, player_id-mergeOne row per player per match; stats is JSON and varies by position.
match_statsmatch_id, period, group_name, keydatedelete+insertTeam statistics in long form, one row per period, group and key.
matches_bulkid-replaceOne export file of matches.
shots_bulkmatch_id, id-replaceOne export file of shots.
events_bulkmatch_id, event_type, minute, minute_added, team_id, player_id-replaceOne export file of events.
lineups_bulkmatch_id, team_id-replaceOne export file of team sheets.
player_stats_bulkmatch_id, player_id-replaceOne export file of player statistics.
match_stats_bulkmatch_id, period, key-replaceOne export file of team statistics.
teams_bulkid-replaceThe whole team catalogue; takes no filters.
players_bulkid-replaceThe whole player catalogue; takes no filters.

Use these as the --source-table parameter in the ingestr ingest command.

Notes ​

  • Discovery. Without league, the per-match tables read every match in --interval-start..--interval-end, or the last days days when there is no interval. With league and season, they read that league-season and ignore the interval.
  • One destination table per league/season. league and season scope every table read with that URI, so load each league-season into its own destination table. Two different filters writing to one table delete each other's rows: teams replaces the table, and shots, events and match_stats delete every row in the dates they read.
  • delete+insert on date for shots, events and match_stats. Each run replaces the days it read, so a corrected scorer or minute, or a disallowed goal, does not leave a stale row behind. With league, the whole season is read and replaced, and the interval is ignored.
  • merge for matches, players, lineups and player_stats. Their keys are stable, and a rescheduled match keeps its id while its date changes.
  • Per-match 404s are not failures. A match that was never rated, has no lineups yet, or has no shots yields no rows for that table.
  • Rate limits. Free is 600 requests a minute and 15,000 a day; Pro and Data are 1,200 a minute with no daily cap. The source paces itself at 8 requests a second and retries a 429 twice, honouring Retry-After, before failing.
  • Bulk tables need the Data plan (€9.99/month). Each read queues one export job, polls it, downloads the Parquet file and deletes the job afterwards. Allow 30 seconds to 5 minutes for a season, longer for shots.
    • Exports take league, season and from/to; from and to must be sent together and span at most five years.
    • 25 jobs per UTC day. A file is downloadable for 7 days and a signed URL is valid for 15 minutes; the source downloads it and deletes the job, so neither matters to a run.
    • One file is capped at 2 GiB. A job that would exceed it fails with export exceeds the size limit; narrow the filter (a season, or a date range) rather than retrying.
    • teams_bulk and players_bulk are whole-table datasets and refuse a filter, so remove league and season from the URI for those two.
    • Bulk files carry the internal integer ids (shots.match_id joins matches.id) and the opaque tokens (id_token) on matches, teams and players. Parquet keeps NULLs as NULL: an undefined rate is not zero.