Quick Start Guide
Get started with AltSportsData in 5 minutes. This guide will walk you through making your first API call and integrating data into your application.
1. Get Your API Key (1 minute)
Option A: Request via API
curl -X POST https://altsportsleagues.ai/api/request-access \
-H "Content-Type: application/json" \
-d '{
"email": "your@email.com",
"use_case": "development"
}'Option B: Sign Up Online
Visit altsportsdata.com/api-keys (opens in a new tab) and create a free developer account.
You'll receive your API key instantly via email.
2. Test the API (30 seconds)
Make your first request:
export API_KEY="your-api-key-here"
curl https://api.altsportsdata.com/v1/leagues \
-H "Authorization: Bearer $API_KEY"Expected response:
{
"success": true,
"data": {
"leagues": [
{
"id": "epl",
"name": "English Premier League",
"sport": "soccer",
"tier": 1,
"country": "England",
"teams_count": 20
}
],
"total": 1,
"page": 1,
"per_page": 10
}
}β Success! You've made your first API call.
3. Choose Your Language (1 minute)
JavaScript/TypeScript Setup
npm install @altsportsdata/sdkimport { AltSportsDataClient } from '@altsportsdata/sdk';
const client = new AltSportsDataClient({
apiKey: process.env.API_KEY
});
// Fetch leagues
const leagues = await client.leagues.list();
console.log(leagues);
// Get specific league
const epl = await client.leagues.get('epl');
console.log(epl);
// Get matches
const matches = await client.matches.list({
league: 'epl',
date: '2024-10-28'
});
console.log(matches);Python Setup
pip install altsportsdatafrom altsportsdata import Client
client = Client(api_key='your-api-key')
# Fetch leagues
leagues = client.leagues.list()
print(leagues)
# Get specific league
epl = client.leagues.get('epl')
print(epl)
# Get matches
matches = client.matches.list(
league='epl',
date='2024-10-28'
)
print(matches)cURL
# Save API key
export API_KEY="your-api-key"
# Get leagues
curl -H "Authorization: Bearer $API_KEY" \
https://api.altsportsdata.com/v1/leagues
# Get specific league
curl -H "Authorization: Bearer $API_KEY" \
https://api.altsportsdata.com/v1/leagues/epl
# Get matches
curl -H "Authorization: Bearer $API_KEY" \
"https://api.altsportsdata.com/v1/matches?league=epl&date=2024-10-28"4. Explore Data Models (2 minutes)
Understanding our schema structure helps you work with the data effectively.
League Schema
interface League {
id: string; // Unique identifier
name: string; // Display name
sport: Sport; // Sport type
tier: 1 | 2 | 3 | 4; // Classification tier
country: string; // Primary country
teams_count: number; // Number of teams
season: Season; // Current season info
partnership: Partnership; // Partnership details
}Match Schema
interface Match {
id: string;
league_id: string;
home_team: Team;
away_team: Team;
scheduled_time: string;
status: 'scheduled' | 'live' | 'completed' | 'postponed';
score?: {
home: number;
away: number;
};
statistics?: MatchStatistics;
}5. Build Something (1 minute)
Example: League Standings Widget
React Component
import { useEffect, useState } from 'react';
import { AltSportsDataClient } from '@altsportsdata/sdk';
export function LeagueStandings({ leagueId }) {
const [standings, setStandings] = useState([]);
const client = new AltSportsDataClient({ apiKey: process.env.API_KEY });
useEffect(() => {
async function loadStandings() {
const data = await client.standings.get(leagueId);
setStandings(data);
}
loadStandings();
}, [leagueId]);
return (
<div className="standings">
<h2>League Standings</h2>
<table>
<thead>
<tr>
<th>Pos</th>
<th>Team</th>
<th>Pts</th>
</tr>
</thead>
<tbody>
{standings.map((team, index) => (
<tr key={team.id}>
<td>{index + 1}</td>
<td>{team.name}</td>
<td>{team.points}</td>
</tr>
))}
</tbody>
</table>
</div>
);
}Vue Component
<template>
<div class="standings">
<h2>League Standings</h2>
<table>
<thead>
<tr>
<th>Pos</th>
<th>Team</th>
<th>Pts</th>
</tr>
</thead>
<tbody>
<tr v-for="(team, index) in standings" :key="team.id">
<td>{{ index + 1 }}</td>
<td>{{ team.name }}</td>
<td>{{ team.points }}</td>
</tr>
</tbody>
</table>
</div>
</template>
<script setup>
import { ref, onMounted } from 'vue';
import { AltSportsDataClient } from '@altsportsdata/sdk';
const props = defineProps(['leagueId']);
const standings = ref([]);
const client = new AltSportsDataClient({ apiKey: import.meta.env.API_KEY });
onMounted(async () => {
standings.value = await client.standings.get(props.leagueId);
});
</script>Vanilla JavaScript
<!DOCTYPE html>
<html>
<head>
<title>League Standings</title>
</head>
<body>
<div id="standings"></div>
<script>
const API_KEY = 'your-api-key';
const LEAGUE_ID = 'epl';
fetch(`https://api.altsportsdata.com/v1/standings/${LEAGUE_ID}`, {
headers: {
'Authorization': `Bearer ${API_KEY}`
}
})
.then(res => res.json())
.then(data => {
const html = `
<h2>League Standings</h2>
<table>
<thead>
<tr><th>Pos</th><th>Team</th><th>Pts</th></tr>
</thead>
<tbody>
${data.standings.map((team, i) => `
<tr>
<td>${i + 1}</td>
<td>${team.name}</td>
<td>${team.points}</td>
</tr>
`).join('')}
</tbody>
</table>
`;
document.getElementById('standings').innerHTML = html;
});
</script>
</body>
</html>Common Patterns
Fetching with Pagination
async function fetchAllLeagues() {
const allLeagues = [];
let page = 1;
let hasMore = true;
while (hasMore) {
const response = await client.leagues.list({ page, per_page: 100 });
allLeagues.push(...response.leagues);
hasMore = response.page < response.total_pages;
page++;
}
return allLeagues;
}Error Handling
try {
const league = await client.leagues.get('invalid-id');
} catch (error) {
if (error.status === 404) {
console.log('League not found');
} else if (error.status === 429) {
console.log('Rate limit exceeded');
} else {
console.error('API error:', error.message);
}
}Caching Strategies
// Simple in-memory cache
const cache = new Map();
const CACHE_TTL = 60000; // 1 minute
async function getCachedLeague(leagueId) {
const cached = cache.get(leagueId);
if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
return cached.data;
}
const data = await client.leagues.get(leagueId);
cache.set(leagueId, { data, timestamp: Date.now() });
return data;
}Real-time Updates
// WebSocket connection
const ws = new WebSocket('wss://ws.altsportsdata.com/v1/live');
ws.onopen = () => {
// Subscribe to specific matches
ws.send(JSON.stringify({
type: 'subscribe',
channels: ['match:epl-001', 'match:epl-002']
}));
};
ws.onmessage = (event) => {
const update = JSON.parse(event.data);
console.log('Live update:', update);
// Update your UI
};Next Steps
Deep Dive
- Complete API Reference - All endpoints
- Schema Explorer - Browse data models
- Authentication Guide - Security details
Advanced Topics
- WebSocket Streaming - Real-time data
- Batch Operations - Efficient data access
- Webhooks - Event-driven integration
- Sportsbook Onboarding Service - Complete league integration guide
Best Practices
- Rate Limiting - Optimize API usage
- Error Handling - Robust integration
- Caching Strategies - Performance optimization
- Security - Protect your integration
Example Projects
Check out complete example applications:
- Sports Dashboard (React) (opens in a new tab)
- Match Tracker (Vue) (opens in a new tab)
- API Proxy (Node.js) (opens in a new tab)
- Mobile App (React Native) (opens in a new tab)
Get Help
- Documentation: You're reading it!
- Examples: Code Examples
- Community: Discord Server (opens in a new tab)
- Support: support@altsportsdata.com
π You're Ready!
You've completed the quick start guide. You can now build amazing sports data applications with AltSportsData!