SDK Overview
Official ALT Sports Data SDKs for TypeScript and Python.
SDK Overview
ALT Sports Data provides official SDKs for TypeScript and Python so you can move faster than raw HTTP while keeping full access to the public platform.
Available SDKs
TypeScript/Node.js
- Package:
altsportsdataon npm - Install:
npm install altsportsdata - Requirements: Node.js 16+ or modern browser
- TypeScript: Full type definitions included
Python
- Package:
altsportsdataon PyPI - Install:
pip install altsportsdata - Requirements: Python 3.8+
- Type Hints: Fully typed with py.typed marker
Credential model
Use the same ALT Sports Data credential you received for:
- direct API requests
- the TypeScript SDK
- the Python SDK
- the MCP server
Quick Start
import { AltSportsData } from 'altsportsdata';
const client = new AltSportsData({
apiKey: process.env.ALTSPORTSDATA_API_KEY
});
// List current Formula 1 events
const events = await client.events.list({
leagueId: 'f1',
limit: 10
});
console.log(events.data);from altsportsdata import AltSportsData
import os
client = AltSportsData(
api_key=os.getenv('ALTSPORTSDATA_API_KEY')
)
# List current Formula 1 events
events = client.events.list(
league_id='f1',
limit=10
)
print(events.data)SDK Features
Full API Coverage
All REST API endpoints are available through intuitive SDK methods:
- Leagues: List, get, fingerprint, valuation, readiness, compare, similar
- Discovery: Search, similarity matching
- Valuation: Multi-dimensional scoring, tier definitions
- Sports: List sports, archetypes
- Events: List events, filter by league/date
- Markets: List betting markets
Type Safety
Both SDKs provide full type definitions:
// TypeScript autocomplete and type checking
const leagues: ListLeaguesResponse = await client.leagues.list({
sportType: 'Soccer', // IDE autocomplete available
tier: 'elite' // Type-checked values
});
// Strongly typed responses
leagues.data.forEach((league: League) => {
console.log(league.name); // Type-safe property access
});# Python type hints
from altsportsdata.types import League, ListLeaguesResponse
leagues: ListLeaguesResponse = client.leagues.list(
sport_type='Soccer',
tier='elite'
)
# Type-safe iteration
league: League
for league in leagues.data:
print(league.name) # Type-checked attributesError Handling
Comprehensive exception types for better error handling:
import {
ResourceNotFoundError,
RateLimitError,
ValidationError
} from 'altsportsdata';
try {
const league = await client.leagues.get('invalid_id');
} catch (error) {
if (error instanceof ResourceNotFoundError) {
console.error('League not found');
} else if (error instanceof RateLimitError) {
console.error('Rate limit exceeded');
console.log(`Retry after: ${error.retryAfter}`);
} else if (error instanceof ValidationError) {
console.error('Invalid parameters:', error.details);
}
}from altsportsdata.exceptions import (
ResourceNotFoundError,
RateLimitError,
ValidationError
)
try:
league = client.leagues.get('invalid_id')
except ResourceNotFoundError:
print('League not found')
except RateLimitError as e:
print(f'Rate limit exceeded')
print(f'Retry after: {e.retry_after}')
except ValidationError as e:
print(f'Invalid parameters: {e.details}')Pagination Helpers
Easy pagination for list endpoints:
// Manual pagination
let offset = 0;
const limit = 100;
while (true) {
const response = await client.leagues.list({ limit, offset });
// Process leagues
response.data.forEach(league => {
console.log(league.name);
});
if (!response.meta.has_more) break;
offset += limit;
}
// Auto-pagination iterator
for await (const league of client.leagues.listAll({ tier: 'elite' })) {
console.log(league.name);
}# Manual pagination
offset = 0
limit = 100
while True:
response = client.leagues.list(limit=limit, offset=offset)
# Process leagues
for league in response.data:
print(league.name)
if not response.meta.has_more:
break
offset += limit
# Auto-pagination iterator
for league in client.leagues.list_all(tier='elite'):
print(league.name)Retry Logic
Automatic retry with exponential backoff for transient errors:
const client = new AltSportsData({
apiKey: 'your-api-key',
retry: {
enabled: true,
maxRetries: 3,
initialDelay: 1000,
maxDelay: 10000
}
});client = AltSportsData(
api_key='your-api-key',
retry_config={
'enabled': True,
'max_retries': 3,
'initial_delay': 1.0,
'max_delay': 10.0
}
)Resource Namespaces
All SDK methods are organized by resource:
| Namespace | Description |
|---|---|
client.leagues | League operations (list, get, readiness, compare, etc.) |
client.discovery | Search and similarity matching |
client.valuation | Scoring and tier definitions |
client.sports | Sports types and archetypes |
client.events | Event data and schedules |
client.markets | Betting market information |