API for LIVE resource
Description
This section describes API methods for creating, deleting and configurations changing of your resources.
All the responses (including errors) return in JSON Format.
Attention!
- You can make not more than 20 API requests (POST, PUT, PATCH) every minute.
When the limit is reached, a response with the status code 200 will be received:
{"status": "error", "message": "Rate limit exceeded", "description": "Request is forbidden"}
- There is a limit of 100 resources. If you need more resources, please contact your personal manager or support.
Find below examples for monitoring and configuring of the options in connection with Live streaming service.
Get stream information
General information
Warning!
- There is a limit on the number of API calls:
- no more than 10 requests per minute.
Required headers: CDN-AUTH-TOKEN (authorization token, refer. Authorization)
In case of correct response API returns 2xx response code and response text in the following format:
{ "status": "Completed", "data": <API response>, "<request parameter 1>": "value1", "<request parameter 2>": "value2" }
In case of an error response, the API returns the corresponding response code and the response text in the following format:
{ "status": "Forbidden", "description": "Token is expired" }
The description
field returns a text description of the error.
Get stream status
URL: https://api.cdnvideo.ru/app/streams/v1/<your_account_name>/status/<stream_name>
- Request type: GET
- Headers: CDN-AUTH-TOKEN
- Request parameters: no request parameters
- Response data type: JSON Object
- Response parameters:
Parameter | Type | Description |
---|---|---|
is_alive | boolean | is the stream alive |
start_ts | integer or null | Time of appearance of the stream. If the stream is on several servers, then the minimum of hosts.start_ts .Possible values: UTC timestamp - if the stream is activenull - if the stream is inactive |
hosts | array | List of servers that have a stream |
hosts.host | string | Server |
hosts.start_ts | integer | Time of appearance of the stream |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" 'https://api.cdnvideo.ru/app/streams/v1/testaccount/status/test/stream1'
Example response for an inactive stream
{ "status": "Completed", "stream_name": "test/stream1", "data": { "is_alive": false, "start_ts": null, "hosts": [] } }
Example response for an active stream
{ "status": "Completed", "stream_name": "test/stream1", "data": { "is_alive": true, "start_ts": 1693392088, "hosts": [ { "host": "ffce3977afe64227676096887231adba", "start_ts": 1693392088 }, { "host": "7bd5e6ccea2e689d252eb4c183a1aaf6", "start_ts": 1693392089 } ] } }
RTMP/RTSP-publish and SRT-publish
API description
Get links for publishing and distribution
To receive the full publication links, you have to combine live resource parameters, received via GET-request.
Link to publish the stream
RTMP/RTSP-publish:
<pub_protocol>://<primary|backup>/<application>/<stream_name>?auth=<password>
SRT-publish:
<pub_protocol>://<primary|backup>:19998/?streamid=#!::r=<application>/<stream_name>,auth=<password>
Examples of links for publication:
rtmp://a.r.cdnvideo.net/livemaster/someid1_stream01?auth=MkE5MGtjbPljT52t491y6z14C srt://a.r.cdnvideo.net:19998/?streamid=#!::r=livemastersrt/someid1_stream01,auth=IEVM5Vyew2nEjPcYZmaskikMN
Link for stream distribution
<dist_protocol>://<domain>/<application>/<master_stream>/playlist.m3u8
Example of link for stream distribution:
https://p0q2zwj4yih.a.trbcdn.net/livemaster/jws2w_test_resource.smil/playlist.m3u8
HLS-pull
API description
Get links for distribution
To receive the full streaming links, you have to combine live resource parameters, received via GET-request, and path to stream playlist.
<dist_protocol>://<cdn_domain|names>/<playlist_path>
Example of CDN-links:
https://wtx3l7rtrl6.a.trbcdn.net/stream/playlist.m3u8 https://test.cname.com/stream/playlist.m3u8