Streaming API
Playback
Play an ALT Sports Data stream in the browser and let viewers switch the audio language.
Streams are standard HLS. Most browsers need a library such as hls.js; Safari can also play HLS natively.
Fetch the catalog on your server
Call the stream catalog from your backend, where your API key stays private, and pass only the
master_hls_url to the browser. The API does not accept calls from other websites' pages.
Play the master playlist
Check Hls.isSupported() first. Chrome answers "maybe" to the native HLS check, so testing native support first
would skip hls.js there and leave you without audio-track control.
<video id="player" controls playsinline></video>
<script src="https://cdn.jsdelivr.net/npm/hls.js@1.5.20/dist/hls.min.js"></script>
<script>
// masterUrl comes from your backend: stream.master_hls_url
const video = document.getElementById('player');
let hls = null;
if (Hls.isSupported()) {
hls = new Hls();
hls.loadSource(masterUrl);
hls.attachMedia(video);
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
video.src = masterUrl; // Safari and iOS without Media Source Extensions
}
</script>Switch audio language
The master playlist carries every language as an audio track on the same clock as the video, so switching is instant and stays in sync. Non-English tracks are generated by machine; see How streaming works.
A track's lang comes from the playlist and can be a 3-letter code (spa) where the catalog's
available_languages uses 2 letters (es). Match both forms instead of assuming they are equal:
const SAME_LANGUAGE = { en: 'eng', es: 'spa', pt: 'por', fr: 'fra', de: 'deu', ja: 'jpn' };
function selectAudio(hls, code) {
const wanted = [code, SAME_LANGUAGE[code]].filter(Boolean);
const index = hls.audioTracks.findIndex((track) =>
wanted.some((w) => (track.lang || '').toLowerCase().startsWith(w))
);
if (index >= 0) hls.audioTrack = index;
}
hls?.on(Hls.Events.MANIFEST_PARSED, () => selectAudio(hls, 'es'));Use the stream's available_languages to build your language picker before the player loads.
Status changes
A stream's status is scheduled, live or ended. Poll GET /v1/streams/{stream_id} (responses may be
cached for 30 seconds) to notice when a scheduled stream goes live. There are no webhooks or push notifications yet.
For a fuller walk-through that starts from a schedule, see the Play a stream recipe.