FanGraphs Baseball Statistics Scraper avatar

FanGraphs Baseball Statistics Scraper

Pricing

from $0.29 / 1,000 item extracteds

Go to Apify Store
FanGraphs Baseball Statistics Scraper

FanGraphs Baseball Statistics Scraper

Export public FanGraphs MLB batting and pitching leaderboards with player and team IDs, WAR, standard statistics, and advanced metrics.

Pricing

from $0.29 / 1,000 item extracteds

Rating

0.0

(0)

Developer

Stas Persiianenko

Stas Persiianenko

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

2 days ago

Last modified

Categories

Share

Export public FanGraphs baseball statistics as structured player-season records. The Actor reads FanGraphs major-league batting and pitching leaderboards and returns player and team identifiers, season, standard statistics, WAR, rate metrics, and the complete scalar metric payload exposed by the selected leaderboard group.

Use it to refresh sabermetric research tables, prepare fantasy-baseball inputs, compare seasons, support scouting analysis, or feed reproducible data pipelines. It uses FanGraphs' public JSON leaderboard over a US residential proxy; it does not access member-only material, projections, playoff odds, or prospect rankings.

What can you extract?

  • batting or pitching player-season rows;
  • FanGraphs player ID and MLBAM ID when exposed;
  • FanGraphs team ID and team abbreviation;
  • season, age, games, plate appearances, or innings pitched;
  • WAR, AVG, OBP, SLG, OPS, ERA, WHIP, FIP, strikeout rate, and walk rate;
  • the complete scalar source response in stats for less common advanced metrics;
  • source URL and extraction timestamp for provenance.

Who is it for?

Sabermetric researchers can create repeatable season snapshots. Fantasy analysts can refresh model features without copying tables. Scouts and sports-data teams can compare player cohorts. Developers can send normalized JSON to a warehouse, spreadsheet, notebook, or scheduled automation.

For official game, schedule, roster, or standings records, use MLB StatsAPI Baseball Data Scraper. This Actor is specifically for FanGraphs leaderboard metrics.

Input parameters

FieldDescriptionDefault
statTypesbatting, pitching, or both['batting']
statGroupstandard or advanced FanGraphs leaderboard groupstandard
seasonsMLB season years from 1871 through the current yearprevious year
teamIdsOptional FanGraphs team IDsall teams
playerNameOptional case-insensitive name substringno filter
qualifiedOnlyApply FanGraphs' qualification thresholdfalse
maxItemsMaximum rows across all requested combinations100
proxyConfigurationApify residential US proxy configurationconfigured automatically

FanGraphs currently requires a US residential proxy. Disabling Apify Proxy causes the run to fail clearly rather than silently returning an empty dataset.

Getting started

  1. Open the Actor in Apify Console.
  2. Choose batting, pitching, or both.
  3. Select standard or advanced and enter one or more seasons.
  4. Optionally add team IDs, a player-name filter, or qualification filtering.
  5. Set maxItems and click Start.
  6. Download results from the Dataset tab as JSON, CSV, Excel, XML, or RSS.

Example input

{
"statTypes": ["batting", "pitching"],
"statGroup": "standard",
"seasons": [2024],
"qualifiedOnly": true,
"maxItems": 50
}

Output example

{
"recordType": "playerSeason",
"statType": "batting",
"statGroup": "standard",
"season": 2024,
"playerId": 12345,
"mlbamId": 654321,
"playerName": "Sample Player",
"teamId": 9,
"team": "NYY",
"games": 150,
"war": 5.4,
"battingAverage": 0.285,
"onBasePercentage": 0.375,
"sluggingPercentage": 0.51,
"ops": 0.885,
"stats": { "HR": 30, "wRC+": 132, "WAR": 5.4 },
"sourceUrl": "https://www.fangraphs.com/api/leaders/major-league/data?...",
"scrapedAt": "2025-01-15T12:00:00.000Z"
}

Fields that do not apply to the selected row type are omitted. stats preserves source metric names, including punctuation such as K% and wRC+.

How much does it cost to export FanGraphs baseball statistics?

Pricing has two parts: a $0.005 start fee and per-result pricing. At the BRONZE rate of $0.00048 per player-season row, 25 rows cost about $0.017, 100 rows about $0.053, and 1,000 rows about $0.485. Your active Apify plan tier may have a lower per-row price; Console shows the applicable rate before a run.

