Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Implementation examples in JavaScript / TypeScript and Python for SportXAPI.
fetch
interface ScheduleResponse { id: number; matchID: string; name: string; matchStatus: string; startDate: string; } async function getLiveMatches(): Promise<ScheduleResponse[]> { const apiKey = process.env.SPORTXAPI_KEY; if (!apiKey) throw new Error("SPORTXAPI_KEY is not defined"); const response = await fetch("https://apiv2.sportxapi.com/cricket/api/v2/match/schedule?status=live", { method: "GET", headers: { "X-API-Key": apiKey, "Accept": "application/json" } }); if (!response.ok) { throw new Error(`SportXAPI error: ${response.status} ${response.statusText}`); } return response.json(); } getLiveMatches().then(matches => console.log("Live matches:", matches));
requests
import os import requests def get_live_matches(): api_key = os.getenv("SPORTXAPI_KEY") if not api_key: raise ValueError("Missing SPORTXAPI_KEY environment variable") url = "https://apiv2.sportxapi.com/cricket/api/v2/match/schedule" headers = { "X-API-Key": api_key, "Accept": "application/json" } params = {"status": "live"} response = requests.get(url, headers=headers, params=params) response.raise_for_status() return response.json() if __name__ == "__main__": live_matches = get_live_matches() print(live_matches)
/cricket/api/v2/match/:matchId/stream
const EventSource = require("eventsource"); const matchId = "100123"; const apiKey = process.env.SPORTXAPI_KEY; const stream = new EventSource(`https://apiv2.sportxapi.com/cricket/api/v2/match/${matchId}/stream`, { headers: { "X-API-Key": apiKey } }); stream.onmessage = (event) => { const payload = JSON.parse(event.data); console.log("Realtime match update:", payload); }; stream.onerror = (err) => { console.error("SSE stream error:", err); };