pybaseball icon indicating copy to clipboard operation
pybaseball copied to clipboard

Error accessing 'https://www.fangraphs.com/leaders-legacy.aspx'. Received status code 403

Open mattpfreer opened this issue 7 months ago • 9 comments

I am receiving the following error when I try to use the team_batting, team_pitching and team_fielding functions within pybaseball - does anyone know how to fix this?

Error accessing 'https://www.fangraphs.com/leaders-legacy.aspx'. Received status code 403

mattpfreer avatar May 13 '25 22:05 mattpfreer

I get the same error when trying to use pitching_stats.

Clem68 avatar May 14 '25 14:05 Clem68

The pitching_stats and team_batting calls have been working for me over the last few weeks that I've used them, up until last night, but as of this morning, and still this afternoon, I'm getting the same 403 as above.

aenfield avatar Jul 31 '25 23:07 aenfield

Im getting the same 403 issue. I looked into just trying to hit their API directly from a python script (not using pybaseball) and I get the 403.

I think the issue is that they added cloudfare verification around their API for "Verifying you are human"

BenHeath0 avatar Aug 01 '25 02:08 BenHeath0

I was getting a 403 yesterday with my own Fangraphs stuff, as well as pitching_stats(), and now neither gets an error. pitching_stats is returning an empty df if called today, but that's a separate issue lol

kchump avatar Aug 01 '25 14:08 kchump

I created a PR for changing the legacy page to current API. Maybe this will fix this issue. Not sure is there any restriction for the API though

https://github.com/jldbc/pybaseball/pull/398

ss77995ss avatar Aug 07 '25 18:08 ss77995ss

Trying to use either pitching_stats or batting_stats and getting "HTTPError: Error accessing 'https://www.fangraphs.com/leaders-legacy.aspx'. Received status code 403" as well. Does anyone know how to solve this? Tried #398 but didn't work

almirlimajr97 avatar Aug 24 '25 21:08 almirlimajr97

In my sample size of one month, this error has seemed transient. It worked for me today, fwiw.

aenfield avatar Aug 25 '25 20:08 aenfield

Idk whether this issue is because of the cloudflare they recently added or it's just an intermittent issue? Anybody knows the approach to solve it? or yeah, i probably need to change the source hahahaha

wibotron130823 avatar Aug 27 '25 23:08 wibotron130823

issue seems to be intermittent to me.

BenHeath0 avatar Aug 27 '25 23:08 BenHeath0