Only useful rows saved to the dataset are charged as item events. Invalid, duplicate, filtered-out, or failed rows are not charged as items. Proxy and platform usage are covered by pay-per-event pricing.

Pagination, filters, and limits

The Actor requests up to 200 leaderboard rows per page and follows pagination until maxItems or source exhaustion. A single team ID is sent to FanGraphs; multiple team IDs are consistently filtered from source rows. Player-name filtering is also applied before saving.

maxItems applies to the combined result across seasons and stat types.

Recurring research workflows

Schedule daily, weekly, or end-of-season runs and compare datasets by playerId, season, and statType. Send results to Google Sheets for fantasy review, to a database for longitudinal analysis, or to a model pipeline for feature refreshes. Keep sourceUrl and scrapedAt to document provenance and collection time.

API usage with cURL

curl -X POST "https://api.apify.com/v2/acts/automation-lab~fangraphs-baseball-statistics-scraper/runs?token=$APIFY_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"statTypes":["batting"],"seasons":[2024],"qualifiedOnly":true,"maxItems":25}'

API usage with JavaScript

import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('automation-lab/fangraphs-baseball-statistics-scraper').call({
statTypes: ['pitching'], seasons: [2024], qualifiedOnly: true, maxItems: 50,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);

API usage with Python

from apify_client import ApifyClient
client = ApifyClient('YOUR_APIFY_TOKEN')
run = client.actor('automation-lab/fangraphs-baseball-statistics-scraper').call(
run_input={'statTypes': ['batting', 'pitching'], 'seasons': [2024], 'maxItems': 100}
)
items = client.dataset(run['defaultDatasetId']).list_items().items

Use through MCP

Add the Apify MCP server in Claude Code:

claude mcp add --transport http apify \
"https://mcp.apify.com?tools=automation-lab/fangraphs-baseball-statistics-scraper"

Claude Desktop, Cursor, and VS Code setup

Use this equivalent MCP JSON configuration in Claude Desktop, Cursor, or VS Code:

{
"mcpServers": {
"apify": {
"url": "https://mcp.apify.com?tools=automation-lab/fangraphs-baseball-statistics-scraper"
}
}
}

Example prompt: “Export qualified 2024 FanGraphs pitching rows and summarize the top ten pitchers by WAR and FIP.”

Reliability and failure behavior

Requests use browser-like headers, US residential proxy sessions, strict JSON validation, and at most three attempts. A retry changes proxy identity for a Cloudflare challenge, timeout, rate limit, or transient server error. Invalid input and deterministic upstream errors are not retried blindly. If all attempts fail, the Actor exits non-zero and logs a concise cause.

Limitations

  • Public major-league leaderboards only.
  • No projections, playoff odds, prospect rankings, minor-league/member-only pages, or login support.
  • FanGraphs can add, rename, or remove fields; headline normalized fields remain stable while stats mirrors current scalar source keys.
  • Historic availability and qualification depend on FanGraphs.
  • Naturally empty filters produce an empty dataset.

Legality and responsible use

FanGraphs data may be subject to source terms and database rights. Collect only public data you are authorized to use, keep request volume reasonable, and comply with applicable law and contractual obligations. Do not use the Actor to circumvent accounts or redistribute restricted content.

Troubleshooting

The run says residential proxy is required. Restore the default proxy configuration with Apify Proxy, group RESIDENTIAL, and country US.

I received zero rows. Check the season, team IDs, name filter, and qualification setting. Try removing optional filters to distinguish a naturally empty cohort from an input mistake.

A field is missing. Some metrics only apply to batting or pitching and some source values are null. Inspect stats for the complete scalar payload returned by FanGraphs.

FAQ

Does it use an official FanGraphs API?

It uses the public JSON endpoint loaded by FanGraphs' major-league leaderboard. FanGraphs does not promise this as a versioned developer API, so changes may require maintenance.

Can I export both batting and pitching?

Yes. Select both values in statTypes; maxItems is shared across the combined output.

Can I search one player?

Use playerName for a case-insensitive substring and one or more seasons. Results still come from public leaderboard rows.

Can I schedule updates?

Yes. Use Apify schedules and integrations to rerun the same input and deliver each fresh dataset to your destination.