{
  "openapi": "3.0.1",
  "info": {
    "title": "MLB Stats Scraper - Teams, Rosters, Scores & Standings",
    "description": "Scrape MLB teams, team rosters with player season stats, game scores and schedules, and division/league standings. No API key required.",
    "version": "1.0",
    "x-build-id": "KrZfP0bQ3b9eHnOA9"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/seemuapps~mlb-stats-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-seemuapps-mlb-stats-scraper",
        "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/seemuapps~mlb-stats-scraper/runs": {
      "post": {
        "operationId": "runs-sync-seemuapps-mlb-stats-scraper",
        "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/seemuapps~mlb-stats-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-seemuapps-mlb-stats-scraper",
        "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": "Mode",
            "enum": [
              "teams",
              "roster",
              "schedule",
              "standings",
              "playerStats",
              "gameDetails",
              "leaders"
            ],
            "type": "string",
            "description": "What to scrape. 'teams' lists all MLB teams. 'roster' returns a team's active roster with player season stats. 'schedule' returns games/scores for a date or date range. 'standings' returns division and league standings. 'playerStats' returns full season stat lines for specific players or teams. 'gameDetails' returns per-team box score lines (2 rows per game). 'leaders' returns ranked statistical leaderboards.",
            "default": "teams"
          },
          "teamId": {
            "title": "Team ID (roster mode)",
            "type": "integer",
            "description": "MLB team ID for 'roster' mode, e.g. 147 for the New York Yankees. Run 'teams' mode first to look up IDs. Ignored in other modes."
          },
          "teamAbbreviation": {
            "title": "Team abbreviation (roster mode)",
            "type": "string",
            "description": "Optional alternative to Team ID for 'roster' mode, e.g. 'NYY'. Used only if Team ID is not set. Ignored in other modes."
          },
          "date": {
            "title": "Date (schedule / gameDetails mode)",
            "type": "string",
            "description": "Single date in YYYY-MM-DD format for 'schedule' mode, or for 'gameDetails' mode when Game PKs are not set. Leave empty to use today's date, or set Start Date / End Date instead for a range. Ignored in other modes."
          },
          "startDate": {
            "title": "Start date (schedule / gameDetails mode, optional range)",
            "type": "string",
            "description": "Start of a date range (YYYY-MM-DD) for 'schedule' mode or for 'gameDetails' mode when Game PKs are not set. Requires End Date to also be set; overrides Date when both are present. Ignored in other modes."
          },
          "endDate": {
            "title": "End date (schedule / gameDetails mode, optional range)",
            "type": "string",
            "description": "End of a date range (YYYY-MM-DD) for 'schedule' mode or for 'gameDetails' mode when Game PKs are not set. Requires Start Date to also be set. Ignored in other modes."
          },
          "gameType": {
            "title": "Game type",
            "enum": [
              "R",
              "S",
              "F",
              "D",
              "L",
              "W",
              "A"
            ],
            "type": "string",
            "description": "Filters games by MLB game type in 'schedule' mode and in 'gameDetails' mode (when Game PKs are not set), and tags the game type used for 'leaders' mode. Default is Regular Season. Note: MLB has no single generic 'postseason' filter — select the specific postseason round (Wild Card, Division Series, LCS, or World Series).",
            "default": "R"
          },
          "leagueId": {
            "title": "League (standings mode)",
            "enum": [
              "AL",
              "NL",
              "BOTH"
            ],
            "type": "string",
            "description": "Which league's standings to return in 'standings' mode. Ignored in other modes.",
            "default": "BOTH"
          },
          "seasons": {
            "title": "Seasons (playerStats / standings / leaders modes)",
            "type": "array",
            "description": "Four-digit season years, e.g. ['2025','2026']. Used by 'playerStats', 'standings', and 'leaders' modes — when multiple seasons are given, each mode loops over all of them and tags every output row with its 'season' field so a multi-season run stays separable in one dataset. Leave empty to use the current season. In 'roster' mode only the first season is used (roster reflects the current team, not a historical one). Ignored in 'teams', 'schedule', and 'gameDetails' modes.",
            "items": {
              "type": "string"
            }
          },
          "teamIds": {
            "title": "Team IDs (playerStats mode)",
            "type": "array",
            "description": "MLB team IDs for 'playerStats' mode. Every player on each team's active roster gets a stat line for the selected Stat group and each selected season. Ignored if Player IDs is set. Ignored in other modes.",
            "items": {
              "type": "string"
            }
          },
          "playerIds": {
            "title": "Player IDs (playerStats mode)",
            "type": "array",
            "description": "MLB player IDs for 'playerStats' mode, e.g. ['592450'] for Aaron Judge. When set, fetches these specific players' stats directly instead of resolving via Team IDs. Ignored in other modes.",
            "items": {
              "type": "string"
            }
          },
          "statGroup": {
            "title": "Stat group (playerStats / leaders modes)",
            "enum": [
              "hitting",
              "pitching",
              "fielding"
            ],
            "type": "string",
            "description": "Which stat category to return in 'playerStats' and 'leaders' modes. Ignored in other modes.",
            "default": "hitting"
          },
          "leaderCategories": {
            "title": "Leader categories (leaders mode)",
            "type": "array",
            "description": "MLB stat leader category keys for 'leaders' mode, e.g. ['homeRuns','battingAverage','earnedRunAverage','strikeouts','saves']. Must match the selected Stat group (hitting categories with statGroup=hitting, pitching categories with statGroup=pitching, etc). Defaults to ['homeRuns']. Ignored in other modes.",
            "items": {
              "type": "string"
            }
          },
          "gamePks": {
            "title": "Game PKs (gameDetails mode)",
            "type": "array",
            "description": "Specific MLB game IDs (gamePk) for 'gameDetails' mode, e.g. ['824911']. When set, fetches box scores for exactly these games instead of deriving games from Date / Start Date / End Date. Ignored in other modes.",
            "items": {
              "type": "string"
            }
          },
          "maxItems": {
            "title": "Max items",
            "minimum": 0,
            "type": "integer",
            "description": "Maximum dataset records to return in this run. 0 = no cap. 'gameDetails' mode produces 2 rows per game, so its effective game count is roughly half this value (also safety-capped at 50 games when unlimited). Mainly relevant for 'roster', 'schedule', 'playerStats', 'gameDetails', and 'leaders' modes; 'teams' always returns 30 or fewer and 'standings' returns one record per team per season.",
            "default": 100
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}