Odds API recipes and code examples

Recipes: Complete examples for odds screens, line alerts, line charts and props. PreciseAPI sports odds API documentation.

Short, complete examples for the most common things teams build.

Build a best-price odds screen

/v1/best-lines returns the top price per outcome across books and which books offer it — everything an odds screen row needs.

screen.mjs
const res = await fetch('https://api.preciseapi.com/v1/best-lines?league=nfl&markets=moneyline,spread', {
  headers: { Authorization: `Bearer ${process.env.PRECISEAPI_KEY}` },
});
const { data } = await res.json();

for (const event of data) {
  for (const m of event.markets) {
    const row = m.outcomes.map((o) => `${o.name} ${o.point ?? ''} ${o.best_price} @ ${o.best_books.join('/')}`);
    console.log(event.away.abbr, '@', event.home.abbr, m.key, row.join(' | '));
  }
}

Alert on line moves

Create a line-move alert rule in the dashboard (or via webhooks) and PreciseAPI pushes a signed line.moved event when a price moves by your threshold. See Webhooks & alerts for the payload and signature check.

Chart line movement

/v1/history returns the opening price, the current price and every move in between for a market. Feed the points straight into your charting library.

curl "https://api.preciseapi.com/v1/history?event_id=evt_%E2%80%A6&book=pinnacle&market=spread" \
  -H "Authorization: Bearer $PRECISEAPI_KEY"

Compare props with pick'em lines

/v1/props returns sportsbook props and DFS lines in one shape. DFS lines carry a variant so you can compare standard lines with standard lines.

curl "https://api.preciseapi.com/v1/props?league=nba&player=jokic&markets=player_points" \
  -H "Authorization: Bearer $PRECISEAPI_KEY"

Previous: Sources, leagues & markets · Next: Deep links & quick bet links