Guides

Real-Time Streaming

WebSocket streaming is available on a custom plan only. Please contact us.

Instead of polling the REST endpoint, open a persistent WebSocket connection to receive instant price updates as prediction market odds move. Built on the Pusher protocol — any Pusher client library works.

How It Works

  1. Call GET /v2/stream/events to get WebSocket credentials and an initial data snapshot.
  2. Connect via Pusher and subscribe to the provided channel.
  3. Receive real-time eventID notifications whenever an event's odds change.
  4. Fetch full event data for changed IDs using GET /v2/events?eventIDs=...

Available Feeds

FeedDescriptionRequired Params
events:liveEvents currently open and actively tradingNone
events:upcomingUpcoming events with odds for a specific leagueleagueID
events:byidUpdates for a single specific eventeventID

Additional feeds will be added over time. Contact support if your use case isn't covered.

Quick Start — JavaScript

const axios = require("axios");
const Pusher = require("pusher-js");

const API_KEY = "YOUR_API_KEY";
const API_BASE = "https://api.sportsgameodds.com/v2";

const run = async () => {
  const events = new Map();

  // Step 1: Get connection details + initial snapshot
  const streamInfo = await axios
    .get(`${API_BASE}/stream/events`, {
      headers: { "x-api-key": API_KEY },
      params: { feed: "events:live" },
    })
    .then((r) => r.data);

  // Seed initial data
  streamInfo.data.forEach((e) => events.set(e.eventID, e));
  console.log(`${events.size} events loaded`);

  // Step 2: Connect and listen for changes
  const pusher = new Pusher(streamInfo.pusherKey, streamInfo.pusherOptions);
  pusher.subscribe(streamInfo.channel).bind("data", async (changed) => {
    const eventIDs = changed.map(({ eventID }) => eventID).join(",");

    const updated = await axios
      .get(`${API_BASE}/events`, {
        headers: { "x-api-key": API_KEY },
        params: { eventIDs },
      })
      .then((r) => r.data);

    updated.data.forEach((e) => events.set(e.eventID, e));
    console.log(`Updated ${updated.data.length} event(s)`);
  });

  process.on("SIGINT", pusher.disconnect);
};

run();

Quick Start — Python

import requests
import pusherclient
import json

API_KEY = "YOUR_API_KEY"
API_BASE = "https://api.sportsgameodds.com/v2"

def handle_update(data):
    changed = json.loads(data)
    event_ids = ",".join([e["eventID"] for e in changed])

    updated = requests.get(
        f"{API_BASE}/events",
        headers={"x-api-key": API_KEY},
        params={"eventIDs": event_ids}
    ).json()

    for event in updated["data"]:
        print(f"Updated: {event['eventID']}")

stream = requests.get(
    f"{API_BASE}/stream/events",
    headers={"x-api-key": API_KEY},
    params={"feed": "events:live"}
).json()

pusher = pusherclient.Pusher(stream["pusherKey"])
channel = pusher.subscribe(stream["channel"])
channel.bind("data", handle_update)

Troubleshooting

  • No connection — verify your API key has streaming access (Pro plan required).
  • No updates received — confirm you're subscribed to the correct channel and the feed has active events.
  • High memory usage — periodically clean up resolved events and store only the fields you need.