Skip to content

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 ​

  • GET and POST. Query and form parameters are merged. HEAD works on stream URLs and does not use a connection slot.
  • A line logs in with username and password, 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-For or CF-Connecting-IP only 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_ip in 10 minutes) block that IP for 15 minutes.
  • Access logs hide usernames and passwords.
  • {base} in links is settings.general.client_url (or the panel URL), always with a port and a trailing slash, for example http://tv.example.com:80/. It never comes from the request Host header.

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."}}
actionCodeExtra parametersReturns
(none)login object with user_info and server_info
get_live_categories201categories
get_vod_categories200categories
get_series_categories206categories
get_live_streams202category_id, params[offset], params[items_per_page]live streams
get_vod_streams203category_id, params[offset], params[items_per_page]movies
get_vod_info209vod_idone movie
get_series208category_idseries
get_series_info204series_idone series with seasons and episodes
get_short_epg205stream_id, limit (default 4, max 50){"epg_listings":[...]}
get_simple_data_table207stream_id{"epg_listings":[...]} from 24 hours ago
get_epg0stream_id, from_nowarray of programmes
  • action can 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 title and description are standard base64. *_timestamp fields 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]
ParameterValuesDefault
typem3u, m3u_plusm3u_plus
outputts (or mpegts), m3u8 (or hls)ts
keycomma list of live, created_live, radio_streams, movie, serieseverything

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:

StatusX-BS-Error
401invalid_credentials
403expired, disabled, banned, restricted, playlist_disabled, output_not_allowed
400unknown_type
429too_many_downloads (more than 2 at once per line)
503maintenance, with Retry-After

xmltv.php ​

/xmltv.php?username=U&password=P[&gzip=1]
/epg/U/P
/epg/U/P/gz

Standard 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 ​

URLContentOutput
/live/U/P/{id}.tslive, created, radioMPEG-TS
/live/U/P/{id}.m3u8live, created, radioHLS
/live/U/P/{id}live, created, radioMPEG-TS
/U/P/{id}.ts, /U/P/{id}.m3u8, /U/P/{id}short form used in playlistsas above
/movie/U/P/{id}.{ext}moviefile, with Range
/series/U/P/{id}.{ext}episodefile, with Range
/streaming/live.php?username=U&password=P&stream={id}&extension={ext}old XC form302 to /live/...
/timeshift/U/P/{minutes}/{start}/{id}.ts or .m3u8, /streaming/timeshift.phpcatch-upTS 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): 302 to {scheme}://{public_host}:{port}/s/{token}/stream.ts (or index.m3u8, or file.{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) gets proxy automatically.
  • direct channels: 302 to 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:

StatusCodeWhen
401invalid_credentialswrong username or password
403expired, disabled, bannedline state. With expired_video_url set, expired and disabled lines get a 302 to that clip instead.
403restrictedblocked IP, country, ASN or user agent, or a line limit
403output_not_allowedoutput not allowed for the line, or turned off in settings
404not_foundno such item, disabled, or not in the line's bouquets
429connection_limitslots full and the line policy is reject
429rate_limitedtoo many requests, with Retry-After
503stream_unavailableno 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 is pending from the redirect until the node says the viewer arrived (15 seconds at most), then active while 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. reject answers 429.

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.

Bitstream documentation