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, and advanced analytics.

Bruin supports PitchAPI as a source for Ingestr assets, and you can use it to ingest football data into your data platform.

Configuration ​

Step 1: Add a connection to the .bruin.yml file ​

yaml
connections:
    pitchapi:
        - name: "pitchapi"
          api_key: "pk_live_..."
          league: "l_B8x2K9"
          season: "2025/2026"
  • api_key (required): A PitchAPI key, pk_live_... or pk_test_....
  • days (optional): How many days the REST tables look back when no interval is given, from 1 to 3660. Defaults to 3.
  • league (optional): An l_ league id, for example l_B8x2K9. Narrows discovery to that league-season instead of a date range.
  • season (optional): 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 (optional): Overrides the API base URL. Defaults to https://api.pitchapi.dev/v1.

league and season scope every table read with the connection, so load each league-season into its own destination table, for example with one connection per league-season.

Step 2: Create an asset file for data ingestion ​

Create a YAML file (e.g. pitchapi_ingestion.yml) inside the assets folder:

yaml
name: public.pitchapi_matches
type: ingestr

parameters:
  source_connection: pitchapi
  source_table: 'matches'

  destination: postgres
  • name: The name of the asset.
  • type: Set to ingestr.
  • source_connection: The name of the PitchAPI connection defined in .bruin.yml.
  • source_table: One of the tables below.
  • destination: The destination platform/type, for example postgres.

Step 3: Run asset to ingest data ​

bash
bruin run assets/pitchapi_ingestion.yml

Available Source Tables ​

TablePrimary KeyIncremental KeyIncremental StrategyDetails
leaguesid-replaceThe league catalogue
teamsid-replaceEvery team in every league
playersid-mergeThe players of the matches in the window
matchesiddatemergeMatches for the date range, or for league and season when given
shotsmatch_id, iddatedelete+insertPer-match shots with xG, xGOT, and coordinates
eventsmatch_id, event_type, minute, minute_added, team_id, player_iddatedelete+insertGoals, cards, and substitutions
lineupsmatch_id, team_id-mergeOne row per team: formation, coach, starters and subs
player_statsmatch_id, player_id-mergeOne row per player per match
match_statsmatch_id, period, group_name, keydatedelete+insertTeam statistics in long form
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

Incremental behavior and limitations ​

  • Without league, the per-match tables read every match in the interval, or the last days days without one. With league and season, they read that league-season and ignore the interval.
  • shots, events, and match_stats replace the days they read, so corrected or removed rows don't linger.
  • The _bulk tables need the Data plan and read the export API, which builds one Parquet file per dataset. teams_bulk and players_bulk refuse a filter, so use a connection without league and season for them.
  • The free plan allows 600 requests a minute and 15,000 a day.