{
  "openapi": "3.0.1",
  "info": {
    "title": "Understat xG & Shot Data - Football Analytics",
    "description": "Scrapes Understat: player/team season aggregates, per-match xG/PPDA/win-probabilities, shot-level data with x/y coords + xG, situation/formation/game-state breakdowns, player career histories, and fixtures across the Big 5 + RFPL (2014–2025). Multi-season + multi-league in a single run.",
    "version": "1.0",
    "x-build-id": "7uMU5asDKlKZGVjLb"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/constructive_calm~understat-football-analytics/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-constructive_calm-understat-football-analytics",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/constructive_calm~understat-football-analytics/runs": {
      "post": {
        "operationId": "runs-sync-constructive_calm-understat-football-analytics",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/constructive_calm~understat-football-analytics/run-sync": {
      "post": {
        "operationId": "run-sync-constructive_calm-understat-football-analytics",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "required": [
          "mode"
        ],
        "properties": {
          "mode": {
            "title": "Scraping mode",
            "enum": [
              "league_players",
              "league_teams",
              "league_matches",
              "match_shots",
              "team_situations",
              "player_career",
              "fixtures"
            ],
            "type": "string",
            "description": "What to scrape. 'league_players' returns per-player season aggregates (xG, xA, xGChain, xGBuildup, etc). 'league_teams' returns team season aggregates (W/D/L, xG, xGA, PPDA, points, xPoints). 'league_matches' returns played-match metadata (xG, win-prob, deep, ppda). 'match_shots' returns every shot with x/y coords, xG, situation, body part, result. 'team_situations' returns long-format breakdowns by situation/formation/game-state/timing/zones. 'player_career' returns one player's full multi-season history. 'fixtures' returns upcoming matches.",
            "default": "league_players"
          },
          "leagues": {
            "title": "Leagues",
            "type": "array",
            "description": "One or more of the six leagues Understat covers. Required for league_*, match_shots (when matchIds is empty), team_situations (when teams is empty), and fixtures.",
            "items": {
              "type": "string",
              "enum": [
                "EPL",
                "La_liga",
                "Bundesliga",
                "Serie_A",
                "Ligue_1",
                "RFPL"
              ],
              "enumTitles": [
                "Premier League (England)",
                "La Liga (Spain)",
                "Bundesliga (Germany)",
                "Serie A (Italy)",
                "Ligue 1 (France)",
                "Russian Premier League"
              ]
            },
            "default": []
          },
          "seasons": {
            "title": "Seasons (start year)",
            "type": "array",
            "description": "List of season start years. 2024 = 2024/25 season. Understat history goes back to 2014 (the 2014/15 season). Multi-season is supported in a single run — pull 11 years of EPL in one go instead of 11 separate invocations.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "teams": {
            "title": "Teams (titles)",
            "type": "array",
            "description": "Team names exactly as Understat displays them — e.g. 'Arsenal', 'Manchester United', 'Real Madrid', 'Зенит'. Spaces become underscores in URLs automatically. Used by team_situations to filter to specific teams.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "matchIds": {
            "title": "Match IDs (skip enumeration)",
            "type": "array",
            "description": "Specific match IDs to scrape directly (used by match_shots). When set, leagues/seasons are ignored. Find IDs in Understat URLs: /match/{ID}.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "playerIds": {
            "title": "Player IDs",
            "type": "array",
            "description": "Player IDs for player_career mode. Find IDs in Understat URLs: /player/{ID}. Examples: 553 (Messi), 619 (Agüero), 1250 (Salah), 8260 (Haaland).",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "positions": {
            "title": "Positions filter",
            "type": "array",
            "description": "Filter players by position. Only applies to league_players mode (uses Understat's filtered POST endpoint).",
            "items": {
              "type": "string",
              "enum": [
                "GK",
                "D",
                "M",
                "F",
                "S",
                "Sub"
              ],
              "enumTitles": [
                "Goalkeeper",
                "Defender",
                "Midfielder",
                "Forward",
                "Striker",
                "Substitute"
              ]
            },
            "default": []
          },
          "nLastMatches": {
            "title": "Last N matches",
            "minimum": 0,
            "maximum": 50,
            "type": "integer",
            "description": "Filter player stats to the last N matches. 0 = full season. Only applies to league_players mode.",
            "default": 0
          },
          "dateStart": {
            "title": "Date from (YYYY-MM-DD)",
            "type": "string",
            "description": "Restrict league_players stats to matches on or after this date. Leave empty for none.",
            "default": ""
          },
          "dateEnd": {
            "title": "Date to (YYYY-MM-DD)",
            "type": "string",
            "description": "Restrict league_players stats to matches on or before this date. Leave empty for none.",
            "default": ""
          },
          "minAppearances": {
            "title": "Minimum appearances",
            "minimum": 0,
            "type": "integer",
            "description": "Drop player rows where games played is below this threshold (client-side filter). 0 = no filter.",
            "default": 0
          },
          "maxResults": {
            "title": "Max results",
            "minimum": 0,
            "maximum": 200000,
            "type": "integer",
            "description": "Stop emitting after this many dataset rows. 0 = unlimited (subject to maxCostUsd).",
            "default": 0
          },
          "maxCostUsd": {
            "title": "Max cost (USD per run)",
            "minimum": 1,
            "maximum": 1000,
            "type": "integer",
            "description": "Hard cap on the run's total billed amount. The actor estimates cost up-front and stops gracefully if the cap is hit mid-run. Default $25 protects you from accidental high-volume runs (e.g. all 6 leagues × 11 seasons of shots ≈ $375).",
            "default": 25
          },
          "includeRawJson": {
            "title": "Include raw Understat JSON",
            "type": "boolean",
            "description": "When true, attach the original Understat record under `_raw` on every output row. Useful for power users / debugging. Default off — keeps the dataset light.",
            "default": false
          },
          "proxyConfiguration": {
            "title": "Proxy configuration",
            "type": "object",
            "description": "Apify proxy. Understat does not block scrapers, but residential proxies help users behind corporate networks. Default = Apify residential.",
            "default": {
              "useApifyProxy": true,
              "apifyProxyGroups": [
                "RESIDENTIAL"
              ]
            }
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}