Skip to main content

Golf — ESPN web API (v3)

sportsdataverse.golf — 2 endpoints.

espn_golf_player_overview​

ESPN endpoint.

Endpoint URL: GET https://site.web.api.espn.com/apis/common/v3/sports/golf/pga/athletes/{athlete_id}/overview

Valid URL: https://site.web.api.espn.com/apis/common/v3/sports/golf/pga/athletes/4239/overview

API ParameterPythonPatternRequiredNullableDescription
athlete_idathlete_idYathlete_id path parameter.

Returns​

return_parsed=True (default) — a tidy polars.DataFrame with the columns below; pass return_as_pandas=True for a pandas.DataFrame.

col_nametypedescription
athlete_idInt64
athlete_display_nameString
athlete_short_nameString
athlete_positionString
athlete_jerseyString
athlete_team_idInt64
athlete_team_abbreviationString
split_nameString
split_categoryString
games_playedString
avg_minutesString
field_goal_pctString
three_point_pctString
free_throw_pctString
avg_reboundsString
avg_assistsString
avg_blocksString
avg_stealsString
avg_foulsString
avg_turnoversString
avg_pointsString

return_parsed=False — the raw JSON Dict payload, unparsed.

Raises​

ExceptionDescription
NoDataErrorThe host answered 404 -- the requested resource does not exist.
ValueErrorThe host answered 400 / 422 -- the request is wrong; retrying cannot help.
AssetFetchErrorThe fetch failed (a non-2xx answer or a connection failure after retries, e.g. 401/403/429/5xx, or an empty or unreadable 200 body) -- the answer is unknown, not empty.

Example​

espn_golf_player_overview(league='pga', athlete_id='4239')

espn_golf_leaders​

ESPN endpoint.

Endpoint URL: GET https://site.web.api.espn.com/apis/common/v3/sports/golf/pga/statistics/byathlete

Valid URL: https://site.web.api.espn.com/apis/common/v3/sports/golf/pga/statistics/byathlete?limit=50&page=1

API ParameterPythonPatternRequiredNullableDescription
categorycategoryYLeaderboard population: the athletes ranked in that category, whose values it fills (other categories come back null). Football takes <group>:<category> (offense:passing, offense:rushing, offense:receiving, defense:defensive, scoring:scoring); a bare passing is rejected with HTTP 400 (ValueError). Basketball takes the bare name (offensive).
seasonseasonYSeason year (e.g. 2024).
seasontypeseason_typeYSeason phase: 1=preseason, 2=regular season, 3=postseason.
limitlimitYMaximum number of items to return.
pagepageYpage query parameter.
sortsortYSort key <category>.<statName>:<asc|desc>, the names in the payload's categories (passing.passingYards:desc, offensive.avgPoints:desc). A stat without its category is rejected with HTTP 400 (ValueError).

Returns​

return_parsed=True (default) — a tidy polars.DataFrame with the columns below; pass return_as_pandas=True for a pandas.DataFrame.

col_nametypedescription
sort_orderInt64Position of the athlete in ESPN's leaderboard order (the requested category or sort), counted across pages: (page - 1) * limit + position on the page. A position, not a rank: tied athletes still count up; ESPN's per-stat ranks stay in the raw payload (return_parsed=False).
athlete_idInt64ESPN id of the athlete, the key the athlete endpoints (athlete_overview, athlete_stats) take.
athlete_uidStringESPN composite athlete uid (s:<sport>~l:<league>~a:<athlete id>), kept as text.
athlete_display_nameStringAthlete's full display name.
athlete_short_nameStringAthlete's abbreviated name (e.g. 'B. Nix').
athlete_first_nameStringAthlete's first name.
athlete_last_nameStringAthlete's last name.
athlete_positionStringAthlete's position abbreviation (e.g. QB, G, C).
athlete_statusStringAthlete's ESPN status name (e.g. Active, Inactive) as ESPN reports it at request time, not for the requested season.
team_idInt64ESPN id of the team the athlete played for in the requested season.
team_abbreviationStringAbbreviation of the athlete's team in the requested season (ESPN teamShortName, e.g. ORE).
team_nameStringNickname of the athlete's team in the requested season (ESPN teamName, e.g. Ducks).

return_parsed=False — the raw JSON Dict payload, unparsed.

Raises​

ExceptionDescription
NoDataErrorThe host answered 404 -- the requested resource does not exist.
ValueErrorThe host answered 400 / 422 -- the request is wrong; retrying cannot help.
AssetFetchErrorThe fetch failed (a non-2xx answer or a connection failure after retries, e.g. 401/403/429/5xx, or an empty or unreadable 200 body) -- the answer is unknown, not empty.

Example​

espn_golf_leaders(league='pga')