MLB player stats scraper on the official MLB stats API: season hitting, pitching and fielding stats per player (AVG, HR, RBI, OPS, ERA, WHIP, strikeouts) with team, league and position, ranked, as clean data.
MLB player season stats from the official MLB stats API
(statsapi.mlb.com/api/v1/stats). src/client.py: curl-cffi with a
Chrome/Firefox/Safari impersonation tuple, fresh proxy session id and
profile on every retry, backoff 2s doubling to 30s, max 5 attempts, honours
Retry-After; a request router refuses every URL that is not
/api/v1/stats on the Stats API host before any network I/O.
src/parser.py: flattens splits[].stat{} into typed columns (integer
counts, numeric rates, innings kept in baseball notation) plus player, team,
league and position identity.
src/scraper.py: offset pager at limit=50 over (season, group) jobs,
stopping on offset >= totalSplits, an empty page or a page with nothing
new; run-wide dedupe on (season, group, player, team, position);
per-job fault isolation. An empty leaderboard finishes SUCCEEDED with zero
rows; a block with nothing emitted fails the run.
Default proxy is Apify Proxy datacenter (keyless public feed).
Offline tests against trimmed real captures (no live network).