Skip to main content

Documentation Index

Fetch the complete documentation index at: https://txline-docs.txodds.com/llms.txt

Use this file to discover all available pages before exploring further.

Stream Odds Updates

Connect to the odds stream for real-time updates.
const streamUrl = "https://oracle-dev.txodds.com/api/odds/stream";
const streamResponse = await fetch(streamUrl, {
  headers: {
    Authorization: `Bearer ${jwt}`,
    "X-Api-Token": apiToken,
    Accept: "text/event-stream",
    "Cache-Control": "no-cache",
  },
});

if (!streamResponse.ok) {
  throw new Error(`Stream failed: ${streamResponse.status}`);
}

const reader = streamResponse.body!.getReader();
const decoder = new TextDecoder();

try {
  while (true) {
    const { value, done } = await reader.read();
    if (done) break;

    const chunk = decoder.decode(value);
    const lines = chunk.split("\n");

    for (const line of lines) {
      if (line.startsWith("Message: ")) {
        try {
          const data = JSON.parse(line.substring(9));
          console.log("Odds update:", data);
        } catch (e) {
          // Skip invalid JSON
        }
      }
    }
  }
} finally {
  reader.releaseLock();
}

Stream Scores Updates

Connect to the scores stream for real-time updates.
const streamUrl = "https://oracle-dev.txodds.com/api/scores/stream";
const streamResponse = await fetch(streamUrl, {
  headers: {
    Authorization: `Bearer ${jwt}`,
    "X-Api-Token": apiToken,
    Accept: "text/event-stream",
    "Cache-Control": "no-cache",
  },
});

if (!streamResponse.ok) {
  throw new Error(`Stream failed: ${streamResponse.status}`);
}

const reader = streamResponse.body!.getReader();
const decoder = new TextDecoder();

try {
  while (true) {
    const { value, done } = await reader.read();
    if (done) break;

    const chunk = decoder.decode(value);
    const lines = chunk.split("\n");

    for (const line of lines) {
      if (line.startsWith("Message: ")) {
        try {
          const data = JSON.parse(line.substring(9));
          console.log("Scores update:", data);
        } catch (e) {
          // Skip invalid JSON
        }
      }
    }
  }
} finally {
  reader.releaseLock();
}