Skip to main content

headshot_url

headshot_url(
player_id: Any,
league: str,
id_system: str = 'espn',
) -> str | None

A headshot URL for one player.

Arguments​

NameTypeDescription
player_idAnyOne player id: an ESPN athlete id, or an nflverse gsis id.
leaguestrThe SDV league key. "espn" ids work for nfl, nba, wnba, mlb, nhl, cfb, mbb and wbb; "gsis" is NFL only.
id_systemstr"espn" (ESPN athlete id, any ESPN league) or "gsis" (mapped to ESPN through nflverse's player table, preferring nflverse's own headshot).

Returns​

str | None: The image URL, or None when the id is missing, malformed, or not in the player table.

Raises​

  • ValueError: If league has no ESPN headshots or id_system is not valid for league.
  • OfflineError: If id_system is "gsis" and the nflverse player table cannot be downloaded and no cached copy exists.

Example​

import sdvplot

sdvplot.headshot_url("3139477", "nfl")
# 'https://a.espncdn.com/combiner/i?img=/i/headshots/nfl/players/full/3139477.png'
sdvplot.headshot_url("00-0033873", "nfl", id_system="gsis") # Patrick Mahomes, an nfl.com URL ending .png

See also​