How much is home court worth in men's college basketball?
Home margin and win rate by season, conference against non-conference play, then a margin rating tested on 2026 against the closing spreads.
Every script run against the live API on December 5, 2026. One full run: 1,050 credits.
Home court is the first adjustment in any college basketball model, and the number is rarely checked. This tutorial measures it with the DunkAPI Python client. It pulls eleven seasons of men's Division I games (2015 to 2026, 2021 left out), drops the games played at neutral sites, and reports the home margin and home win rate for each season. Then it asks whether home court shrinks in conference play, where teams meet twice a year and the host is no longer the stronger side by design.
Then it builds a simple margin rating from the scores, with a home-court value for conference games and another for the rest, and tests it on the 2025-26 season against the closing spreads. The measure is how close the predicted margin comes to the real one, as an average miss in points, for the rating and for the spread. It is not a count of covers, and the result is not flattering to the rating: the spread is closer.
The data is 53,493 regular-season games at a home floor between Division I teams, 2015 to 2026 without 2021, and 1,624 games from 2026 with a closing spread. One full run costs 1,050 credits: 678 for the games (339 calls of list_games), 370 for the spreads (37 days of get_odds at 10 credits; a 38th day had no games and cost nothing) and 2 for one get_ratings call. The 500 free credits do not cover all of it. Step 9 shows three edits that bring it to 324. Every script waits 1.1 seconds between calls to stay under the 60 requests a minute limit.
1. Install the client and set your key
The client has no required dependencies. This tutorial uses pandas and NumPy, which the pandas extra installs. It needs Python 3.9 or newer, and the client reads your key from DUNKAPI_API_KEY.
pip install "dunkapi[pandas]"
export DUNKAPI_API_KEY=your_key_here2. Pull eleven seasons of men's college games
list_games with league="ncaam", a season and status="final" returns every finished game of a season: the score, the date, whether it was played at a neutral site, whether it was a conference game and the venue. A page holds at most 200 games and costs 2 credits, so a season of about 6,000 games is 30 calls and 60 credits. Seasons are named by the year they end, so 2026 is 2025-26.
The script pulls 2015 to 2026 and skips 2021, the 2020-21 season, which was played with limited crowds and schedules cut by the pandemic. A home-court question is the one a missing crowd changes most, so we left that season out rather than average it in. Note the 2020 season (2019-20): its regular season was played in full before the postseason was cancelled, so it stays. Every later step reads the saved file and costs nothing until step 6.
import time, pandas as pd
from dunkapi import Client
client = Client()
rows, calls, spent = [], 0, 0
for season in [s for s in range(2015, 2027) if s != 2021]:
offset = 0
while offset is not None:
page = client.list_games(season=season, league="ncaam", status="final", limit=200, offset=offset)
for g in page["games"]:
rows.append({"game_id": g["game_id"], "season": g["season"], "season_type": g["season_type"], "date": g["date"],
"home_id": g["home"]["team_id"], "away_id": g["away"]["team_id"], "home_name": g["home"]["name"], "away_name": g["away"]["name"],
"home_score": g["home"]["score"], "away_score": g["away"]["score"], "overtime_periods": g["overtime_periods"],
"neutral": g["neutral_site"], "conference": g["conference_game"]})
offset = page["next_offset"]
calls += 1
spent += client.last_credits_used
time.sleep(1.1)
games = pd.DataFrame(rows)
games.to_csv("ncaam_games_2015_2026.csv", index=False)
print(len(games), "games from", calls, "calls,", spent, "credits")
print("credits left:", client.last_credits_remaining)Output
66705 games from 339 calls, 678 credits
credits left: 9604That is 339 calls and 678 credits for 66,705 games. The balance on the last line is for the key that ran it; yours will differ. The rows include a small number of postseason games and games against teams outside Division I, which the next step takes out.
3. Home margin and win rate by season, neutral sites out
Home court needs a home team, so a game at a neutral site is not in the sample. The neutral flag marks them: 6,640 regular-season games over the eleven seasons. The script also keeps only regular-season games between two Division I teams. list_games has no division field, so it treats a team as Division I in a season if it played at least one conference game in it, and drops the 5,372 games that involve anyone else. Those are mostly games against small programs, where the home side wins by 20 or more and tells you little about the floor.
For each season it prints the games left, the mean home margin (home score minus away score), the home win rate and the standard deviation of the margin.
import pandas as pd
g = pd.read_csv("ncaam_games_2015_2026.csv", dtype={"game_id": str, "home_id": str, "away_id": str})
print(len(g), "final games,", g["season"].nunique(), "seasons; season types:", g["season_type"].value_counts().to_dict())
g = g[g["season_type"] == "regular"].dropna(subset=["home_score", "away_score"]).copy()
g["margin"] = g["home_score"] - g["away_score"]
print("regular season:", len(g), "| neutral site:", int(g["neutral"].sum()), "| conference:", int(g["conference"].sum()))
# Division I teams: those that play at least one conference game in the season. Games against anyone else are dropped.
conf = g[g["conference"]]
d1 = set(zip(conf["season"], conf["home_id"])) | set(zip(conf["season"], conf["away_id"]))
in_d1 = [(s, h) in d1 and (s, a) in d1 for s, h, a in zip(g["season"], g["home_id"], g["away_id"])]
print("games with a team outside Division I:", len(g) - sum(in_d1))
g = g[in_d1]
# Neutral-site games have no home team, so they leave the home-court sample.
h = g[~g["neutral"]].copy()
h["home_win"] = (h["margin"] > 0).astype(int)
h.to_csv("home_games.csv", index=False)
by = h.groupby("season").agg(games=("margin", "size"), home_margin=("margin", "mean"), home_win=("home_win", "mean"))
by["margin_sd"] = h.groupby("season")["margin"].std()
print(by.round(3).to_string())
print("all seasons:", len(h), "games | mean home margin", round(h["margin"].mean(), 2), "| home win rate", round(h["home_win"].mean(), 3))Output
66705 final games, 11 seasons; season types: {'regular': 65422, 'postseason': 1283}
regular season: 65422 | neutral site: 6640 | conference: 38138
games with a team outside Division I: 5372
games home_margin home_win margin_sd
season
2015 4763 5.383 0.650 13.948
2016 4792 5.463 0.653 14.264
2017 4816 5.320 0.645 14.410
2018 4801 5.819 0.662 14.507
2019 4867 5.459 0.647 14.461
2020 4873 5.591 0.658 14.097
2022 4752 4.923 0.635 14.233
2023 4882 5.318 0.646 13.946
2024 4925 5.340 0.650 14.493
2025 4998 5.715 0.648 14.907
2026 5024 5.752 0.645 15.216
all seasons: 53493 games | mean home margin 5.46 | home win rate 0.649The home side outscored the visitor by 5.46 points a game and won 64.9% of the 53,493 games. Season to season the margin runs from 4.92 (2022, the lowest) to 5.82 (2018), and the win rate from 63.5% to 66.2%. With a standard deviation near 14.4 points and about 4,800 games a season, the standard error of a season's mean is about 0.2 points, so most of that range is noise, and the 2022 low is the one season we would look at twice. We did not test why. The spread of the margin has grown from 13.9 to 15.2 points, a sign that scores are more spread out now than in 2015, but not something this page explains.
4. Does home court shrink in conference play?
Compare the raw margins and the answer looks huge: 3.0 points in conference games and 10.2 outside the conference. That gap is mostly scheduling. Non-conference home games are often a strong team hosting a weaker one, paid to come, so the host would win by a lot on any floor. Conference play pairs teams that face each other twice a year, once at each home, which cancels who is stronger.
To remove the strength difference, the script fits one model per season: the home margin equals a home-court value plus the home team's rating minus the away team's rating, with one rating per team and one home-court value for conference games and another for the rest. It is ridge least squares (a penalty of 1 on each team rating, none on the two home-court values), solved with NumPy. The two home-court values are the numbers to read. The raw columns and the home win rates are printed beside them.
import numpy as np
import pandas as pd
h = pd.read_csv("home_games.csv", dtype={"game_id": str, "home_id": str, "away_id": str})
def adjusted(df):
"""Fit margin = home-court value (conference or not) + home rating - away rating, by ridge least squares, so a strong team hosting a weak one is not counted as home court."""
teams = pd.Index(pd.unique(pd.concat([df["home_id"], df["away_id"]])))
ix = {t: i for i, t in enumerate(teams)}
X = np.zeros((len(df), len(teams) + 2))
X[np.arange(len(df)), df["home_id"].map(ix).to_numpy()] += 1
X[np.arange(len(df)), df["away_id"].map(ix).to_numpy()] -= 1
X[:, len(teams)] = df["conference"].to_numpy()
X[:, len(teams) + 1] = (~df["conference"]).to_numpy()
pen = np.eye(X.shape[1])
pen[-2:, -2:] = 0 # the two home-court values are not shrunk
beta = np.linalg.solve(X.T @ X + pen, X.T @ df["margin"].to_numpy())
return beta[-2], beta[-1]
rows = []
for season, d in h.groupby("season"):
c, n = d[d["conference"]], d[~d["conference"]]
a_conf, a_non = adjusted(d)
rows.append((season, len(c), len(n), c["margin"].mean(), n["margin"].mean(), c["home_win"].mean(), n["home_win"].mean(), a_conf, a_non))
t = pd.DataFrame(rows, columns=["season", "conf_n", "non_n", "conf_raw", "non_raw", "conf_win", "non_win", "conf_adj", "non_adj"])
t["gap"] = t["conf_adj"] - t["non_adj"]
print(t.round(2).to_string(index=False))
print("mean of seasons: conference", round(t["conf_adj"].mean(), 2), "| non-conference", round(t["non_adj"].mean(), 2), "| gap", round(t["gap"].mean(), 2))
print("gap in every season:", bool((t["gap"] < 0).all()), "| smallest", round(t["gap"].abs().min(), 2), "largest", round(t["gap"].abs().max(), 2))
t.to_csv("conference_by_season.csv", index=False)Output
season conf_n non_n conf_raw non_raw conf_win non_win conf_adj non_adj gap
2015 3092 1671 3.25 9.32 0.60 0.74 3.20 3.84 -0.64
2016 3108 1684 3.19 9.65 0.61 0.74 3.13 4.25 -1.12
2017 3111 1705 2.88 9.77 0.59 0.74 2.79 3.79 -1.01
2018 3101 1700 3.44 10.16 0.61 0.75 3.36 4.16 -0.80
2019 3160 1707 3.12 9.79 0.59 0.74 3.02 4.18 -1.16
2020 3218 1655 3.37 9.91 0.61 0.74 3.30 4.24 -0.94
2022 3240 1512 2.45 10.22 0.58 0.76 2.36 4.49 -2.13
2023 3330 1552 3.26 9.73 0.60 0.74 3.22 4.72 -1.50
2024 3302 1623 2.86 10.38 0.60 0.75 2.81 4.36 -1.56
2025 3380 1618 3.04 11.29 0.60 0.76 2.98 4.38 -1.40
2026 3389 1635 2.60 12.28 0.59 0.77 2.56 4.55 -1.99
mean of seasons: conference 2.98 | non-conference 4.27 | gap -1.3
gap in every season: True | smallest 0.64 largest 2.13- Conference
- Non-conference
From the output above: points of home margin after adjusting for team strength, Division I games at a home floor, 2015 to 2026. 2021 is not in the data. A single season's figure has a standard error near 0.25 points for conference games and 0.35 for non-conference.
After adjusting, home court is worth about 3.0 points in conference games and 4.3 outside them, a gap of 1.3 points, and the conference value is lower in all eleven seasons (the gap runs from 0.64 to 2.13). So yes, it is smaller in conference play, by roughly a third. Two cautions. First, the adjusted values depend on the model: they assume one home-court value for every team in a season, and a penalty that pulls ratings toward zero, so read 1.3 as an estimate, not a measurement. Second, non-conference teams are linked to the rest by fewer games, which makes that figure the less certain of the two. The trend is small: the conference value drifts from 3.20 in 2015 to 2.56 in 2026 and the non-conference one rises from 3.84 to 4.55, but each season's figure carries a standard error of 0.25 to 0.35, so we would not call either a trend without testing it.
5. Build a margin rating and choose its settings on 2024 and 2025
A margin rating says how many points a team is better than average, so the gap between two ratings, plus a home-court value, is a predicted home margin. This one keeps one number per team, starting at 0. After a game it moves both teams by the error of the prediction, times a step that shrinks as the team plays: k0 / (games played + 8) ** 0.5. A blowout counts as 25 points at most. At the start of a season each rating is multiplied by carry, so a carry of 1.0 keeps all of last year's rating. A neutral-site game gets no home-court value; a conference game gets hca_conf and any other home game hca_non, which uses step 4's finding that the two differ.
Save this as rating.py. run walks the games in date order and returns the prediction it had for each game before the game, so a prediction never sees its own result. The main block tries 144 combinations of the four settings, scored on the mean absolute error of the predicted margin on the 2024 and 2025 games only, and keeps the lowest. It also prints the best run that uses one home-court value for every game, to see whether the split earns its place. Then it fixes the settings and walks through 2026. Games from 2022 on are used so that every team has a few seasons of history.
from collections import defaultdict
import numpy as np
import pandas as pd
g = pd.read_csv("ncaam_games_2015_2026.csv", dtype={"game_id": str, "home_id": str, "away_id": str})
g = g[(g["season"] >= 2022) & g["season_type"].isin(["regular", "postseason"])].dropna(subset=["home_score", "away_score"])
g = g.sort_values(["date", "game_id"]).reset_index(drop=True)
g["margin"] = g["home_score"] - g["away_score"]
def run(df, k0, carry, hca_conf, hca_non, cap=25.0):
"""Walk the games in date order. Predict the home margin from the ratings before a game, then move both ratings."""
rating, played, season = defaultdict(float), defaultdict(int), None
pred = np.empty(len(df))
for i, (h, a, s, neutral, conf, m) in enumerate(zip(df["home_id"], df["away_id"], df["season"], df["neutral"], df["conference"], df["margin"])):
if s != season: # a new season keeps part of last year's rating, and every team counts as unsettled again
for t in rating:
rating[t] *= carry
played, season = defaultdict(int), s
bonus = 0.0 if neutral else (hca_conf if conf else hca_non)
pred[i] = rating[h] - rating[a] + bonus
err = float(np.clip(m, -cap, cap)) - pred[i] # a 40-point blowout counts as 25
rating[h] += k0 / (played[h] + 8) ** 0.5 * err # a team early in the season moves faster
rating[a] -= k0 / (played[a] + 8) ** 0.5 * err
played[h] += 1
played[a] += 1
return pred, rating
def mae(pred, actual):
return float(np.mean(np.abs(actual - pred)))
if __name__ == "__main__":
import itertools
through25 = g[g["season"] <= 2025]
tune = through25["season"].isin([2024, 2025]).to_numpy() # settings are chosen on 2024 and 2025, never on 2026
rows = []
for k0, carry, hc, hn in itertools.product([0.5, 0.7, 1.0], [0.85, 0.9, 0.95, 1.0], [2.5, 3.0, 3.5], [3.5, 4.5, 5.5, 6.5]):
p, _ = run(through25, k0, carry, hc, hn)
rows.append((k0, carry, hc, hn, mae(p[tune], through25["margin"].to_numpy()[tune])))
grid = pd.DataFrame(rows, columns=["k0", "carry", "hca_conf", "hca_non", "mae"]).sort_values("mae")
print(grid.head(5).round(3).to_string(index=False))
best = grid.iloc[0]
single = grid[grid["hca_conf"] == grid["hca_non"]].iloc[0] # the best run that uses one home-court value for every game
print("best with one home-court value:", single[["k0", "carry", "hca_conf", "mae"]].round(3).to_dict())
K0, CARRY, HC, HN = float(best["k0"]), float(best["carry"]), float(best["hca_conf"]), float(best["hca_non"])
print("chosen: k0", K0, "carry", CARRY, "home court", HC, "conference,", HN, "non-conference")
# The same walk through 2026 with the settings fixed. Every 2026 game is predicted before it updates anything.
pred, rating = run(g, K0, CARRY, HC, HN)
g.assign(pred=pred)[["game_id", "season", "date", "neutral", "conference", "home_id", "away_id", "home_name", "away_name", "margin", "pred"]].to_csv("model_predictions.csv", index=False)
pd.Series(rating, name="rating").rename_axis("team_id").reset_index().to_csv("model_ratings.csv", index=False)
print(len(g[g["season"] == 2026]), "games in 2026 rated")Output
k0 carry hca_conf hca_non mae
0.7 1.0 3.0 4.5 10.488
0.7 1.0 3.0 5.5 10.488
0.7 1.0 2.5 4.5 10.488
0.7 1.0 2.5 5.5 10.488
0.7 1.0 3.5 4.5 10.500
best with one home-court value: {'k0': 0.7, 'carry': 1.0, 'hca_conf': 3.5, 'mae': 10.514}
chosen: k0 0.7 carry 1.0 home court 3.0 conference, 4.5 non-conference
6300 games in 2026 ratedThe best combination, a step of 0.7, a carry of 1.0, 3.0 points for a conference game and 4.5 for the rest, scores 10.49 points of error on 2024 and 2025. The best run with a single home-court value scores 10.51, so splitting it into two earns 0.03 points, which is small. Several combinations tie at 10.488, which means the data does not pin down the second value. The error of 10.5 points is for every game, including games against teams outside Division I, where scores are lopsided; it is not the number to compare with the market. Step 7 does that on a cleaner set. The carry sits at the top of the grid (1.0), so a wider search might go further; we left it.
6. Pull the closing spreads for 2026
get_odds with a date returns every game of that day with each sportsbook's opening and closing moneyline, spread and total, for 10 credits whatever the day holds, and nothing for a day without games. The 2025-26 season has about 150 game days, which is 1,500 credits, more than this tutorial needs. The script takes every third day from Nov 17 2025 to Mar 8 2026, which is 38 days, and keeps the median closing spread across the books that posted one for each finished game. Dec 26 had no games and cost nothing, so the run is 37 calls that cost credits.
The spread is the home team's, and a home spread of -6.5 means the books expect the home side to win by 6.5. Prices here are information about what the market expected. Nothing on this page works out a stake or recommends a game.
import time
from datetime import date, timedelta
import numpy as np
import pandas as pd
from dunkapi import Client
client = Client() # reads DUNKAPI_API_KEY
day, end, rows, spent, days = date(2025, 11, 17), date(2026, 3, 8), [], 0, 0
while day <= end: # every third day: a day is one 10 credit call whatever its size
d = client.get_odds(date=day.isoformat(), league="ncaam")
spent += client.last_credits_used
days += 1
for g in d["games"]:
s = [b["home_spread_close"] for b in g["books"] if b.get("home_spread_close") is not None]
if g["status"] == "final" and s:
rows.append({"game_id": g["game_id"], "date": g["date"], "books": len(s), "spread_close": float(np.median(s))})
time.sleep(1.1)
day += timedelta(days=3)
lines = pd.DataFrame(rows)
lines.to_csv("closing_spreads_2026.csv", index=False)
print(days, "days,", len(lines), "games with a closing spread,", spent, "credits")
print("median books per game:", int(lines["books"].median()))
print("credits left:", client.last_credits_remaining)Output
38 days, 1624 games with a closing spread, 370 credits
median books per game: 7
credits left: 9234The sample is 1,624 games, with a median of 7 books each. They come from the days the script visited, so they are every third day of the season and not a random draw of games, which is fine for scoring but means a game on a skipped day is simply missing.
7. Score the rating against the closing spread
The question is how close each predicted home margin comes to the real one, in points. We use the mean absolute error (MAE), the average size of the miss, with root mean square error beside it because it punishes big misses more. Whether a side covered a spread is a different question and not the one here. The script puts the spread on the same scale as the model (the predicted home margin is the spread with its sign flipped), scores both on the same 1,624 games, and adds a simple average of the two. It splits the games into conference and non-conference, and resamples the games 2,000 times to put an interval on the difference in MAE. The rating was built only from games before each one, and its settings were chosen on 2024 and 2025, so 2026 was not seen. "bias" is the mean of the real margin minus the prediction: a positive number means the home side did better than predicted.
import numpy as np
import pandas as pd
p = pd.read_csv("model_predictions.csv", dtype={"game_id": str})
lines = pd.read_csv("closing_spreads_2026.csv", dtype={"game_id": str})
d = p.merge(lines[["game_id", "books", "spread_close"]], on="game_id")
d = d[d["season"] == 2026].copy()
d["spread_pred"] = -d["spread_close"] # a home spread of -6.5 means the market expects the home side to win by 6.5
d["blend"] = (d["pred"] + d["spread_pred"]) / 2
print(len(d), "games with a closing spread on", d["date"].nunique(), "days | neutral site:", int(d["neutral"].sum()), "| conference:", int(d["conference"].sum()))
def score(df):
out = {}
for name, col in [("our rating", "pred"), ("closing spread", "spread_pred"), ("average of the two", "blend")]:
e = df["margin"] - df[col]
out[name] = (len(df), np.mean(np.abs(e)), np.sqrt(np.mean(e**2)), np.mean(e))
return pd.DataFrame(out, index=["games", "mae", "rmse", "bias"]).T
print("all games, error in points of home margin")
print(score(d).round(3).to_string())
for label, mask in [("conference games", d["conference"]), ("non-conference games", ~d["conference"])]:
print(label)
print(score(d[mask]).round(3).to_string())
# Is the gap in MAE bigger than chance? Resample the games 2,000 times.
rng = np.random.default_rng(7)
diff = (d["margin"] - d["pred"]).abs().to_numpy() - (d["margin"] - d["spread_pred"]).abs().to_numpy()
boot = np.array([diff[rng.integers(0, len(diff), len(diff))].mean() for _ in range(2000)])
print("our MAE minus the spread's:", round(float(diff.mean()), 3), "| 95% interval", np.percentile(boot, [2.5, 97.5]).round(3).tolist())
print("share of games where our margin was closer to the result:", round(float((diff < 0).mean()), 3))
print("correlation of our margin with the spread's:", round(float(np.corrcoef(d["pred"], d["spread_pred"])[0, 1]), 3))
d.to_csv("scored_2026.csv", index=False)Output
1624 games with a closing spread on 37 days | neutral site: 124 | conference: 1198
all games, error in points of home margin
games mae rmse bias
our rating 1624.0 9.474 12.151 -0.065
closing spread 1624.0 9.027 11.515 -0.388
average of the two 1624.0 9.128 11.672 -0.226
conference games
games mae rmse bias
our rating 1198.0 9.138 11.660 -0.839
closing spread 1198.0 8.829 11.176 -0.691
average of the two 1198.0 8.886 11.304 -0.765
non-conference games
games mae rmse bias
our rating 426.0 10.420 13.438 2.112
closing spread 426.0 9.586 12.417 0.464
average of the two 426.0 9.808 12.649 1.288
our MAE minus the spread's: 0.447 | 95% interval [0.273, 0.618]
share of games where our margin was closer to the result: 0.466
correlation of our margin with the spread's: 0.911- Our rating
- Closing spread
From the output above: 1,624 games on 37 days between Nov 17 2025 and Mar 8 2026. Lower is better. The axis starts at 8, so the gaps look larger than they are.
The closing spread is closer to the result than our rating: 9.03 points of average miss against 9.47. The gap is 0.45 points and the 95% interval, from the resampling, runs from 0.27 to 0.62, so it is not chance. Our rating was nearer in 46.6% of games. The two margins are strongly related (correlation 0.911), and averaging them (9.13) is better than ours and worse than the spread alone, so averaging in our rating did not help. That is the expected result: a closing spread already reflects injuries, rest and lineups, which a rating made from final scores cannot see.
The gap is larger outside the conference: 10.42 against 9.59 there, 9.14 against 8.83 in conference games. In non-conference games our rating also under-predicts the home side by 2.1 points on average, while the spread is off by 0.5. That may mean 4.5 is too low for those games, but we did not retune on it, since that would use 2026. A rating like this is a baseline to test ideas against, and it comes within half a point of the market on a typical game, which is not enough to say more.
8. Compare your ratings with get_ratings
get_ratings returns our team ratings as of the end of a season, best first. Our method is published in the response: Elo from every final game, with a home-court term and a margin-of-victory multiplier, a rating keeping 90% of its distance from average between seasons. That is a different scale from the points rating above, so the numbers cannot be compared directly, only the order. The script runs your rating through 2025 with nothing from 2026, takes our top 400 for the 2025 season, joins them on team_id, and reports the rank correlation and how many of our top 25 are in your top 25 and top 50. One call, 2 credits. The rank correlation is the Pearson correlation of the two rank lists, so it needs only pandas.
import pandas as pd
from dunkapi import Client
from rating import g, run
K0, CARRY, HC, HN = 0.7, 1.0, 3.0, 4.5 # the settings step 5 chose
_, ours = run(g[g["season"] <= 2025], K0, CARRY, HC, HN) # our ratings after the 2025 season, with nothing from 2026
client = Client() # reads DUNKAPI_API_KEY
theirs = pd.DataFrame(client.get_ratings(season=2025, limit=400, league="ncaam")["ratings"])
theirs["ours"] = theirs["team_id"].map(ours)
print("credits used:", client.last_credits_used, "| teams in our list:", len(theirs), "| matched to our ratings:", int(theirs["ours"].notna().sum()))
both = theirs.dropna(subset=["ours"]).copy()
both["our_rank"] = both["ours"].rank(ascending=False).astype(int)
print("rank correlation, top 400:", round(float(both["rating"].rank().corr(both["ours"].rank())), 3))
top25 = both[both["rank"] <= 25]
print("their top 25 that are in our top 25:", int((top25["our_rank"] <= 25).sum()), "| in our top 50:", int((top25["our_rank"] <= 50).sum()))
print(both.head(10)[["rank", "team", "rating", "our_rank"]].to_string(index=False))
print("credits left:", client.last_credits_remaining)Output
credits used: 2 | teams in our list: 400 | matched to our ratings: 400
rank correlation, top 400: 0.965
their top 25 that are in our top 25: 19 | in our top 50: 24
rank team rating our_rank
1 Florida Gators 2092.3 1
2 Houston Cougars 2066.9 3
3 Duke Blue Devils 2059.6 2
4 Auburn Tigers 2048.2 4
5 Tennessee Volunteers 2007.1 10
6 Alabama Crimson Tide 1990.8 5
7 Michigan State Spartans 1980.0 6
8 St. John's Red Storm 1972.8 8
9 Texas Tech Red Raiders 1965.3 11
10 Gonzaga Bulldogs 1961.7 7
credits left: 9228The order agrees closely: 0.965 across 400 teams, with 19 of our top 25 in your top 25 and 24 in your top 50. The top four are the same four teams. Where they differ at the top it is a place or two (Tennessee is 5th in ours and 10th in yours). The two methods are different in design, so close agreement suggests the scores carry most of the signal.
9. Run it on the free plan
The full run costs 1,050 credits and the free plan has 500, so three edits cut it to 324. Priced from the full run's data, not run separately:
- Step 2: pull
[2024, 2025, 2026]instead of the eleven seasons: 96 calls, 192 credits. Steps 3 and 4 then cover three seasons, with a noisier conference comparison. - Step 5: change
g["season"] >= 2022to>= 2024, and score the settings on 2025 alone (isin([2025])), because 2024 is now the warm-up. - Step 6: change
timedelta(days=3)totimedelta(days=9): 13 days with games, 130 credits, about 600 games to score.
Step 8 stays at 2 credits. The numbers on this page are from the full run, and a smaller sample moves them: with about 600 games the interval on the MAE gap would be about 1.6 times as wide.
10. What this leaves out
The rating knows final scores, the date and where the game was played, and nothing else. Read its limits before extending it.
- No rosters. Transfers and injuries change a team between seasons and between games; a carry of 1.0 is a blunt way to start a year.
- No pace or lineup. A margin rating blurs a slow team's close games and a fast team's blowouts.
get_team_statshas pace and efficiency, and is worth testing as a feature, scored the same way on a season you did not tune on. - One home-court value for all floors. Real home courts differ, and a fair test would give each team its own, shrunk toward the mean. We did not test it.
- Neutral sites are all alike. A tournament game 20 miles from one school is not neutral for that school, and the
neutralflag cannot tell. - Only 37 game days. Every third day from November to March, and the window ends on Mar 8, so the postseason is mostly missing.
- The 2021 season is missing, and the two seasons after it may differ for reasons that are not about the floor.
Change the season range in step 2 for more history, the grid in step 5 for other settings, and the dates in step 6 for a different slice of 2026. The same MAE against the closing spread, on a season held out from the tuning, is the check on every change.
Tools and credits
- list_games: 339 calls, 678 credits (ncaam, eleven seasons, 200 games a page).
- get_odds: 38 calls, 370 credits (10 credits for every day with games; 2025-12-26 had none and cost nothing).
- get_ratings: 1 call, 2 credits (ncaam, season 2025, top 400).
One full run: 1,050 credits.
What you can do with the data
You may store these rows, train models and backtest on them, and build products that show your users what you derive. You may not redistribute the rows, or sportsbook prices as a raw feed, as a dataset or API of its own. The spreads here are market information used to score a model, not a recommendation, and nothing on this page works out a stake or sends you to a sportsbook.
Details: data timing and rights.
What to do next
Start with 500 free credits every month
No card. pip install dunkapi, REST or MCP.