# Sports betting model in Python: build one on Novig line history

> Independent. Not affiliated with, endorsed by or sponsored by Novig.

Canonical: https://novigapi.com/uses/sports-betting-model-python
Facts checked: 2026-11-22

A sports betting model in Python needs prices and results for the same markets. novigapi.com gives both: Novig line history, closing fair prices and graded results by league and date, as plain JSON for pandas. Daily history starts 4 Aug 2026. The example below scores Novig's own closing prices as a baseline. (Source: [novigapi.com: GET /v1/clv reference](https://novigapi.com/docs/endpoints/clv?ref=ai-md))

```python
import os, requests

def nv(path, **params):
    r = requests.get("https://novigapi.com/api/v1/" + path, params=params, timeout=30,
                     headers={"Authorization": "Bearer " + os.environ["NOVIGAPI_KEY"]})
    r.raise_for_status()
    return r.json()

import pandas as pd

days = pd.date_range("2026-11-10", "2026-11-16").strftime("%Y-%m-%d")
rows = []
for d in days:
    page = nv("clv", league="NBA", date=d, settled="true", limit=500)
    rows += page["data"]

df = pd.DataFrame(rows).dropna(subset=["close_fair", "won"])
df["y"] = df["won"].astype(int)
brier = ((df["close_fair"] - df["y"]) ** 2).mean()
print(len(df), "outcomes, Brier score of the close:", round(brier, 4))
print(df.groupby(pd.cut(df["close_fair"], [0, .2, .4, .6, .8, 1]))["y"].agg(["mean", "count"]))
```

The close is the bar to beat. Your model is useful only if its probabilities score better than this Brier score on the same outcomes, or find prices that later close in your favor.

## Where the features come from

Data for a betting model, by endpoint

| Need | Endpoint |
| --- | --- |
| Price path before the start | [GET /v1/line-history](https://novigapi.com/docs/endpoints/line-history?ref=ai-md) |
| Opening and closing fair prices | [GET /v1/clv](https://novigapi.com/docs/endpoints/clv?ref=ai-md) |
| Who won, with grade source and confidence | [GET /v1/results](https://novigapi.com/docs/endpoints/results?ref=ai-md) |
| Line moves and steam | [GET /v1/line-moves](https://novigapi.com/docs/endpoints/line-moves?ref=ai-md) |
| Daily OHLC, volume and open interest | [GET /v1/ohlc/daily](https://novigapi.com/docs/endpoints/ohlc-daily?ref=ai-md) |


## A simple workflow

1. Pull closes and results for a past window and store them, so a backtest never calls the API twice.
2. Build features only from what was known before the start, such as the opening price and early moves.
3. Fit a model, then compare its Brier score and calibration with the close on games it never saw.
4. Track live picks with a [CLV tracker](https://novigapi.com/uses/clv-tracker?ref=ai-md) before you trust the backtest.

## Bulk history

Free keys read the last 7 days, enough to test the code above. Paid plans read the full store. For a whole season at once, use [bulk CSV](https://novigapi.com/docs/endpoints/bulk-csv?ref=ai-md) or the one-time [history archive](https://novigapi.com/archive?ref=ai-md). Pandas and the `pip install novigapi` client are covered in the [Python guide](https://novigapi.com/novig-api-python?ref=ai-md). [Get a free API key](https://novigapi.com/sign-up?ref=ai-md). No card, no Novig account.

## Questions

### What is a Brier score?

The mean squared gap between a forecast probability and the 0 or 1 outcome. Lower is better; always guessing 50% scores 0.25.

### Can I backtest on Novig data?

Yes. Line history, closes and graded results come from the same API, keyed by the same market id.

## Sources

- [novigapi.com: GET /v1/clv reference](https://novigapi.com/docs/endpoints/clv?ref=ai-md)
- [Brier, G. W. (1950): Verification of forecasts expressed in terms of probability, Monthly Weather Review](https://journals.ametsoc.org/view/journals/mwre/78/1/1520-0493_1950_078_0001_vofeit_2_0_co_2.xml)
- [novigapi.com pricing](https://novigapi.com/pricing?ref=ai-md)

---

Get a free API key: https://novigapi.com/sign-up?ref=ai-md . Docs: https://novigapi.com/docs?ref=ai-md . MCP: https://novigapi.com/api/mcp . Operated by Stunning Couches LLC. Independent. Not affiliated with, endorsed by or sponsored by Novig.
