{
  "openapi": "3.0.1",
  "info": {
    "title": "FPL Intelligence - Picks, Optimizer, Watchlist, History",
    "description": "Fantasy Premier League intelligence: weekly captain & transfer picks, wildcard optimizer, mini-league insights, price-change predictor, manager dashboard, live tracker, 10 seasons of history.",
    "version": "1.0",
    "x-build-id": "0qc4uRP54F3Rd8wsS"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/constructive_calm~fpl-intelligence/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-constructive_calm-fpl-intelligence",
        "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~fpl-intelligence/runs": {
      "post": {
        "operationId": "runs-sync-constructive_calm-fpl-intelligence",
        "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~fpl-intelligence/run-sync": {
      "post": {
        "operationId": "run-sync-constructive_calm-fpl-intelligence",
        "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": "What do you want to do?",
            "enum": [
              "gameweek_picks",
              "wildcard_optimizer",
              "mini_league_intel",
              "price_change_predictor",
              "manager_dashboard",
              "live_tracker",
              "historical_seasons"
            ],
            "type": "string",
            "description": "Pick a workflow. Each mode emits a distinct output row shape — see README for samples and which mode fits your use case.",
            "default": "gameweek_picks"
          },
          "managerIds": {
            "title": "Manager IDs",
            "type": "array",
            "description": "Your FPL manager ID(s). Find yours in the URL when logged in: fantasy.premierleague.com/entry/<your-id>/event/N. Required for manager_dashboard. Optional for live_tracker.",
            "items": {
              "type": "string"
            },
            "default": []
          },
          "leagueIds": {
            "title": "Mini-League IDs",
            "type": "array",
            "description": "Mini-league ID(s) — the number in the URL when viewing a league. ID 314 is the Overall global league everyone is in. Required for mini_league_intel.",
            "items": {
              "type": "string"
            },
            "default": []
          },
          "gameweek": {
            "title": "Gameweek (optional)",
            "minimum": 1,
            "maximum": 38,
            "type": "integer",
            "description": "Which gameweek to analyze. If omitted, defaults to the current/next gameweek. Required for live_tracker."
          },
          "picksTopN": {
            "title": "Picks: how many candidates per category",
            "minimum": 3,
            "maximum": 20,
            "type": "integer",
            "description": "gameweek_picks mode. Top-N candidates per category (captain / transfer-in / differential / sell).",
            "default": 5
          },
          "picksDifferentialThresholdPct": {
            "title": "Picks: differential ownership threshold",
            "minimum": 0.1,
            "maximum": 25,
            "type": "number",
            "description": "gameweek_picks mode. Max global ownership %% for a player to qualify as a differential.",
            "default": 5
          },
          "picksFixtureLookahead": {
            "title": "Picks: fixture lookahead window",
            "minimum": 1,
            "maximum": 8,
            "type": "integer",
            "description": "gameweek_picks mode. How many upcoming fixtures to weight in the difficulty score.",
            "default": 3
          },
          "optimizerBudget": {
            "title": "Optimizer: budget (£m)",
            "minimum": 80,
            "maximum": 110,
            "type": "number",
            "description": "wildcard_optimizer mode. Total squad budget in £m. Default 100.0 is the FPL game default.",
            "default": 100
          },
          "optimizerLockedPlayers": {
            "title": "Optimizer: locked player IDs",
            "type": "array",
            "description": "wildcard_optimizer mode. FPL element IDs the optimizer must include in the final squad (e.g. 430 for Haaland). Use this to force premium picks.",
            "items": {
              "type": "string"
            }
          },
          "optimizerExcludedPlayers": {
            "title": "Optimizer: excluded player IDs",
            "type": "array",
            "description": "wildcard_optimizer mode. FPL element IDs the optimizer must exclude.",
            "items": {
              "type": "string"
            }
          },
          "optimizerExcludedTeams": {
            "title": "Optimizer: excluded team IDs",
            "type": "array",
            "description": "wildcard_optimizer mode. FPL team IDs to skip entirely (e.g. a club whose fixtures are too tough).",
            "items": {
              "type": "string"
            }
          },
          "leagueTopManagersPerLeague": {
            "title": "League: top-N managers to fetch",
            "minimum": 5,
            "maximum": 1000,
            "type": "integer",
            "description": "mini_league_intel mode. How many top-ranked managers per league to fetch + analyze. Larger = slower + more cost.",
            "default": 50
          },
          "leagueCompareToManagerId": {
            "title": "League: your manager ID (for you-vs-field)",
            "type": "string",
            "description": "mini_league_intel mode. Optional. Your manager ID to compute your-vs-the-field deltas (captain match, differentials you have/miss)."
          },
          "priceMinConfidence": {
            "title": "Price: min confidence",
            "minimum": 0,
            "maximum": 1,
            "type": "number",
            "description": "price_change_predictor mode. Only emit predictions with at least this confidence (0..1).",
            "default": 0.5
          },
          "priceIncludeNeutral": {
            "title": "Price: include neutral signals",
            "type": "boolean",
            "description": "price_change_predictor mode. If true, emit a row for every player even if no change predicted (useful for raw transfer data).",
            "default": false
          },
          "liveRefreshIntervalSec": {
            "title": "Live: refresh interval (seconds)",
            "minimum": 0,
            "maximum": 600,
            "type": "integer",
            "description": "live_tracker mode. If > 0, poll this many seconds between snapshots until maxSnapshots is reached. 0 = single snapshot.",
            "default": 0
          },
          "liveMaxSnapshots": {
            "title": "Live: max snapshots",
            "minimum": 1,
            "maximum": 50,
            "type": "integer",
            "description": "live_tracker mode. Cap on snapshots even if refreshIntervalSec > 0. Each snapshot fires a billable live-snapshot event.",
            "default": 1
          },
          "historicalSeasons": {
            "title": "Historical: seasons",
            "type": "array",
            "description": "historical_seasons mode. FPL seasons in YYYY-YY format (e.g. '2024-25'). Pass 'all' for all 10 archived seasons. Tier note: 2021-22+ has full xG data; 2016-17 to 2017-18 are basic stats only.",
            "items": {
              "type": "string"
            },
            "default": [
              "2024-25"
            ]
          },
          "historicalDataType": {
            "title": "Historical: data type",
            "enum": [
              "per_gameweek",
              "season_totals_only",
              "fixtures_only",
              "players_only"
            ],
            "type": "string",
            "description": "historical_seasons mode. What to pull. per_gameweek is the heaviest (~600 rows × N gameweeks per season).",
            "default": "per_gameweek"
          },
          "historicalGameweeksFilter": {
            "title": "Historical: gameweek filter",
            "type": "array",
            "description": "historical_seasons mode. Optional. Limit to specific gameweeks (e.g. ['1','2','3']). Empty = all 38.",
            "items": {
              "type": "string"
            }
          },
          "enableAiVerdict": {
            "title": "Enable AI verdict (Gemini)",
            "type": "boolean",
            "description": "Adds a 1-paragraph 'manager's brief' (captain rec + reasoning + sell candidates) using Gemini 2.5 Flash. Costs +$0.05 per verdict event. Available in gameweek_picks mode.",
            "default": false
          },
          "maxItems": {
            "title": "Max output items",
            "minimum": 1,
            "maximum": 100000,
            "type": "integer",
            "description": "Hard cap on output rows for safety. Tune up for historical seasons mode (a single season has ~600 rows × 38 GWs = 22,800 rows).",
            "default": 1000
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}