Skip to main content

Package — additional Python functions — IDs and crosswalks

find_athlete​

find_athlete(name: 'str', league: 'str', *, team: 'Optional[str]' = None, multi: 'bool' = False) -> 'Union[Optional[Dict[str, Any]], List[Dict[str, Any]]]'

Resolve an athlete name to ESPN athlete metadata.

Strategy: when a team= filter is given, hit that team's roster endpoint and search there (single fast call); otherwise iterate every team in the league and search their rosters (slower).

Parameters

ParameterTypeDefaultDescription
namestrAthlete identifier — full or partial name.
leaguestrLeague slug.
teamOptional[str]NoneOptional team filter (passed through to find_team). Strongly recommended for performance.
multiboolFalseIf True, return all matches.

Returns

Single athlete dict or list. Each entry contains the athlete's ESPN ID plus the team they were found on (so callers can immediately call espn_{league}_athlete_overview(athlete_id=...) or other athlete-scoped wrappers).

Raises

ExceptionDescription
ValueErrorleague is not one of the supported slugs.
NoDataErrorThe league's teams endpoint answered 404 (it is read to resolve team= or, without it, to list the teams to search).
AssetFetchErrorA teams or roster fetch failed (403, rate limit, 5xx, dead connection), so whether the athlete exists is unknown. A roster that answers 404 is skipped.

Example

from sportsdataverse.find import find_athlete
athlete = find_athlete("lebron", league="nba", team="lakers")
print(athlete["id"], athlete["team_id"])

# Every match across the league (one roster call per team)

find_athlete("smith", league="wnba", multi=True)

find_event​

find_event(date: 'str', league: 'str', *, home: 'Optional[str]' = None, away: 'Optional[str]' = None, multi: 'bool' = False) -> 'Union[Optional[Dict[str, Any]], List[Dict[str, Any]]]'

Resolve a game to its ESPN event ID via the scoreboard endpoint.

Parameters

ParameterTypeDefaultDescription
datestrYYYYMMDD (e.g. "20240617") or YYYY-MM-DD (e.g. "2024-06-17") — the latter is auto-normalized.
leaguestrLeague slug.
homeOptional[str]NoneOptional home-team filter (partial name OK).
awayOptional[str]NoneOptional away-team filter (partial name OK).
multiboolFalseIf True, return every event on that date matching the filters (useful for double-headers / Game 1 vs Game 2).

Returns

Single event dict (with the id you'd pass to espn_{league}_summary(event_id=...) / espn_{league}_pbp(game_id=...)) or a list when multi=True.

Raises

ExceptionDescription
ValueErrorleague is not one of the supported slugs, or date is not YYYYMMDD / YYYY-MM-DD.
NoDataErrorThe scoreboard endpoint answered 404.
AssetFetchErrorThe scoreboard fetch failed (403, rate limit, 5xx, dead connection), so the answer is unknown.

Example

from sportsdataverse.find import find_event
event = find_event("2024-06-17", league="nba", home="Boston")
print(event["id"], event["name"])

# Every game on a date (double-headers)

find_event("20240601", league="mlb", multi=True)

find_team​

find_team(name: 'str', league: 'str', *, multi: 'bool' = False) -> 'Union[Optional[Dict[str, Any]], List[Dict[str, Any]]]'

Resolve a team name to ESPN team metadata.

Performs case-insensitive substring matching against the team's displayName, location, shortDisplayName, name, abbreviation, and nickname fields. Returns the first match by default; pass multi=True to get every candidate.

Parameters

ParameterTypeDefaultDescription
namestrTeam identifier — full or partial name, location, or abbreviation. Case-insensitive.
leaguestrLeague slug ("nba", "wnba", "mbb", "wbb", "cfb", "nfl", "mlb", "nhl").
multiboolFalseIf True, return every match. Default is single-match (first hit; None if nothing matches).

Returns

Single team dict ({id, displayName, abbreviation, location, ...}) or None when nothing matches; or a list of all matches when multi=True.

Raises

ExceptionDescription
ValueErrorleague is not one of the supported slugs.
NoDataErrorThe teams endpoint answered 404.
AssetFetchErrorThe teams fetch failed (403, rate limit, 5xx, dead connection), so the answer is unknown.

Example

from sportsdataverse.find import find_team
team = find_team("lakers", league="nba")
print(team["id"], team["displayName"]) # the raw ESPN team dict (camelCase keys)

# Every candidate

find_team("new", league="nba", multi=True) # New Orleans Pelicans and New York Knicks

function_count​

function_count(league: 'Optional[str]' = None) -> 'Union[Dict[str, int], int]'

Count callable functions per league, or in one league.

Cheap way to verify "what's actually in the package" — useful as a sanity check after pulling a new version.

Parameters

ParameterTypeDefaultDescription
leagueOptional[str]NoneA league prefix ("mlb"); None counts every league.

Returns

dict[str, int] | int: {league: count} for every league, or the one league's count when league is given.

list_functions​

list_functions(league: 'Optional[str]' = None, *, search: 'Optional[str]' = None, parsers_only: 'bool' = False, wrappers_only: 'bool' = False) -> 'Union[Dict[str, List[str]], List[str]]'

Return an index of callable functions exposed by the package.

Parameters

ParameterTypeDefaultDescription
leagueOptional[str]NoneLeague slug ("nba" / "wnba" / "mbb" / "wbb" / "cfb" / "nfl" / "mlb" / "nhl"). When given, returns a flat list of function names for that league. With no league, returns a dict keyed by league.
searchOptional[str]NoneCase-insensitive substring to filter function names. search="roster" matches every *_roster / roster_* / parse_*_roster function across leagues.
parsers_onlyboolFalseIf True, restrict the result to parse_* callables.
wrappers_onlyboolFalseIf True, exclude parse_* callables.

Returns

Dict (no league) or list (one league) of function names. Names are sorted alphabetically within each league.