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_...orpk_test_....days(optional): How many days the REST tables look back when no interval is given, from 1 to 3660. Defaults to3.league(optional): Anl_league id, for examplel_B8x2K9. Narrows discovery to that league-season instead of a date range.season(optional):2025/2026for a season that crosses the new year, or2026for a calendar year. Used withleague, and as the filter for the_bulktables.base_url(optional): Overrides the API base URL. Defaults tohttps://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: postgresname: The name of the asset.type: Set toingestr.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 examplepostgres.
Step 3: Run asset to ingest data
bash
bruin run assets/pitchapi_ingestion.ymlAvailable Source Tables
| Table | Primary Key | Incremental Key | Incremental Strategy | Details |
|---|---|---|---|---|
leagues | id | - | replace | The league catalogue |
teams | id | - | replace | Every team in every league |
players | id | - | merge | The players of the matches in the window |
matches | id | date | merge | Matches for the date range, or for league and season when given |
shots | match_id, id | date | delete+insert | Per-match shots with xG, xGOT, and coordinates |
events | match_id, event_type, minute, minute_added, team_id, player_id | date | delete+insert | Goals, cards, and substitutions |
lineups | match_id, team_id | - | merge | One row per team: formation, coach, starters and subs |
player_stats | match_id, player_id | - | merge | One row per player per match |
match_stats | match_id, period, group_name, key | date | delete+insert | Team statistics in long form |
matches_bulk | id | - | replace | One export file of matches |
shots_bulk | match_id, id | - | replace | One export file of shots |
events_bulk | match_id, event_type, minute, minute_added, team_id, player_id | - | replace | One export file of events |
lineups_bulk | match_id, team_id | - | replace | One export file of team sheets |
player_stats_bulk | match_id, player_id | - | replace | One export file of player statistics |
match_stats_bulk | match_id, period, key | - | replace | One export file of team statistics |
teams_bulk | id | - | replace | The whole team catalogue; takes no filters |
players_bulk | id | - | replace | The whole player catalogue; takes no filters |
Incremental behavior and limitations
- Without
league, the per-match tables read every match in the interval, or the lastdaysdays without one. Withleagueandseason, they read that league-season and ignore the interval. shots,events, andmatch_statsreplace the days they read, so corrected or removed rows don't linger.- The
_bulktables need the Data plan and read the export API, which builds one Parquet file per dataset.teams_bulkandplayers_bulkrefuse a filter, so use a connection withoutleagueandseasonfor them. - The free plan allows 600 requests a minute and 15,000 a day.