MLB Roster & Player Stats Exporter

Export official MLB roster player bios and season statistics.

Data fields

FieldTypeDescription
recordTypestringValue exported as recordType.
playerIdinteger | nullValue exported as playerId.
fullNamestringValue exported as fullName.
firstNamestring | nullValue exported as firstName.
lastNamestring | nullValue exported as lastName.
nameSlugstring | nullValue exported as nameSlug.
teamIdinteger | nullValue exported as teamId.
teamNamestring | nullValue exported as teamName.

Input preview

modeExport mode
teamIdsMLB team IDs
playerIdsMLB player IDs
seasonSeason
statGroupsStatistic groups
includeStatsInclude season statistics

API and agents

This actor can be run through Apify API, datasets, webhooks, schedules, and the official Apify MCP server.

Ready-to-run examples

Open a saved Apify example, adjust the input, and run the actor in your own Apify account.

View all examples

How this actor works

See example inputs, outputs, API usage, and practical limits before running this actor on Apify.

Open Apify page

MLB Stats Scraper exports official public MLB roster bios and season player statistics into clean, analysis-ready records. Build a repeatable MLB stats API workflow for fantasy research, baseball player statistics analysis, editorial research, and roster reporting—without an MLB login.

Each result combines player identity, team and position context, biographical details, the selected season/stat group, the complete available statistics object, and a source link. A single request can cover one team, multiple teams, or a known list of player IDs.

Who is it for?

  • Fantasy and sports analysts who need current roster context alongside season statistics.
  • Reporters and researchers building reproducible baseball player statistics exports.
  • Data teams and developers that need structured player data in an Apify dataset for downstream workflows.
  • AI agents that need a bounded, attributable MLB roster or player-stat lookup.

What you get

One normalized record is exported for each player and requested statistic group. Rows retain the official statistics object and source URL for traceability.

  • Player identity: playerId, fullName, firstName, lastName, and nameSlug
  • Roster context: teamId, teamName, jerseyNumber, rosterStatus, and position fields
  • Player bio: birth details, age, height, weight, batting side, throwing hand, and MLB debut date when supplied
  • Statistics: season, statGroup, and the complete available stats object
  • Provenance: sourceUrl, sourceTeamId, and retrievedAt

Input recipe

{
  "mode": "roster",
  "teamIds": [147, 121],
  "season": 2025,
  "statGroups": ["hitting", "pitching", "fielding"],
  "includeStats": true,
  "maxItems": 50
}

Input settings

Input Description
mode Use roster for selected team rosters or playerStats for explicit player IDs.
teamIds MLB team IDs used by roster mode. For example, 147 is the New York Yankees.
playerIds MLB player IDs required by playerStats mode.
season Season year for official player statistics.
statGroups Any combination of hitting, pitching, and fielding.
includeStats Set to false for roster biographies only.
maxItems Global player-record cap. Start low when testing a workflow.

Example output

{
  "recordType": "mlbPlayerRosterStat",
  "playerId": 645305,
  "fullName": "Ali Sánchez",
  "teamId": 147,
  "teamName": "New York Yankees",
  "positionAbbreviation": "C",
  "season": 2025,
  "statGroup": "hitting",
  "stats": { "gamesPlayed": 12, "hits": 5, "avg": ".217" },
  "sourceUrl": "https://statsapi.mlb.com/api/v1/teams/147/roster?...",
  "retrievedAt": "2026-08-27T00:00:00.000Z"
}

Use cases

Build a team roster export

Choose mode: "roster", add one or more teamIds, and use a moderate maxItems value. Select only the statistic groups your analysis needs to keep the output focused.

Look up known players

Choose mode: "playerStats" and supply playerIds. This works well when a separate workflow already has a shortlist of public MLB player IDs.

Create a bio-only roster dataset

Set includeStats to false to return roster and player biography fields without a requested statistics object.

Tips and limits

  • Use a low maxItems value to validate input and output before a larger export.
  • A player can have one row for each requested statistic group; this keeps hitting, pitching, and fielding values unambiguous.
  • The source can omit an optional player biography value or a statistic for a player. Those values are returned as null, never guessed.
  • This focused version exports roster and player-stat records. It does not export schedules, standings, scores, or game-detail entities.
  • Results reflect the selected season and data currently available from the official public source.

API usage

Use the Actor API with the same JSON input shown above. Results are written to the run's default dataset.

Node.js

import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('fetch_cat/mlb-stats-scraper').call({
  mode: 'roster', teamIds: [147], season: 2025,
  statGroups: ['hitting'], maxItems: 25,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);

Python

from apify_client import ApifyClient
client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("fetch_cat/mlb-stats-scraper").call(run_input={
    "mode": "roster", "teamIds": [147], "season": 2025,
    "statGroups": ["hitting"], "maxItems": 25,
})
items = client.dataset(run["defaultDatasetId"]).list_items().items
print(items)

cURL

curl "https://api.apify.com/v2/acts/fetch_cat~mlb-stats-scraper/runs?token=$APIFY_TOKEN" \
  -H 'content-type: application/json' \
  -d '{"mode":"roster","teamIds":[147],"season":2025,"statGroups":["hitting"],"maxItems":25}'

MCP and AI agents

Add this Actor to an MCP client to let an agent request a bounded roster or player-stat export.

claude mcp add apify -- npx -y @apify/mcp-server
{
  "mcpServers": {
    "apify": {
      "command": "npx",
      "args": ["-y", "@apify/mcp-server"],
      "env": { "APIFY_TOKEN": "YOUR_APIFY_TOKEN" }
    }
  }
}

Use the MCP endpoint https://mcp.apify.com?tools=fetch_cat/mlb-stats-scraper. Example prompts:

  • “Export up to 25 2025 hitting-stat roster records for MLB team ID 147.”
  • “Return 10 2025 pitching-stat records for player IDs 592450 and 543037.”

Support

Need help with an input or result? Open an issue on this Actor's Apify page and include a reproducible report:

  • Run: the Apify run ID and URL, for example final validation run 7DkJbupSs53DcNUdQ.
  • Complete input JSON: paste the full submitted JSON, such as:
{
  "mode": "roster",
  "teamIds": [147],
  "season": 2025,
  "statGroups": ["hitting"],
  "includeStats": true,
  "maxItems": 20
}
  • Expected vs. actual: state the expected record count/field values and paste one actual row or the exact error message. For the example above, expect up to 20 mlbPlayerRosterStat rows with season: 2025, statGroup: "hitting", and a populated sourceUrl; report the returned count and the first row if it differs.
  • Public source: include the reproducible official source URL, such as https://statsapi.mlb.com/api/v1/teams/147/roster for this Yankees request.

Do not include API tokens or other secrets in a support report.

Common questions

Questions and answers reused from the canonical actor README.

What data can I export with MLB Stats Scraper?

Each record includes official player identity, roster assignment, position, public biography fields, requested season/stat group, available statistics, and source provenance.

Can I run MLB Roster & Player Stats Exporter through an API, schedule, or MCP client?

Yes. Use the API input shown above, schedule the same validated input in Apify, or add the listed MCP endpoint to a compatible client.

How much does it cost to use MLB Roster & Player Stats Exporter?

Billing is per exported player-stat record plus the one-time run start event. Check the live Pricing tab for your current rate.

Do I need an MLB account?

No. This Actor exports data available from official public MLB sources.

Why are there multiple rows for one player?

A row is emitted per requested statistic group so values remain unambiguous.