altsportsdata
v1.0.0
Published
Production-grade alternative sports data feed — odds, events, futures, settlement for 30 leagues
Maintainers
Readme
AltSportsData SDK (TypeScript)
Production-grade alternative sports data feed — odds, events, futures, settlement for 30 leagues.
Original model-generated probabilities for sports nobody else can price. Built for prediction markets, DFS platforms, and sportsbooks.
Zero runtime dependencies. Uses native fetch (Node 18+, Bun, Deno).
npm install altsportsdataQuick Start
import { AltSportsData } from "altsportsdata";
const client = new AltSportsData({ apiKey: "your_key" });
// Discover leagues with data shapes
const leagues = await client.getLeagues();
// → [{ league: "spr", dataShape: "field", archetype: "racing", markets: "..." }, ...]
// Scope to a league
const spr = client.getLeague("spr");
spr.dataShape // → "field"
spr.archetype // → "racing"
spr.contractHints // → { contractTypes: ["outright_winner", ...], ... }
// Get odds
const events = await spr.getEvents({ status: "upcoming" });
const odds = await spr.getMoneylines(events[0].id);For Prediction Markets (Kalshi, Polymarket)
Fair Probabilities (vig-removed)
const client = new AltSportsData({ apiKey: "key", oddsFormat: "probability" });
const spr = client.getLeague("spr");
// What contracts should I create?
spr.dataShape // → "field" — many binary contracts per event
spr.contractHints // → contract types, probability shape, settlement
// Fair probabilities — vig removed, sums to 1.0
const probs = await spr.getFairProbabilities(eventId);
// → [{ athlete: "Eli Tomac", fairProbability: 0.3069, rawOdds: 2.02, margin: 61, outcomeId: "..." }]
const total = probs.reduce((s, p) => s + p.fairProbability, 0);
// → 1.000000
// Create contracts
for (const p of probs) {
await createContract({
question: `Will ${p.athlete} win?`,
probability: p.fairProbability,
settlementId: p.outcomeId,
});
}Fair Matchup Probabilities
const matchups = await spr.getFairMatchupProbabilities(eventId);
// → [{ player1: "Tomac", fairProb1: 0.562, player2: "Lawrence", fairProb2: 0.438, margin: 7.19 }]Data Shapes — Know What Contracts to Create
| Shape | Leagues | Contract Pattern |
|-------|---------|-----------------|
| field | F1, Supercross, NHRA... (12) | Many binary: "Will X win?", "Top 3?" |
| match | BKFC, MASL, Power Slap... (12) | One binary per matchup: "A beats B?" |
| bracket | WSL, SLS, Formula Drift (3) | Layered: heat + event contracts |
Settlement
const result = await client.getSettlement(eventId);
for (const [market, data] of Object.entries(result.markets)) {
const winners = (data as any).winners ?? [];
for (const w of winners) {
console.log(`✅ ${w.athlete} — settled at ${result.settledAt}`);
}
}For Sportsbooks (DraftKings, Bet365)
// American odds
const client = new AltSportsData({ apiKey: "key", oddsFormat: "american" });
const odds = await client.getMoneylines(eventId);
// Cross-league market discovery
const allMatchups = await client.getMarkets({ market: "matchup" });
const racingMoneylines = await client.getMarkets({ market: "moneyline", archetype: "racing" });For DFS (PrizePicks, Underdog)
const matchups = await client.getMatchups(eventId);
const props = await client.getPlayerProps(eventId);
const totals = await client.getPlayerTotals(eventId, "finishingPosition");Odds Conversion
import { AltSportsData, convertOdds } from "altsportsdata";
// Set once — all responses auto-convert
const client = new AltSportsData({ apiKey: "key", oddsFormat: "probability" });
// Or convert individual values
convertOdds(2.50, "decimal", "american") // → 150
convertOdds(2.50, "decimal", "probability") // → 0.4
AltSportsData.convert(150, "american", "decimal") // → 2.5Batch & Polling
// Batch: fetch odds for many events concurrently
const events = await client.getEvents({ league: "spr", status: "upcoming" });
const ids = events.map(e => e.id!);
const batch = await client.getOddsBatch(ids, "moneyline", 5);
// Live polling — async generator
for await (const update of client.pollOdds(eventId, "moneyline", { interval: 5, maxPolls: 60 })) {
console.log(update);
}Enterprise Reliability
const client = new AltSportsData({
apiKey: "key",
maxRetries: 3, // exponential backoff on 429/5xx
retryBackoff: 0.5, // base delay in seconds
timeout: 30_000, // per-request timeout (ms)
});- Automatic exponential backoff with jitter
- Respects
Retry-Afterheaders - Request tracing via
X-Request-ID - Full TypeScript types for all responses
Full API
// Discovery
client.getLeagues({ archetype?, market? })
client.getLeagueInfo(league)
client.listMarketTypes()
spr.describe()
// Events
client.getEvents({ league?, status?, startDate?, endDate?, sort? })
client.getEvent(eventId)
client.getParticipants(eventId)
// Markets (cross-league)
client.getMarkets({ market?, archetype?, status?, limit? })
// Odds
client.getMoneylines(eventId)
client.getMatchups(eventId)
client.getTotals(eventId, subMarket?)
client.getExactas(eventId, n?)
client.getPodiums(eventId)
client.getHeatWinners(eventId)
client.getFastestLap(eventId)
client.getShows(eventId)
client.getOdds(eventId, market, { exactasType?, subMarket? })
// Prediction market
client.getFairProbabilities(eventId, market?)
client.getFairMatchupProbabilities(eventId)
client.getMarketProbabilities(eventId)
client.getTopFinishProbabilities(eventId, topN)
// DFS
client.getPlayerProps(eventId)
client.getPlayerMatchups(eventId)
client.getPlayerTotals(eventId, stat?)
// Batch & polling
client.getOddsBatch(eventIds, market?, maxConcurrent?)
client.pollOdds(eventId, market?, { interval?, maxPolls? })
// Settlement
client.getSettlement(eventId, markets?)
// Futures
client.listFutures()
client.getFutures(tour, type?, league?)
// Parlays
client.calculateParlay(eventId, picks)
// Static
AltSportsData.convert(value, from, to)Links
License
MIT
