Skip to main content

Stream URLs: how long they last, and calling the API from a browser (CORS)

How long a stream URL from the Angelcam API is valid, how to get one that lasts longer, how to handle HLS redirects, and CORS support.

Written by Ondrej Lanc

This article is for developers using the Angelcam API. It explains how long the stream URLs you get from the API stay valid, how to get one that lasts longer, and whether you can call the API from a browser.

Stream URLs carry a token

The camera endpoints (for example GET /v1/cameras/{id}/) return stream URLs with a token query parameter, for example https://m1.angelcam.com/stream/81/playlist.m3u8?token=…. The token limits how long the URL can be used:

  • Fragmented MP4, MPEG-TS and MJPEG: the token is checked only when the player connects. Once connected, the stream keeps playing for as long as you stay connected. These tokens are short-lived, so always request a new URL from the API before you reconnect.

  • HLS: the token is checked on every request and lasts about an hour. Don't rely on an exact expiry time.

Get a URL that lasts longer

Add stream_expires_at to the camera request to ask for URLs valid until a time you choose. The value is a date and time in the future in ISO 8601, for example:

GET /v1/cameras/{id}/?stream_expires_at=2026-12-31T23:00:00Z

A time in the past is rejected. Use this when you can't fetch a fresh URL every time, but keep the time as short as your use allows: anyone who has the URL can watch the stream until it expires.

Handle HLS redirects

When an HLS token expires, the streaming server answers with a permanent redirect (301) to a new valid URL. Your player must follow it and keep using the new URL.

Most HTTP clients do this automatically. Some media players treat a 301 like a temporary 302: they keep requesting the original URL and follow the redirect every time. Once the original token is too old, the server answers 401 and playback stops. If you see that, make your player store the redirected URL, or fetch a new URL from the API and reconnect.

Calling the API from a browser (CORS)

The API (/v1/) and OAuth (/oauth/) endpoints allow cross-origin requests from any origin, so you can call them directly from JavaScript in a browser.

Warning: anything you put in browser code can be read by your users. Don't put a personal access token or OAuth client secret there. Call the Angelcam API from your own backend and pass only the stream URL to the browser.

Did this answer your question?