Build a calibrated tennis match prediction model in Python
Train a logistic regression baseline on free 30-day ATP & WTA match CSVs using pre-match surface Elo differentials and rolling serve/return metrics, benchmark Brier loss against closing market odds, and score today's schedule live.
Pro $59/mo: real-time scores, full archive since 1968, match webhooks. Free: 500 calls/month, live 60 s delayed, last 30 days. Read the docs
$ curl "https://tennisapi.dev/dataset/tennis_matches_30d.csv" -o tennis_matches_30d.csv
In short
Load /dataset/tennis_matches_30d.csv and tennis_odds_sample_30d.csv in Python to combine pre-match surface Elo (winner_surface_elo_pre vs loser_surface_elo_pre) with rolling serve stats (w_1st_won_pct, w_bp_saved_pct), calibrate probabilities against closing odds, and score upcoming fixtures via /tennis/odds/upcoming.
1. Feature matrix from the free 30-day tennis CSVs
Download or read the 4 tables directly from our interactive Tennis Dataset Explorer (/tennis-csv-dataset/): 8,645 completed 30-day matches, 1,500 active surface Elo ratings, 2,000 odds rows, and 996 ATP/WTA rankings rows.
| Feature group | Columns in tennis_matches_30d.csv | Modeling role |
|---|---|---|
| Surface Elo pre-match | winner_surface_elo_pre, loser_surface_elo_pre, elo_win_prob | Hard, Clay, and Grass strength prior to match start |
| First-serve effectiveness | w_1st_serve_pct, w_1st_won_pct, l_1st_serve_pct, l_1st_won_pct | Rolling hold dominance and free-point serve percentage |
| Pressure survival | w_bp_saved, w_bp_faced, l_bp_saved, l_bp_faced | Break-point save differential on deciding points |
| Market benchmark | close_player1_odds, close_player2_odds (tennis_odds_sample_30d.csv) | No-vig closing implied probability for Brier & log-loss eval |
2. Train & evaluate symmetric pre-match features in Python
tennis_model.py - Symmetric Elo + serve-stats model with closing odds check
import pandas as pd
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import brier_score_loss, roc_auc_score
from sklearn.preprocessing import StandardScaler
matches = pd.read_csv("https://tennisapi.dev/dataset/tennis_matches_30d.csv")
odds = pd.read_csv("https://tennisapi.dev/dataset/tennis_odds_sample_30d.csv")
df = matches.dropna(subset=["winner_surface_elo_pre", "loser_surface_elo_pre"]).sort_values("match_date").reset_index(drop=True)
# Assign player_a / player_b cleanly using canonical player_id ordering
swap = df["winner_id"].astype(str) > df["loser_id"].astype(str)
df["target_a_win"] = (~swap).astype(int)
df["surf_elo_diff"] = (df["winner_surface_elo_pre"] - df["loser_surface_elo_pre"]).where(~swap, df["loser_surface_elo_pre"] - df["winner_surface_elo_pre"])
df["overall_elo_diff"] = (df["winner_elo_pre"] - df["loser_elo_pre"]).where(~swap, df["loser_elo_pre"] - df["winner_elo_pre"])
df["rank_diff"] = (df["loser_rank"].fillna(300) - df["winner_rank"].fillna(300)).where(~swap, df["winner_rank"].fillna(300) - df["loser_rank"].fillna(300))
features = ["surf_elo_diff", "overall_elo_diff", "rank_diff"]
split = int(len(df) * 0.70)
scaler = StandardScaler()
X_train = scaler.fit_transform(df.iloc[:split][features])
X_test = scaler.transform(df.iloc[split:][features])
clf = LogisticRegression(C=0.5, max_iter=500)
clf.fit(X_train, df.iloc[:split]["target_a_win"])
test_df = df.iloc[split:].copy()
test_df["pred_a"] = clf.predict_proba(X_test)[:, 1]
print("Out-of-sample AUC:", round(roc_auc_score(test_df["target_a_win"], test_df["pred_a"]), 4))
print("Out-of-sample Brier:", round(brier_score_loss(test_df["target_a_win"], test_df["pred_a"]), 4))3. Inspect opening/closing odds & score live fixtures
Match odds history curve from REST
curl "https://api.citoapi.com/api/v1/tennis/odds/atp_m_2026_12345/history" \
-H "x-api-key: YOUR_API_KEY"{
"success": true,
"match_id": "m_2026_4891297",
"player1_name": "Mirra Andreeva",
"player2_name": "Elina Svitolina",
"ticks": [
{
"market_id": "mkt_7052659",
"market": "h2h",
"set_number": null,
"line": null,
"player1_odds": 1.53,
"player2_odds": 2.9,
"over_odds": null,
"under_odds": null,
"player1_prob": 0.655,
"player2_prob": 0.345,
"best_bid": 0.65,
"best_ask": 0.66,
"spread": 0.01,
"in_play": true,
"live_set": 1,
"live_score": "3-2 (0-0)",
"price_timestamp": "2026-11-15T20:36:34.497000+00:00"
},
{
"market_id": "mkt_7053352",
"market": "set_winner",
"set_number": 1,
"line": null,
"player1_odds": 1.89,
"player2_odds": 2.13,
"over_odds": null,
"under_odds": null,
"player1_prob": 0.53,
"player2_prob": 0.47,
"best_bid": 0.5,
"best_ask": 0.56,
"spread": 0.06,
"in_play": true,
"live_set": 1,
"live_score": "3-2 (0-0)",
"price_timestamp": "2026-11-15T20:36:34.497000+00:00"
},
{
"market_id": "mkt_7053353",
"market": "set_winner",
"set_number": 2,
"line": null,
"player1_odds": 1.55,
"player2_odds": 2.82,
"over_odds": null,
"under_odds": null,
"player1_prob": 0.645,
"player2_prob": 0.355,
"best_bid": 0.61,
"best_ask": 0.68,
"spread": 0.07,
"in_play": true,
"live_set": 1,
"live_score": "3-2 (0-0)",
"price_timestamp": "2026-11-15T20:36:34.497000+00:00"
}
]
}Upcoming schedule + H2H market prices
curl "https://api.citoapi.com/api/v1/tennis/odds/upcoming?limit=3" \
-H "x-api-key: YOUR_API_KEY"{
"success": true,
"total": 694,
"items": [
{
"match_id": "m_2026_4891297",
"tour": "WTA",
"tournament": "WTA Finals, Final Stage",
"commence_time": "2026-11-15T20:10:00+00:00",
"home": {
"name": "Mirra Andreeva",
"player_id": "wta_259799",
"id": "wta_259799"
},
"away": {
"name": "Elina Svitolina",
"player_id": "wta_202494",
"id": "wta_202494"
},
"live": true,
"market_status": "open",
"liquidity_usd": 251462.12,
"volume_usd": 600112.4,
"price_timestamp": "2026-11-15T21:37:44.985000+00:00",
"h2h": {
"market_id": "mkt_7052659",
"player1_odds": 1.21,
"player2_odds": 5.71,
"player1_prob": 0.825,
"player2_prob": 0.175,
"open_player1_odds": 1.53,
"open_player2_odds": 2.9,
"best_bid": 0.82,
"best_ask": 0.83,
"spread": 0.01,
"status": "open"
},
"markets": ["h2h","set_handicap","set_winner","spreads","totals","set_totals"],
"market_count": 9
},
{
"match_id": "m_2026_4893994",
"tour": "ATP",
"tournament": "ATP World Tour Finals, John McEnroe Group",
"commence_time": "2026-11-15T19:35:00+00:00",
"home": {
"name": "Ben Shelton",
"player_id": "atp_210097",
"id": "atp_210097"
},
"away": {
"name": "Arthur Fils",
"player_id": "atp_209950",
"id": "atp_209950"
},
"live": true,
"market_status": "open",
"liquidity_usd": 214342.38,
"volume_usd": 308203.09,
"price_timestamp": "2026-11-15T21:37:44.988000+00:00",
"h2h": {
"market_id": "mkt_7001803",
"player1_odds": 1.02,
"player2_odds": 48.78,
"player1_prob": 0.9795,
"player2_prob": 0.0205,
"open_player1_odds": 1.18,
"open_player2_odds": 6.45,
"best_bid": 0.979,
"best_ask": 0.98,
"spread": 0.001,
"status": "open"
},
"markets": ["h2h","spreads","set_handicap","set_winner","totals","set_totals"],
"market_count": 8
}
]
}| Data | Depth |
|---|---|
| Match results (ATP and WTA) | Open Era (1968) to today, plus earlier seasons: 2.1M+ matches with set scores |
| Point-in-time Elo & win probs | Overall, Hard, Clay, Grass & Indoor Elo across 2.1M+ matches since 1968 |
| Weekly rankings | Every published ATP and WTA list since the 1970s, queryable by date |
| Serve and return statistics | Per match where recorded in the archive; every tour-level and Challenger match in the live era |
| Point-by-point | Matches carried live, consistently since June 2026. Not available for older seasons |
| Odds & tick history | Pre-match & live prediction-market prices + liquidity linked by canonical match_id, plus history snapshots |
Explore the 30-day dataset interactively on /tennis-csv-dataset/, test Pro ($59/mo) for full 1968+ historical REST + odds, or unlock 2.1M+ Master & Daily Delta CSVs on Business CSV ($299/mo).
Plans for tennis
| Free | Starter | Pro | Scale | Business CSV | |
|---|---|---|---|---|---|
| Price | $0 | $15/mo | $59/mo | $100/mo | $299/mo (+$99/mo extra sport) |
| Credits / mo | 500/month | 10,000/month | 250,000/month | 1,000,000/month | 3,000,000/month |
| Rate limit | 10/min | 30/min | 100/min | 400/min | 600/min |
| Live scores | 60 s delayed | 60 s delayed | Real time | Real time | Real time |
| History | Last 30 days | Last 90 days | Full archive (1968-) | Full archive (1968-) | Full archive (1968-) + Master/Delta CSV |
| Deep-history (>90d) sub-cap | 0 | 0 | 50,000/mo (5x narrow / bulk) | 100,000/mo (5x narrow / bulk) | Unlimited in quota |
| Prediction-market odds | 3-day free trial | Upgrade to Pro | Pre-match, live & history | Pre-match, live & history | API + opening/closing CSV |
| Point-in-time Elo | 3-day free trial | Career & leaders | Full 1968- history | Full 1968- history | API + pre-match CSV |
| Webhooks | No | No | Yes | Yes | Yes |
| WebSockets | No | No | +$15/mo (points + odds) | Included | Included (points + odds) |
| Bulk CSV exports | Sample CSV | — | — | — | Master + Daily Delta CSV (0 REST credits) |
| Commercial use | No | 1 product | Yes | Yes | Yes |
Tennis on each plan, as the API enforces it (checked 15 Nov 2026). Paid API plans: 7-day money-back guarantee.
Frequently asked
Ready to go
live ?
Pro unlocks real-time scores, point-by-point, prediction-market odds, point-in-time Elo back to 1968, and webhooks for $59/mo with a 7-day money-back guarantee. Free includes a 3-day odds & Elo trial; Business ($299/mo) delivers full CSV datasets.
Compare every plan