Skip to content

PitchAPI Source Research ​

Status: implemented in pkg/source/pitchapi, with supported-source docs at docs/supported-sources/pitchapi.md. The REST tables and the Data plan's bulk export tables live in the same package.

Primary docs:

Connection ​

ItemValue
Base URLhttps://api.pitchapi.dev/v1
AuthX-API-KEY: pk_live_... request header (not Authorization)
Response envelope{"data": ...} on success, {"error":{"code","message"}} on failure
PaginationNone server-side: the cursor is a date, a league-season, or a match id
IDsOpaque strings with prefixes m_, t_, p_, l_, s_ (ex_ for export jobs); never cast to integers

Every response is the same envelope, so unwrapping is uniform — but the member inside data is not: data.leagues for the catalogue, data.matches for a date or a league-season, and objects or arrays for the per-match endpoints.

Tier Map ​

PlanPriceRequestsNotes
Free€015,000/day, 600/min, 60/min on /liveEvery league and every endpoint.
Pro€4.99/moNo daily cap, 1,200/min, 600/min on /liveOutbound webhooks.
Data€9.99/moSame as ProBulk exports: NDJSON or Parquet, 25 jobs a day.

The free plan is complete, which matters for how this source is described: nothing here is behind a plan except the _bulk tables, and those exist for volume, not access.

Main Table Coverage ​

Main tableCoveragePrimary endpointRequired tierPaging
LeaguesYesGET /leaguesFreeOne call, all 77.
TeamsYesGET /leagues/{id}/matches (team refs), or GET /teams/{id}FreeDerived from the match lists: one request per league instead of one per team.
PlayersYesGET /matches/{id}/players, then GET /players/{id}FreePer match, deduplicated across the run.
MatchesYesGET /date/{date} or GET /leagues/{id}/matches?season=FreeIterate dates, or one league-season.
ShotsYesGET /matches/{id}/shotsFreePer match; nested under data.periods[].shots.
EventsYesGET /matches/{id}/eventsFreePer match; data.events.
LineupsYesGET /matches/{id}/lineupsFreePer match; one object per team, starters and subs as arrays.
Player statsYesGET /matches/{id}/playersFreePer match; data is the array itself.
Match statsYesGET /matches/{id}/statsFreePer match; periods, groups and items.
Bulk exportsYesPOST /v1/exportsDataOne job per read, then a Parquet file.

Endpoint Map ​

Discovery ​

GET /leagues → data.leagues[] with id, name, country_code, image_url, seasons and is_free.

GET /date/{YYYY-MM-DD}?status=played|upcoming|all → data.matches[] with id, league, home_team, away_team, time_utc, status, score_home, score_away. This is the cheapest discovery call and the one the date-range mode uses.

GET /leagues/{id}/matches?season=2025/2026&status=all → data.matches[], a summary list that also carries date. Seasonless calls default to the latest season the league has data for; a league with no data answers 400 INVALID_PARAMETER.

Per-match endpoints ​

All of these take an m_ id and take no query parameters.

http
GET /matches/{id}/shots      → data.periods[].shots[]
GET /matches/{id}/events     → data.events[]
GET /matches/{id}/lineups    → data.home / data.away
GET /matches/{id}/players    → data[]  (an array, not an object)
GET /matches/{id}/stats      → data.periods[].groups[].items[]

A match that was never rated, or simply has nothing stored for that table, answers 404 RESOURCE_NOT_FOUND; 404 ANALYTICS_UNAVAILABLE is specific to the advanced endpoints. Both are permanent and must not be retried.

Bulk exports ​

POST /v1/exports with {"dataset","format","league?","season?","from?","to?"} → 202 and data.job. Poll GET /v1/exports/{id} until status is ready, then take data.download_url (a signed URL valid for 15 minutes). DELETE /v1/exports/{id} frees the object.

Datasets: matches, shots, events, lineups, player_stats, match_stats, teams, players. The last two are not match-scoped and refuse a filter with 400 INVALID_PARAMETER.

Backfill Strategy ​

REST for incremental reads — a date range, or one league-season. For a full history, the export API is the only realistic path: 77 leagues of shots is roughly 150k matches, one request each on REST, which is ten days of the entire free allowance before the match lists are counted. One export job replaces all of it with a single file.

bash
# Data plan: queue an export, then read the Parquet straight into DuckDB
curl -X POST https://api.pitchapi.dev/v1/exports \
  -H "X-API-KEY: $PITCHAPI_KEY" -H 'Content-Type: application/json' \
  -d '{"dataset":"shots","format":"parquet","season":"2025/2026"}'
duckdb pitch.duckdb -c "CREATE TABLE shots AS SELECT * FROM read_parquet('signed-url.parquet')"

Response Notes ​

  • Nested objects (league, home_team, away_team, player) stay objects; the connector lifts id to its own column and keeps the object as JSON, which is what the other football sources in this repo do.
  • 429 DAILY_QUOTA_EXCEEDED and 429 RATE_LIMIT_EXCEEDED carry Retry-After in seconds.
  • 403 PLAN_UPGRADE_REQUIRED means the resource needs a paid plan; 403 SUBSCRIPTION_SUSPENDED means the account's payment failed beyond the grace window.
  • 429 EXPORT_QUOTA_EXCEEDED is the 25-job daily allowance, resetting at 00:00 UTC.
  • 503 EXPORTS_UNAVAILABLE means the deployment does not sell exports at all, which is a permanent answer, not a transient one.
  • GET /date/{date} is edge-cached for settled dates, so a backfill by date is cheaper than it looks on the rate-limit arithmetic.

Implementation Notes ​

  • Strategies: replace for the whole-table reads (leagues, teams, the _bulk tables); delete+insert on date for shots, events and match_stats, so a corrected or removed row does not linger; merge for matches, players, lineups and player_stats. Use one destination table per league/season.
  • match_stats keys on group_name as well: the "Top stats" group repeats keys from the other groups.
  • players is merge rather than replace because its rows are derived from the matches in the window: replacing would keep only those players and drop the rest of the catalogue.
  • The rate limiter paces at 8 requests a second (Free allows 600/min, about 10/s), and a 429 is retried twice with the Retry-After the API sends.
  • Bulk reads download the Parquet to a temporary file and stream it through pqarrow, so a 2 GiB export never sits in memory.