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 groupColumns in tennis_matches_30d.csvModeling role
Surface Elo pre-matchwinner_surface_elo_pre, loser_surface_elo_pre, elo_win_probHard, Clay, and Grass strength prior to match start
First-serve effectivenessw_1st_serve_pct, w_1st_won_pct, l_1st_serve_pct, l_1st_won_pctRolling hold dominance and free-point serve percentage
Pressure survivalw_bp_saved, w_bp_faced, l_bp_saved, l_bp_facedBreak-point save differential on deciding points
Market benchmarkclose_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

Python
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

request
curl "https://api.citoapi.com/api/v1/tennis/odds/atp_m_2026_12345/history" \
  -H "x-api-key: YOUR_API_KEY"
response
{
  "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

request
curl "https://api.citoapi.com/api/v1/tennis/odds/upcoming?limit=3" \
  -H "x-api-key: YOUR_API_KEY"
response
{
  "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
    }
  ]
}
DataDepth
Match results (ATP and WTA)Open Era (1968) to today, plus earlier seasons: 2.1M+ matches with set scores
Point-in-time Elo & win probsOverall, Hard, Clay, Grass & Indoor Elo across 2.1M+ matches since 1968
Weekly rankingsEvery published ATP and WTA list since the 1970s, queryable by date
Serve and return statisticsPer match where recorded in the archive; every tour-level and Challenger match in the live era
Point-by-pointMatches carried live, consistently since June 2026. Not available for older seasons
Odds & tick historyPre-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

FreeStarterProScaleBusiness CSV
Price$0$15/mo$59/mo$100/mo$299/mo (+$99/mo extra sport)
Credits / mo500/month10,000/month250,000/month1,000,000/month3,000,000/month
Rate limit10/min30/min100/min400/min600/min
Live scores60 s delayed60 s delayedReal timeReal timeReal time
HistoryLast 30 daysLast 90 daysFull archive (1968-)Full archive (1968-)Full archive (1968-) + Master/Delta CSV
Deep-history (>90d) sub-cap0050,000/mo (5x narrow / bulk)100,000/mo (5x narrow / bulk)Unlimited in quota
Prediction-market odds3-day free trialUpgrade to ProPre-match, live & historyPre-match, live & historyAPI + opening/closing CSV
Point-in-time Elo3-day free trialCareer & leadersFull 1968- historyFull 1968- historyAPI + pre-match CSV
WebhooksNoNoYesYesYes
WebSocketsNoNo+$15/mo (points + odds)IncludedIncluded (points + odds)
Bulk CSV exportsSample CSV———Master + Daily Delta CSV (0 REST credits)
Commercial useNo1 productYesYesYes

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

More tennis API resources

Live Tennis Scores APITennis Point-by-Point APITennis API Coverage MatrixATP & WTA Rankings APITennis Head-to-Head APITennis Draws APITennis Stats API for Betting Models & MLTennis Webhooks APITennis API PricingTennis Elo Ratings APITennis CSV DatasetTennis API in PythonTennis API in Node.js & TypeScriptTennis WebSocket APITennis Historical Data APIATP Challenger APIITF Tennis APITennis Schedule APIFree Tennis APIAustralian Open Live Scores APITennis Qualifying Results APIITF Women Tennis Stats APITennis Break Points Saved APIWimbledon APIRoland Garros & French Open APIUS Open Tennis APITennis MCP ServerTennis API documentationMatches endpointsPlayers endpointsRankings & Elo endpointsOdds endpointsTournaments & draws endpointsHead-to-head endpointsLeaderboards endpointsLive WebSocket guideMeasured coverage guidePlayer & match IDsError referencePython ATP & WTA Live Tennis Scoreboard TutorialTennis Surface Elo Pandas Backtesting Tutorial (CSV + API)The tennis data API with 58 seasons of memoryA tennis scores API that keeps up with the serveEvery tennis result since 1968, one query awayA rankings API with a time machine built inThe ATP API that remembers Laver and streams SinnerLive odds, surface Elo, and 2.1M+ matches for quantitative modelsLive, pre-match, and historical tennis odds in one APIThe WTA, from Original 9 era to this week's finalBetsAPI alternativeGoalserve alternativeDIY Flashscore Scraper alternativeAPI-Tennis alternativeapi.tennis alternativeLiveTennisAPI alternativeAcesAPI alternativeTennis Abstract alternativeBALLDONTLIE alternativeThe Odds API alternativeOpticOdds alternativeSportmonks alternativeSportradar alternativeSofascore alternativeESPN alternative