# API
# Getting Started
# Create API Token
For generate the API token, please login to the xaccel panel first, then follow the steps:
- Click the icon at top right corner.
- Click the icon at popup menu for
open the
Account Settings
page. - Click the icon at right of
API Token
option for generate new API token and save the settings.
# Use API Token
API Token is required to enable in your account settings.
The token will be used in the each API request for identify
your permission. You need add an Authorization: Token XXX
header to your each request. XXX
is the token you generated
in your Account Settings
page.
# Stream API
# Add Stream
POST /api/stream/add
# Example
$ curl -X POST \
-H 'Content-Type: application/json' \
-H 'Authorization: Token fiMY9nMdrE82zSD1IbUuVr6J' \
--data '{"name": "Test", "input_urls": ["lavfi://nullsrc=1920x1080,anullsrc"], "server_id": 1, "video_encoders": [{"codec": "copy"}], "audio_encoders": [{"codec": "copy"}], "outputs": [{"protocol": "hls", "filename": "index.m3u8"}]}' \
'http://192.168.2.3:8000/api/stream/add'
# Get Stream Config
GET /api/stream/<int:stream_id|str:stream_name>/config
# Example
$ curl -X GET \
-H 'Authorization: Token fiMY9nMdrE82zSD1IbUuVr6J' \
'http://192.168.2.3:8000/api/stream/Bein%20Sports/config'
# Get All Stream Stats
GET /api/stream/stats
# Example
$ curl -X GET \
-H 'Authorization: Token fiMY9nMdrE82zSD1IbUuVr6J' \
'http://192.168.2.3:8000/api/stream/stats'
# Get Stream Stats
GET /api/stream/<int:stream_id|str:stream_name>/stats
# Example
$ curl -X GET \
-H 'Authorization: Token fiMY9nMdrE82zSD1IbUuVr6J' \
'http://192.168.2.3:8000/api/stream/1/stats'
# Get Stream Log
GET /api/stream/<int:stream_id|str:stream_name>/log
$ curl -X GET \
-H 'Authorization: Token fiMY9nMdrE82zSD1IbUuVr6J' \
'http://192.168.2.3:8000/api/stream/1/log'
# Start/Stop/Restart Stream
POST /api/stream/<int:stream_id|str:stream_name>/start
POST /api/stream/<int:stream_id|str:stream_name>/stop
POST /api/stream/<int:stream_id|str:stream_name>/restart
$ curl -X POST \
-H 'Authorization: Token fiMY9nMdrE82zSD1IbUuVr6J' \
'http://192.168.2.3:8000/api/stream/1/start'
$ curl -X POST \
-H 'Authorization: Token fiMY9nMdrE82zSD1IbUuVr6J' \
'http://192.168.2.3:8000/api/stream/Bein%20Sports/stop'
TIP
If use the stream name to start or stop stream, since the name may contains whitespace and other special characters, so URL encoding is required.
# Restart All Streams
POST /api/stream/restart-all
# Example
$ curl -X POST \
-H 'Authorization: Token fiMY9nMdrE82zSD1IbUuVr6J' \
'http://192.168.2.3:8000/api/stream/restart-all'
# Delete Stream
POST /api/stream/<int:stream_id|str:stream_name>/delete
# Example
$ curl -X POST \
-H 'Authorization: Token fiMY9nMdrE82zSD1IbUuVr6J' \
'http://192.168.2.3:8000/api/stream/Bein%20Sports/delete'
# Update Stream Source
POST /api/stream/<int:stream_id|str:stream_name>/source-update
POST /api/stream/<int:stream_id|str:stream_name>/source-update-with-restart
# Post Data
["url1", "url2", "url3"]
# Example
$ curl -X POST \
-H 'Content-Type: application/json' \
-H 'Authorization: Token fiMY9nMdrE82zSD1IbUuVr6J' \
--data '["https://livesim.dashif.org/livesim/chunkdur_1/ato_7/testpic4_8s/Manifest.mpd"]' \
'http://192.168.2.3:8000/api/stream/Bein%20Sports/source-update'
TIP
You should post the json list data and the list contains the stream source URLs you want to update to. It will override the original stream source completely, so if the original sources contains backup URLs, you should post the backup URLs here too.
# Update Decryption Key
POST /api/stream/<int:stream_id|str:stream_name>/decryption-key-update
# Post Data
[
{
"kid": "32 bytes kid",
"key": "32 bytes key"
},
{
"kid": "32 bytes kid",
"key": "32 bytes key"
}
]
# Example
$ curl -X POST \
-H 'Content-Type: application/json' \
-H 'Authorization: Token fiMY9nMdrE82zSD1IbUuVr6J' \
--data '[{"kid": "ef6da52114a8965d2aa2e3956f649c86", "key": "7077907241013942bd543b8e1eb8dee9"}, {"kid": "ecf8aa2b4e2585937791bb593593ad4d", "key": "b43e943cfcc74fbeb80348aab91c761c"}]' \
'http://192.168.2.3:8000/api/stream/Bein%20Sports/decryption-key-update'
# Update Stream Config
POST /api/stream/<int:stream_id|str:stream_name>/update
POST /api/stream/<int:stream_id|str:stream_name>/update-with-restart
# Post Data
{
"name": "Stream Name",
"user_agent": "HTTP User-Agent",
"referer": "HTTP Referer",
"headers": "HTTP headers"
}
# Example
$ curl -X POST \
-H 'Content-Type: application/json' \
-H 'Authorization: Token fiMY9nMdrE82zSD1IbUuVr6J' \
--data '{"name": "BeinSports FHD", "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"}' \
'http://192.168.2.3:8000/api/stream/Bein%20Sports/update'
Notice
http_proxy
field is deprecated in v5 panel. A newproxy
option is added. It's a<int:proxy_id>
list. you need call proxy API to add proxy first. Then use theproxy
option in the POST to specify which proxy you want use for the stream.- For more stream config option and column type, please check the
stream_config
table in the database.
# Dynamic URL
POST /api/stream/<int:stream_id|str:stream_name>/dynamic-url
# Post Data
[
"http://x.x.x.x/new-url"
]
TIP
This API is for update the source stream URL's dynamic token or decryption key in real-time.
# Proxy API
# Add/Update Proxy
POST /api/proxy/add
POST /api/proxy/<int:proxy_id|str:proxy_name>/update
# Post Data
{
"name": "Proxy Test",
"type": "http",
"host": "192.168.1.1",
"port": 8001,
"username": "test",
"password": "test",
"streams": [1,2,3]
}
TIP
type
must behttp
,http+ssl
,socks5
,socks5+ssl
orssh
.username
andpassword
is optional.streams
is a<int:stream_id>
list, for specify which streams you want to use this proxy.
# Get Proxy Info
GET /api/proxy/info
GET /api/proxy/<int:proxy_id|str:proxy_name>/info
# Delete Proxy
POST /api/proxy/<int:proxy_id|str:proxy_name>/delete
# User API
# Add User
POST /api/user/add
# Post Data
{
"username": "Username",
"password": "Password"
}
TIP
If username or password is not specified, it will generate a random username and password. And return it in the response.
# Example
$ curl -X POST \
-H 'Content-Type: application/json' \
-H 'Authorization: Token fiMY9nMdrE82zSD1IbUuVr6J' \
--data '{"username": "test", "password": "test"}' \
'http://192.168.2.3:8000/api/user/add'
{
"user_id": 1,
"username": "test",
"password": "test",
"package_id": null,
"package_name": null,
"expire_date": "2021-11-05 15:47:05",
"max_connections": 1
}
# Add User Package
POST /api/user/<int:user_id>/package/add
# Post Data
{
"package_id": "Package id"
}
$ curl -X POST \
-H 'Content-Type: application/json' \
-H 'Authorization: Token fiMY9nMdrE82zSD1IbUuVr6J' \
--data '{"package_id": 1}' \
'http://192.168.2.3:8000/api/user/1/package/add'
{
"user_id": 1,
"username": "test",
"password": "test",
"package_id": 1,
"package_name": "Package 1",
"expire_date": "2021-12-05 23:59:47",
"max_connections": 1
}
# Renew User Package
POST /api/user/<int:user_id>/package/renew
# Example
$ curl -X POST \
-H 'Content-Type: application/json' \
-H 'Authorization: Token fiMY9nMdrE82zSD1IbUuVr6J' \
'http://192.168.2.3:8000/api/user/1/package/renew'
{
"user_id": 1,
"username": "test",
"password": "test",
"package_id": 1,
"package_name": "Package 1",
"expire_date": "2022-01-04 23:59:47",
"max_connections": 1
}
# Change User Package
POST /api/user/<int:user_id>/package/change
# Post Data
{
"package_id": "Package id"
}
# Example
$ curl -X POST \
-H 'Content-Type: application/json' \
-H 'Authorization: Token fiMY9nMdrE82zSD1IbUuVr6J' \
--data '{"package_id": "2"}' \
'http://192.168.2.3:8000/api/user/1/package/change'
{
"user_id": 1,
"username": "test",
"password": "test",
"package_id": 2,
"package_name": "Package 2",
"expire_date": "2021-11-24 00:02:54",
"max_connections": 5
}
# Cancel User Package
POST /api/user/<int:user_id>/package/cancel
# Example
$ curl -X POST \
-H 'Content-Type: application/json' \
-H 'Authorization: Token fiMY9nMdrE82zSD1IbUuVr6J' \
'http://192.168.2.3:8000/api/user/1/package/cancel'
{
"user_id": 1,
"username": "test",
"password": "test",
"package_id": null,
"package_name": null,
"expire_date": "2021-11-05 16:05:21",
"max_connections": 0
}
# Query User Info
GET /api/user/<int:user_id|str:username>/info
# Example
$ curl -X GET \
-H 'Content-Type: application/json' \
-H 'Authorization: Token fiMY9nMdrE82zSD1IbUuVr6J' \
'http://192.168.2.3:8000/api/user/test/info'
{
"user_id": 1,
"username": "test",
"password": "test",
"package_id": null,
"package_name": null,
"expire_date": "2021-11-05 16:05:21",
"max_connections": 0
}
# DVB API
# Fetch All Control Word
If you are using panel's builtin DVB adapter and SoftCAM feature, it's possible to get the decryption CW in real-time, but only the channels you added and running in the panel will able to get CW. Since the CW is changed periodically, so you need use HTTP request to polling the CW for every a few seconds.
GET /api/adapter/service/cw/all
# Example
$ curl -X GET \
-H 'Authorization: Token fiMY9nMdrE82zSD1IbUuVr6J' \
'http://192.168.2.3:8000/api/adapter/service/cw/all'
[
{
"tp": "12680 V",
"sid": 419,
"name": "EPTV Ribeir Preto",
"timestamp": 1666482459049,
"cw": "f99275005f2fd76571a13c4e6b1fbe48"
},
{
"tp": "12680 V",
"sid": 431,
"name": "EPTV S Carlos",
"timestamp": 1666482454449,
"cw": "3b1f328cd2dea757603ddd7a26ccfef0"
},
{
"tp": "12680 V",
"sid": 432,
"name": "TV Vanguarda S. J. dos Campos",
"timestamp": 1666482457502,
"cw": "146ba4235e90fdeba7702a41be71a3d2"
}
]
# Fetch Control Word Via Service ID
GET /api/adapter/service/<int:service_id>/cw
# Example
$ curl -X GET \
-H 'Authorization: Token fiMY9nMdrE82zSD1IbUuVr6J' \
'http://192.168.2.3:8000/api/adapter/service/432/cw'
{
"tp": "12680 V",
"sid": 432,
"name": "TV Vanguarda S. J. dos Campos",
"timestamp": 1666482457502,
"cw": "146ba4235e90fdeba7702a41be71a3d2"
}