Odds API for Next.js

Fetch real-time odds in Next.js server components and route handlers, with your API key kept server-side and responses cached. Normalized JSON, no SDK.

Overview

The MoneyLine odds API is a plain REST/HTTPS API, which makes it a natural fit for the Next.js App Router. Fetch odds in a server component or route handler so your API key never reaches the browser, and use Next.js fetch caching (revalidate) to control freshness and cost.

Responses are normalized to American odds under canonical event IDs, so server components can render odds directly and route handlers can return a trimmed shape to the client without per-sportsbook parsing.

Key features

Server-side fetch

Call the API in server components/route handlers; the key stays off the client.

Built-in caching

Use Next.js fetch revalidate to tune freshness vs. request volume.

No SDK

Plain fetch against REST/HTTPS — nothing to install.

All leagues + props

Game lines and player props across every major US league.

Supported leagues

NFLNBAMLBNHLNCAAFNCAAB

Supported sportsbooks

DraftKingsFanDuelBetMGMCaesarsESPN BETFanaticsHard Rock BetBetRiversPinnaclebet365 (US)BovadaBetOnline.ag

Example request

Next.js App Router — server component with revalidate

Request

// app/odds/page.tsx (server component)
async function getOdds() {
  const res = await fetch(
    'https://mlapi.bet/v1/odds?league=nba&market=moneyline',
    {
      headers: { 'x-api-key': process.env.ML_API_KEY! },
      next: { revalidate: 60 }, // cache for 60s
    },
  )
  return res.json()
}

export default async function OddsPage() {
  const { data } = await getOdds()
  return (
    <ul>
      {data.map((g) => (
        <li key={g.eventId}>{g.eventId}</li>
      ))}
    </ul>
  )
}

Response

{
  "success": true,
  "data": [
    {
      "eventId": "nba-ev-311286",
      "leagueId": "nba",
      "bookmakers": [
        {
          "bookmakerId": "draftkings",
          "bookmakerName": "DraftKings",
          "markets": [
            { "marketType": "moneyline", "outcomes": [
              { "name": "Boston Celtics", "price": -180 },
              { "name": "Los Angeles Lakers", "price": 155 }
            ] }
          ]
        }
      ]
    }
  ]
}

Use cases

SSR odds pages

Render odds server-side for fast, indexable pages with your key hidden.

Route handlers

Proxy and trim the API response for your client from app/api routes.

ISR dashboards

Use revalidate to balance freshness against request volume and cost.

Latency & performance

FAQ

Where do I put my API key?

In a server-only env var (e.g. ML_API_KEY) read inside a server component or route handler, never a NEXT_PUBLIC_ variable.

How do I control freshness?

Use the Next.js fetch option next: { revalidate: <seconds> } to cache responses; lower for live odds, higher for static views.

Do I need an SDK?

No. It is REST over HTTPS, so the native fetch in the App Router is all you need.

Related

Start building in minutes

Free tier to start, one API key, normalized responses across every league and sportsbook.