π§ More sources with sportsdataverse-py
This page is the executed notebook
19_more_sources_intro.ipynb: download it to run it yourself.
Four smaller surfaces, one notebook:
| Surface | Module | Provider |
|---|---|---|
| NBA G League | sportsdataverse.nbagl | ESPN |
| Formula 1 | sportsdataverse.f1 | Jolpica (the Ergast API successor) |
| TheSportsDB | sportsdataverse.providers.thesportsdb | TheSportsDB (free tier) |
| ESPN content | sportsdataverse.providers.espn_content | ESPN news API |
No API keys needed.
π§° The toolboxβ
| Function | What it gives you |
|---|---|
espn_nbagl_standings | G League standings |
espn_nbagl_scoreboard | G League scoreboard |
f1_schedule | Race calendar of a season |
f1_driver_standings | Drivers' championship |
f1_results | Race classification |
f1_laps | Every lap of a race, all pages |
thesportsdb_leagues | Leagues TheSportsDB knows |
thesportsdb_table | A league table |
espn_content_news | Cross-sport headlines |
espn_content_league_news | Headlines for one league |
π Setupβ
pip install "sportsdataverse[sdvplot]"
The sdvplot extra brings in sdvplot and matplotlib for the charts.
import matplotlib.pyplot as plt
import polars as pl
from sportsdataverse import f1, nbagl
from sportsdataverse.providers import espn_content, thesportsdb
pl.Config.set_tbl_rows(10)
pl.Config.set_fmt_str_lengths(60)
polars.config.Config
Provider feeds are seasonal and occasionally rate-limited, so a tiny safe() helper runs each call
defensively: you get the frame when the feed is up, and a one-line skip when it isn't, naming whether
the answer was nothing there (NoDataError) or the fetch failed (AssetFetchError). π
from sportsdataverse.errors import AssetFetchError, NoDataError
def safe(label, thunk):
try:
out = thunk()
print(f"β
{label}")
return out
except (NoDataError, AssetFetchError) as e:
print(f"\u23ed\ufe0f {label}: {type(e).__name__}: {e}")
return None
π NBA G Leagueβ
The G League rides the cross-league ESPN wrappers (espn_nbagl_*).
espn_nbagl_standings takes a season (END year),
and sdvplot's team_colors("nbagl", ...) resolves ESPN team ids to each team's color.
The nbagl_enhanced_pbp / nbagl_possessions / nbagl_rapm_from_games helpers in the same module
read stats.nba.com, which blocks datacenter IPs, so this notebook does not call them.
import sdvplot
gst = safe("G League standings 2026", lambda: nbagl.espn_nbagl_standings(season=2026))
if gst is not None and gst.height:
top = gst.sort("win_percent", "point_differential")
colors = [c or "#999999" for c in sdvplot.team_colors("nbagl", [str(i) for i in top["team_id"]])]
fig, ax = plt.subplots(figsize=(7, 8))
ax.barh(top["team_display_name"], top["win_percent"], color=colors)
ax.set_xlabel("win %")
ax.set_title("G League 2025-26 standings")
plt.tight_layout()
plt.show()
else:
print("standings unavailable")
β
G League standings 2026

gsb = safe("G League scoreboard", nbagl.espn_nbagl_scoreboard)
cols = ["date", "short_name", "status_type_detail", "home_score", "away_score"]
gsb.select([c for c in cols if c in gsb.columns]).head() if gsb is not None and gsb.height else "no games today"
β
G League scoreboard
shape: (2, 5)
βββββββββββββββββββββ¬βββββββββββββ¬βββββββββββββββββββββ¬βββββββββββββ¬βββββββββββββ
β date β short_name β status_type_detail β home_score β away_score β
β --- β --- β --- β --- β --- β
β str β str β str β str β str β
βββββββββββββββββββββͺβββββββββββββͺβββββββββββββββββββββͺβββββββββββββͺβββββββββββββ‘
β 2026-12-01T00:00Z β MNE @ CPS β Final β 103 β 105 β
β 2026-12-01T01:00Z β MHU @ RGV β Final β 114 β 110 β
βββββββββββββββββββββ΄βββββββββββββ΄βββββββββββββββββββββ΄βββββββββββββ΄βββββββββββββ
ποΈ Formula 1β
The F1 helpers take season and round as strings.
f1_driver_standings returns the table after a season's
last round; f1_laps pages through every lap of a race.
F1_SEASON = "2025"
dst = safe(f"F1 driver standings {F1_SEASON}", lambda: f1.f1_driver_standings(F1_SEASON))
cols = ["position", "driver_given_name", "driver_family_name", "constructors", "points", "wins"]
dst.select([c for c in cols if c in dst.columns]).head(10) if dst is not None else None
β
F1 driver standings 2025
shape: (10, 6)
ββββββββββββ¬ββββββββββββββββββββ¬βββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ¬βββββββββ¬βββββββ
β position β driver_given_name β driver_family_name β constructors β points β wins β
β --- β --- β --- β --- β --- β --- β
β i64 β str β str β str β f64 β i64 β
ββββββββββββͺββββββββββββββββββββͺβββββββββββββββββββββͺβββββββββββββββββββββββββββββββͺβββββββββͺβββββββ‘
β 1 β Lando β Norris β [{"constructorId": β 423.0 β 7 β
β β β β "mclaren", "url": β β β
β β β β "https://en.wikipedia.oβ¦ β β β
β 2 β Max β Verstappen β [{"constructorId": β 421.0 β 8 β
β β β β "red_bull", "url": β β β
β β β β "https://en.wikipedia.β¦ β β β
β 3 β Oscar β Piastri β [{"constructorId": β 410.0 β 7 β
β β β β "mclaren", "url": β β β
β β β β "https://en.wikipedia.oβ¦ β β β
β 4 β George β Russell β [{"constructorId": β 319.0 β 2 β
β β β β "mercedes", "url": β β β
β β β β "https://en.wikipedia.β¦ β β β
β 5 β Charles β Leclerc β [{"constructorId": β 242.0 β 0 β
β β β β "ferrari", "url": β β β
β β β β "https://en.wikipedia.oβ¦ β β β
β 6 β Lewis β Hamilton β [{"constructorId": β 156.0 β 0 β
β β β β "ferrari", "url": β β β
β β β β "https://en.wikipedia.oβ¦ β β β
β 7 β Andrea Kimi β Antonelli β [{"constructorId": β 150.0 β 0 β
β β β β "mercedes", "url": β β β
β β β β "https://en.wikipedia.β¦ β β β
β 8 β Alexander β Albon β [{"constructorId": β 73.0 β 0 β
β β β β "williams", "url": β β β
β β β β "https://en.wikipedia.β¦ β β β
β 9 β Carlos β Sainz β [{"constructorId": β 64.0 β 0 β
β β β β "williams", "url": β β β
β β β β "https://en.wikipedia.β¦ β β β
β 10 β Fernando β Alonso β [{"constructorId": β 56.0 β 0 β
β β β β "aston_martin", "url": β β β
β β β β "https://en.wikipeβ¦ β β β
ββββββββββββ΄ββββββββββββββββββββ΄βββββββββββββββββββββ΄βββββββββββββββββββββββββββββββ΄βββββββββ΄βββββββ
laps = safe(f"F1 laps {F1_SEASON} round 1", lambda: f1.f1_laps(F1_SEASON, "1"))
res = safe(f"F1 results {F1_SEASON} round 1", lambda: f1.f1_results(F1_SEASON, "1"))
if laps is not None and laps.height and res is not None and res.height:
top5 = res.sort(pl.col("position").cast(pl.Int64, strict=False)).head(5)["driver_id"].to_list()
fig, ax = plt.subplots(figsize=(9, 4))
for d in top5:
s = laps.filter(pl.col("driver_id") == d).sort("lap_number")
ax.plot(s["lap_number"], s["position"].cast(pl.Int64, strict=False), label=d)
ax.invert_yaxis()
ax.set_xlabel("lap")
ax.set_ylabel("position")
ax.set_title(f"{res['race_name'][0]} {F1_SEASON}: the top five finishers, lap by lap")
ax.legend(fontsize=8)
plt.show()
else:
print("lap data unavailable")
β
F1 laps 2025 round 1
β
F1 results 2025 round 1

π TheSportsDBβ
TheSportsDB's free tier serves a sample of its catalog (a handful of leagues, five rows of a table),
which is enough to see the shape. thesportsdb_table
takes the league id and a season label such as "2024-2025" (4328 is the English Premier League).
safe("TheSportsDB leagues", thesportsdb.thesportsdb_leagues)
β
TheSportsDB leagues
shape: (10, 3)
βββββββββββββ¬ββββββββββββββββββββββββββββββ¬ββββββββββββ
β id_league β str_league β str_sport β
β --- β --- β --- β
β str β str β str β
βββββββββββββͺββββββββββββββββββββββββββββββͺββββββββββββ‘
β 4328 β English Premier League β Soccer β
β 4329 β English League Championship β Soccer β
β 4330 β Scottish Premier League β Soccer β
β 4331 β German Bundesliga β Soccer β
β 4332 β Italian Serie A β Soccer β
β 4334 β French Ligue 1 β Soccer β
β 4335 β Spanish La Liga β Soccer β
β 4336 β Greek Super League 1 β Soccer β
β 4337 β Dutch Eredivisie β Soccer β
β 4338 β Belgian Pro League β Soccer β
βββββββββββββ΄ββββββββββββββββββββββββββββββ΄ββββββββββββ
epl = safe("EPL table 2024-2025", lambda: thesportsdb.thesportsdb_table("4328", "2024-2025"))
cols = ["int_rank", "str_team", "int_played", "int_win", "int_draw", "int_loss", "int_points"]
epl.select([c for c in cols if c in epl.columns]) if epl is not None else None
β
EPL table 2024-2025
shape: (5, 7)
ββββββββββββ¬βββββββββββββββββββ¬βββββββββββββ¬ββββββββββ¬βββββββββββ¬βββββββββββ¬βββββββββββββ
β int_rank β str_team β int_played β int_win β int_draw β int_loss β int_points β
β --- β --- β --- β --- β --- β --- β --- β
β str β str β str β str β str β str β str β
ββββββββββββͺβββββββββββββββββββͺβββββββββββββͺββββββββββͺβββββββββββͺβββββββββββͺβββββββββββββ‘
β 1 β Liverpool β 38 β 25 β 9 β 4 β 84 β
β 2 β Arsenal β 38 β 20 β 14 β 4 β 74 β
β 3 β Manchester City β 38 β 21 β 8 β 9 β 71 β
β 4 β Chelsea β 38 β 20 β 9 β 9 β 69 β
β 5 β Newcastle United β 38 β 20 β 6 β 12 β 66 β
ββββββββββββ΄βββββββββββββββββββ΄βββββββββββββ΄ββββββββββ΄βββββββββββ΄βββββββββββ΄βββββββββββββ
π° ESPN contentβ
espn_content_news returns cross-sport
headlines; espn_content_league_news
takes ESPN's sport and league slugs ("basketball", "nba").
news = safe("ESPN NBA news", lambda: espn_content.espn_content_league_news("basketball", "nba", limit="5"))
news.select("published", "headline") if news is not None and news.height else "no headlines"
β
ESPN NBA news
shape: (5, 2)
ββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β published β headline β
β --- β --- β
β str β str β
ββββββββββββββββββββββββͺββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ‘
β 2026-12-01T03:40:32Z β Jayson Tatum helps balanced Celtics bounce back with 125-101β¦ β
β 2026-12-01T03:34:31Z β Sengun powers the Rockets past the Lakers 110-105 for their β¦ β
β 2026-12-01T03:15:31Z β Coby White makes 7 3s and Hornets spoil debut of Wizards intβ¦ β
β 2026-12-01T03:01:32Z β Gilgeous-Alexander scores 31 as the Thunder beat the Nets 10β¦ β
β 2026-12-01T02:40:31Z β John Collins scores season-high 33 points and banged-up Pistβ¦ β
ββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π Where to nextβ
- The G League's ESPN surface has the same shape as every other ESPN league: see the NBA G League reference pages.
- F1 also has
f1_qualifying,f1_sprint,f1_pitstopsand thef1_circuits/f1_statusvocabularies. - Headlines for any league: pass its ESPN slugs to
espn_content_league_news.