Securing a sports stream API key
A streaming key is a bandwidth credential, and a leaked one is someone else using your allocation. Domain lock, origin IP binding, sport scoping, and why the key must never reach the browser.
What a leaked key actually costs
A streaming key is not a read-only credential. Whoever holds it can resolve playable URLs and spend your concurrency allocation, which means a leak shows up as your own viewers being squeezed out during the fixture you care most about.
It is also attributable to you. Upstream rights holders see traffic against your key, and a DMCA action follows the key, not the person who copied it.
Never ship the key to the browser
The most common mistake is calling the API directly from front-end JavaScript. Anything the browser can send, a viewer can read — bundling, obfuscation and environment variables prefixed for client exposure all leave the key in plain sight in the network tab.
Put a thin proxy on your own backend. It holds the key, applies whatever authorisation your product requires, and returns only the resolved source list. This is also the natural place to add your own rate limiting and to log who resolved what.
const API_BASE = process.env.XPORTAPI_BASE; // issued at provisioning
app.get('/api/stream/:sportId/:matchId', requireLoggedInUser, async (req, res) => {
const { sportId, matchId } = req.params;
const upstream = await fetch(
`${API_BASE}/v1/stream/${sportId}/${matchId}`,
{ headers: { 'x-api-key': process.env.XPORTAPI_KEY } } // server-side only
);
if (!upstream.ok) {
return res.status(upstream.status).json({ error: 'resolve failed' });
}
const { data } = await upstream.json();
// Forward only what the player needs.
res.json({
sources: data.sources.map(({ name, url, checkedAt }) => ({
name,
url,
checkedAt,
})),
});
}); Domain lock and origin IP binding
Two server-side controls are applied when the key is provisioned, and they are what make a leaked key largely useless to someone else.
Domain lock whitelists the HTTP referrers allowed to use the key, so a copy pasted into another site is rejected. Origin IP binding allowlists the server addresses that may call the API, which is the stronger of the two for a backend proxy because referrers can be forged while source addresses cannot easily be.
Both are configured during onboarding. Send the production domains and the egress IP addresses of your servers — not your office address, and remember that a platform with autoscaling may egress from a range rather than a single address.
Scope the key to what you actually serve
Keys are allocated against specific sports and leagues. A key scoped to football returns 403 Forbidden for a basketball match, which sounds like a limitation and is in fact the point: the blast radius of a leak is bounded by the scope.
Request the scope you serve today rather than everything you might serve eventually. Widening later is a provisioning change, not a migration.
Rotating a key you believe is exposed
There is no self-serve rotation, because keys are provisioned manually along with their domain and IP bindings. Contact the operator desk directly through WhatsApp or email and a replacement is issued with the same bindings.
Until the replacement lands, the fastest mitigation under your own control is tightening the IP allowlist to the single server that needs it. That takes effect without waiting for a new key.