Oddlyx LogoOddlyx

Live Odds Endpoint

Stream real-time odds updates for in-progress games.

GET
/api/v1/nba/odds/live

Description

Returns the latest odds for live games. Use the WebSocket for real-time push updates (recommended), or the REST endpoint for one-off fetches or fallback.

Plan availability

Live odds (WebSocket and /api/v1/nba/odds/live) are available on all paid plans (Starter, Pro, Elite).

WebSocket (recommended)

Connect to the /live-odds namespace with your API key. The server pushes live odds every ~20 seconds. Send subscribe with optional game_id, market_type, or book_id to filter.

import { io } from "socket.io-client";

const socket = io("https://odds-marketplace.onrender.com/live-odds", {
  auth: { apiKey: "sk_your_api_key_here" },
  transports: ["websocket", "polling"],
});

// Optional: filter by game, market, or book
socket.emit("subscribe", {
  game_id: 12345,
  market_type: "moneyline",
  book_id: 15,
});

socket.on("live_odds", (payload) => {
  if (payload.success) {
    console.log("Updated at", payload.updated_at);
    console.log("Games:", payload.data);
  } else {
    console.error("Error:", payload.error);
  }
});

socket.on("connect_error", (err) => {
  console.error("Connection failed:", err.message);
});

REST (one-off / fallback)

For a single snapshot or when WebSockets are not available, use GET /api/v1/nba/odds/live.

Example Request

curl -X GET "https://odds-marketplace.onrender.com/api/v1/nba/odds/live?game_id=12345&market_type=moneyline&book_id=15" \
  -H "Authorization: Bearer sk_your_api_key_here"

Client-side polling example

If you cannot use WebSockets, poll the REST endpoint on an interval (e.g. every 5 seconds).

const API_BASE_URL = "https://odds-marketplace.onrender.com";
const API_KEY = "sk_your_api_key_here";

type LiveOddsParams = {
  game_id?: number;
  market_type?: "spread" | "moneyline" | "total" | "player_props";
  book_id?: number;
};

async function fetchLiveOdds(params: LiveOddsParams = {}) {
  const searchParams = new URLSearchParams();

  if (params.game_id) searchParams.append("game_id", String(params.game_id));
  if (params.market_type) searchParams.append("market_type", params.market_type);
  if (params.book_id) searchParams.append("book_id", String(params.book_id));

  const url = `${API_BASE_URL}/api/v1/nba/odds/live?${searchParams.toString()}`;

  const res = await fetch(url, {
    headers: {
      "Authorization": `Bearer ${API_KEY}`,
    },
  });

  if (!res.ok) {
    throw new Error(`Live odds request failed: ${res.status}`);
  }

  const json = await res.json();
  // Shape:
  // {
  //   success: true,
  //   data: [...],
  //   count: number,
  //   updated_at: string
  // }
  return json;
}

// Basic polling loop (every 5 seconds)
const POLL_INTERVAL_MS = 5000;

setInterval(async () => {
  try {
    const response = await fetchLiveOdds({
      market_type: "moneyline",
      // game_id: 12345, // optionally scope to a single game
      // book_id: 15,    // optionally scope to a specific sportsbook
    });

    console.log("Live odds update at", response.updated_at);
    console.log("Games:", response.data);

    // TODO: update your UI or trading models here
  } catch (err) {
    console.error("Failed to fetch live odds", err);
  }
}, POLL_INTERVAL_MS);

Example Response

The live odds endpoint returns the latest snapshot for all in-progress games, filtered by any query parameters you provide.

{
  "success": true,
  "data": [
    {
      "game_id": 12345,
      "status": "live",
      "start_time": "2025-10-10T00:00:00Z",
      "away_team_id": 1,
      "home_team_id": 2,
      "away_team": {
        "id": 1,
        "name": "Boston Celtics",
        "abbr": "BOS"
      },
      "home_team": {
        "id": 2,
        "name": "Los Angeles Lakers",
        "abbr": "LAL"
      },
      "markets": {
        "moneyline": {
          "market_type": "moneyline",
          "outcomes": [
            {
              "outcome_id": "bos_ml_15",
              "book_id": 15,
              "team_id": 1,
              "label": "Boston Celtics",
              "odds": {
                "american": "+120",
                "decimal": 2.2,
                "implied_probability": 0.4545
              },
              "is_available": true
            },
            {
              "outcome_id": "lal_ml_15",
              "book_id": 15,
              "team_id": 2,
              "label": "Los Angeles Lakers",
              "odds": {
                "american": "-140",
                "decimal": 1.71,
                "implied_probability": 0.5848
              },
              "is_available": true
            }
          ]
        }
      }
    }
  ],
  "count": 1,
  "updated_at": "2025-10-10T00:00:05.123Z"
}
GET
/api/v1/nba/odds/live/movement

Live Line Movement

Pro / Elite only

The /api/v1/nba/odds/live/movement endpoint is available on Pro and Elite plans only. Starter plans will receive a 403 Forbidden response when calling this endpoint.

This endpoint returns a flattened list of outcomes with attached line_movement data (open line, current line, absolute change, direction) so you can track how spreads, totals, and prices have moved over time.

Example Request

curl -X GET "https://odds-marketplace.onrender.com/api/v1/nba/odds/live/movement?game_id=12345&market_type=spread" \
  -H "Authorization: Bearer sk_your_api_key_here"

Example Response

{
  "success": true,
  "data": [
    {
      "game_id": 12345,
      "league_id": 1,
      "market_type": "spread",
      "book_id": 69,
      "side": "home",
      "team_id": 2,
      "period": "full_game",
      "value": -3.5,
      "odds": {
        "decimal": 1.91,
        "american": -110,
        "fractional": "10/11",
        "original": 1.91
      },
      "line_movement": {
        "open_line": -2.5,
        "current_line": -3.5,
        "absolute_change": 1.0,
        "direction": "towards_favorite",
        "open_price": 1.95,
        "current_price": 1.91
      },
      "game": {
        "away_team_id": 1,
        "home_team_id": 2,
        "start_time": "2025-10-10T00:00:00Z",
        "status": "scheduled"
      }
    }
  ],
  "count": 1,
  "updated_at": "2025-10-10T00:00:05.123Z"
}