Appearance
Client API (Xtream compatible)
This is the API IPTV apps use: TiviMate, IPTV Smarters, XCIPTV, OTT Navigator, Kodi PVR IPTV Simple, VLC and others. bs-control serves it at the root path, not under /api/v1, on the same listeners as the panel: http.listen (:8080 from the installer) and, when you set it, http.tls_listen (for example :443).
The full contract, with every JSON field in order and its JSON type, is spec/client-api.md in the repository. This page is a summary.
Try it
Replace U, P and the channel id 1 with a real line and channel:
bash
curl -s "http://tv.example.com:8080/player_api.php?username=U&password=P"
curl -s -o list.m3u "http://tv.example.com:8080/get.php?username=U&password=P&type=m3u_plus&output=ts"
curl -sL -o test.ts --max-time 10 "http://tv.example.com:8080/live/U/P/1.ts"Use curl -L for streams
Stream URLs answer 302 to the node (/s/<token>/stream.ts). VLC and IPTV apps follow it on their own. curl without -L only saves a tiny "Found" page.
General rules
GETandPOST. Query and form parameters are merged.HEADworks on stream URLs and does not use a connection slot.- A line logs in with
usernameandpassword, exactly as stored. Both are case sensitive. - CORS:
Access-Control-Allow-Origin: *on every client endpoint. - The real client IP is read from
X-Forwarded-FororCF-Connecting-IPonly when the request comes from a trusted proxy (settings.client_api.trusted_proxies). - About 20 requests per second per IP. Too many failed logins from one IP (
max_failed_logins_per_ipin 10 minutes) block that IP for 15 minutes. - Access logs hide usernames and passwords.
{base}in links issettings.general.client_url(or the panel URL), always with a port and a trailing slash, for examplehttp://tv.example.com:80/. It never comes from the requestHostheader.
A line can play when it is not banned, is enabled and has not expired. Then the request must pass, in order: global blocks (IP, country, ASN, user agent), the line's own limits (allowed IPs, allowed user agents, forced country), and for streams the allowed output, bouquet membership and a free connection slot.
player_api.php
Paths: /player_api.php and /player_api. Parameters: username, password, action.
Login errors are always HTTP 200 with user_info.auth = 0, because apps read that field:
json
{"user_info":{"auth":0,"status":"Expired","message":"Account has expired."}}action | Code | Extra parameters | Returns |
|---|---|---|---|
| (none) | login object with user_info and server_info | ||
get_live_categories | 201 | categories | |
get_vod_categories | 200 | categories | |
get_series_categories | 206 | categories | |
get_live_streams | 202 | category_id, params[offset], params[items_per_page] | live streams |
get_vod_streams | 203 | category_id, params[offset], params[items_per_page] | movies |
get_vod_info | 209 | vod_id | one movie |
get_series | 208 | category_id | series |
get_series_info | 204 | series_id | one series with seasons and episodes |
get_short_epg | 205 | stream_id, limit (default 4, max 50) | {"epg_listings":[...]} |
get_simple_data_table | 207 | stream_id | {"epg_listings":[...]} from 24 hours ago |
get_epg | 0 | stream_id, from_now | array of programmes |
actioncan be the name or the old numeric code.- An empty result is
[], never an error. - A line sees exactly the items in its bouquets, in bouquet order, with duplicates removed.
- EPG
titleanddescriptionare standard base64.*_timestampfields are strings, like the original Xtream Codes.
get.php (playlists)
/get.php?username=U&password=P&type=m3u_plus&output=ts
/playlist/U/P[/TYPE][?output=O&key=K]| Parameter | Values | Default |
|---|---|---|
type | m3u, m3u_plus | m3u_plus |
output | ts (or mpegts), m3u8 (or hls) | ts |
key | comma list of live, created_live, radio_streams, movie, series | everything |
Other type values (Enigma2 and friends) answer 400 in this version.
Errors are a plain HTTP status with a one line text body and an X-BS-Error header:
| Status | X-BS-Error |
|---|---|
| 401 | invalid_credentials |
| 403 | expired, disabled, banned, restricted, playlist_disabled, output_not_allowed |
| 400 | unknown_type |
| 429 | too_many_downloads (more than 2 at once per line) |
| 503 | maintenance, with Retry-After |
xmltv.php
/xmltv.php?username=U&password=P[&gzip=1]
/epg/U/P
/epg/U/P/gzStandard XMLTV with only the channels in the line's bouquets, from 24 hours ago to the end of the guide. Times are in the panel time zone. The file is prebuilt after each EPG import and supports Range and If-Modified-Since. Same errors as get.php.
Stream URLs
| URL | Content | Output |
|---|---|---|
/live/U/P/{id}.ts | live, created, radio | MPEG-TS |
/live/U/P/{id}.m3u8 | live, created, radio | HLS |
/live/U/P/{id} | live, created, radio | MPEG-TS |
/U/P/{id}.ts, /U/P/{id}.m3u8, /U/P/{id} | short form used in playlists | as above |
/movie/U/P/{id}.{ext} | movie | file, with Range |
/series/U/P/{id}.{ext} | episode | file, with Range |
/streaming/live.php?username=U&password=P&stream={id}&extension={ext} | old XC form | 302 to /live/... |
/timeshift/U/P/{minutes}/{start}/{id}.ts or .m3u8, /streaming/timeshift.php | catch-up | TS with Range, or HLS VOD playlist. {start} is YYYY-MM-DD:HH-MM[-SS] in the panel timezone. See catch-up. |
What the control answers, by the node's delivery_mode:
redirect(default):302to{scheme}://{public_host}:{port}/s/{token}/stream.ts(orindex.m3u8, orfile.{ext}for VOD). The scheme is the same as the client's request.proxy: the control streams the node's answer through itself. HLS playlists are rewritten so segments load from/s/<token>/<segment>on the control, which forwards them to the right node. A node that enrolled over loopback (the node on the panel machine) getsproxyautomatically.directchannels:302to the source. No slot, no node, no stats. A source with a username or password in the URL, a query string, a fragment or a provider account always plays through a node, so its address never reaches viewers.
The short form /U/P/{id} and /streaming/live.php work while the setting client_api.legacy_urls is on (the default).
Stream errors use the X-BS-Error header too:
| Status | Code | When |
|---|---|---|
| 401 | invalid_credentials | wrong username or password |
| 403 | expired, disabled, banned | line state. With expired_video_url set, expired and disabled lines get a 302 to that clip instead. |
| 403 | restricted | blocked IP, country, ASN or user agent, or a line limit |
| 403 | output_not_allowed | output not allowed for the line, or turned off in settings |
| 404 | not_found | no such item, disabled, or not in the line's bouquets |
| 429 | connection_limit | slots full and the line policy is reject |
| 429 | rate_limited | too many requests, with Retry-After |
| 503 | stream_unavailable | no node can serve it right now, or the source account is full, with Retry-After: 5 |
The node can answer with an error too. An HLS or VOD session is bound to the first client IP that opened it. Another IP gets 403 session_in_use until the session goes idle.
Connection slots
- Each line has
max_connections. A slot ispendingfrom the redirect until the node says the viewer arrived (15 seconds at most), thenactivewhile the node sends heartbeats. - The same line, IP and content reuse the same slot. VOD seeks, reconnects and app probes do not use extra slots.
- When all slots are taken, the line's policy decides.
kick_oldest(default) lets the new viewer in and closes the oldest slot, preferring one from the same IP, so channel zapping works.rejectanswers429.
Not served in this version
panel_api.php, enigma2.php, /play/{token} links, token URLs, activation codes, ?utc= catch-up on live URLs, /thumb, /subtitle, RTMP, and MAG or Stalker portals. MAG and Enigma2 are planned.