API for LIVE resource
Description
This section describes API methods for creating, deleting and configurations changing of your resources. You will also find here the information on cache managing and statistical data receiving.
All the responses (including errors) return in JSON Format.
Attention!
- You can make not more than 5 API requests (POST, PUT) 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.
Configuration for LIVE Resource
RTMP/RTSP-publish
Get all resources
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/
- Method: GET
- Headers: CDN-AUTH-TOKEN
- Response Data Type: JSON Array or JSON Object in case of error
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | All live resources configured in specified account or error description | JSON | Response with list of resources or error |
403 | None | None | Forbidden |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" https://api.cdnvideo.ru/cdn/api/v1/testaccount/resource/live/
Successful response example
[ { "name": "test_resource", "settings": { "RTMP-publish": { "domain": "p0q2zwj4yih.a.trbcdn.net", "pub_protocol": "rtmp", "master_stream": "jws2w_test_resource.smil", "primary": "a.r.cdnvideo.net", "application": "livemaster", "dist_protocol": "https", "backup": "b.r.cdnvideo.net" } }, "streams": { "someid1": { "stream_name": "someid1_stream01", "password": "RtdHESB7aA7rdKDCuVYn5W9Zp", "resolution": "720p", "name": "stream01", "smil": { "BANDWIDTH": "5000000", "RESOLUTION": "1280x720" } }, "someid2": { "stream_name": "someid2_stream02", "password": "dRKLVu6v90P5PhSAMIGSIgKuh", "resolution": "1080p", "name": "stream02", "smil": { "BANDWIDTH": "10000000", "RESOLUTION": "1920x1080" } } }, "active": true, "creation_ts": 1542872090, "type": "RTMP-publish", "id": "1163546047721937079_p0q2zwj4yih", "resources": { "http": "test" }, "cdn_domain": "test.a.trbcdn.net", "description": "" } ]
Unsuccessful response example
{"status": "error", "message": "Not allowed method", "description": "Request is forbidden"}
Attention
To get deactivated resources, use the query parameter "active" with the value "false"
Get specific resource
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/<resource_id>
- Method: GET
- Headers: CDN-AUTH-TOKEN
- Response Data Type: JSON Object
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | Live resource configured in specified account or error description | JSON | Response with resource or error |
403 | None | None | Forbidden |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" https://api.cdnvideo.ru/cdn/api/v1/testaccount/resource/live/1163546047721937079_p0q2zwj4yih
Successful response example
{ "name": "test_resource", "settings": { "RTMP-publish": { "domain": "p0q2zwj4yih.a.trbcdn.net", "pub_protocol": "rtmp", "master_stream": "jws2w_test_resource.smil", "primary": "a.r.cdnvideo.net", "application": "livemaster", "dist_protocol": "https", "backup": "b.r.cdnvideo.net" } }, "streams": { "someid1": { "stream_name": "someid1_stream01", "password": "RtdHESB7aA7rdKDCuVYn5W9Zp", "resolution": "720p", "name": "stream01", "smil": { "BANDWIDTH": "5000000", "RESOLUTION": "1280x720" } }, "someid2": { "stream_name": "someid2_stream02", "password": "dRKLVu6v90P5PhSAMIGSIgKuh", "resolution": "1080p", "name": "stream02", "smil": { "BANDWIDTH": "10000000", "RESOLUTION": "1920x1080" } } }, "active": true, "creation_ts": 1542872090, "type": "RTMP-publish", "id": "1163546047721937079_p0q2zwj4yih", "resources": { "http": "test" }, "cdn_domain": "test.a.trbcdn.net", "description": "" }
Unsuccessful response example
{"status": "error", "message": "Not allowed method", "description": "Request is forbidden"}
Attention
To get deactivated resource, use the query parameter "active" with the value "false"
Create resource
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/
- Method: POST
- Headers: CDN-AUTH-TOKEN
- Request Data: JSON with resource data
- Response Data Type: JSON Object
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | task_id, resource_id or error description | JSON | Created, id of task in global task queue or error |
400 | None | None | Bad Request |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" \ -X POST \ -d '{"name": "test_resource", "type": "RTMP-publish", "streams": {"someid1": {"name": "stream01", "resolution": "720p"}, "someid2": {"name": "stream02", "resolution": "1080p"}}}' \ https://api.cdnvideo.ru/cdn/api/v1/testaccount/resource/live/
Successful response example
{ "status": "accept", "task_id": "20181122103450831469", "resource_id": "1163546047721937079_p0q2zwj4yih" }
Unsuccessful response example
{"status": "error", "message": "Json invalid", "description": "required key name isn't provided"}
Update resource
Attention
This request completely replaces the resource configuration with the data passed in the body of the PUT request.
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/<resource_id>
- Method: PUT
- Headers: CDN-AUTH-TOKEN
- Request Data: JSON with new resource data
- Response Data Type: JSON Object
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | task_id or error description | JSON | Updated, id of task in global task queue or error |
400 | None | None | Bad Request |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" \ -X PUT \ -d '{"name": "test_resource", "type": "RTMP-publish", "streams": {"someid1": {"name": "stream01", "resolution": "360p"}}}' \ https://api.cdnvideo.ru/cdn/api/v1/testaccount/resource/live/1163546047721937079_p0q2zwj4yih
Successful response example
{ "status": "accept", "task_id": "20181122103856008585" }
Unsuccessful response example
{"status": "error", "message": "Json invalid", "description": "stream key length should be between 5 and 10. Not 17"}
Deactivate resource
Attention
This request completely replaces the resource configuration with the data passed in the body of the PUT request.
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/<resource_id>
- Method: PUT
- Headers: CDN-AUTH-TOKEN
- Response Data Type: JSON Object
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | task_id or error description | JSON | Deactivated, id of task in global task queue or error |
400 | None | None | Bad Request |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" \ -X PUT \ -d '{"active": false, "name": "test_resource", "type": "RTMP-publish", "streams": {"someid1": {"name": "stream01", "resolution": "360p"}}}' \ https://api.cdnvideo.ru/cdn/api/v1/testaccount/resource/live/1163546047721937079_p0q2zwj4yih
Successful response example
{ "status": "accept", "task_id": "20181122103856008586" }
Unsuccessful response example
{"status": "error", "message": "Not allowed method", "description": "Request is forbidden"}
Activate resource
Attention
This request completely replaces the resource configuration with the data passed in the body of the PUT request.
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/<resource_id>
- Method: PUT
- Headers: CDN-AUTH-TOKEN
- Response Data Type: JSON Object
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | task_id or error description | JSON | Activated, id of task in global task queue or error |
400 | None | None | Bad Request |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" \ -X PUT \ -d '{"active": true, "name": "test_resource", "type": "RTMP-publish", "streams": {"someid1": {"name": "stream01", "resolution": "360p"}}}' \ https://api.cdnvideo.ru/cdn/api/v1/testaccount/resource/live/1163546047721937079_p0q2zwj4yih
Successful response example
{ "status": "accept", "task_id": "20181122103856008586" }
Unsuccessful response example
{"status": "error", "message": "Not allowed method", "description": "Request is forbidden"}
Local authorization $
Create resource with local authorization
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/
- Method: POST
- Headers: CDN-AUTH-TOKEN
- Request Data: JSON with resource data and local authorization parameters
- Response Data Type: JSON Object
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | task_id, resource_id or error description | JSON | Created, id of task in global task queue or error |
400 | None | None | Bad Request |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" \ -X POST \ -d '{"auth": {"md5": {"secret": "123", "forever": true, "anywhere": true}}, "name": "test_resource", "type": "RTMP-publish", "streams": {"someid1": {"name": "stream01", "resolution": "720p"}, "someid2": {"name": "stream02", "resolution": "1080p"}}}' \ https://api.cdnvideo.ru/cdn/api/v1/testaccount/resource/live/
Successful response example
{ "status": "accept", "task_id": "20181122103450831469", "resource_id": "1163546047721937079_p0q2zwj4yih" }
Unsuccessful response example
{"status": "error", "message": "Json invalid", "description": "required key name isn't provided"}
Update resource local authorization
Attention
This request completely replaces the resource configuration with the data passed in the body of the PUT request.
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/<resource_id>
- Method: PUT
- Headers: CDN-AUTH-TOKEN
- Request Data: JSON with new parameters of local authorization
- Response Data Type: JSON Object
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | task_id or error description | JSON | Updated, id of task in global task queue or error |
400 | None | None | Bad Request |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" \ -X PUT \ -d '{"auth": {"md5": {"secret": "456", "forever": true}}, "name": "test_resource", "type": "RTMP-publish", "streams": {"someid1": {"name": "stream01", "resolution": "360p"}}}' \ https://api.cdnvideo.ru/cdn/api/v1/testaccount/resource/live/1163546047721937079_p0q2zwj4yih
Successful response example
{ "status": "accept", "task_id": "20181122103856008585" }
Unsuccessful response example
{"status": "error", "message": "Json invalid", "description": "stream key length should be between 5 and 10. Not 17"}
External authorization $
Create resource with external authorization
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/
- Method: POST
- Headers: CDN-AUTH-TOKEN
- Request Data: JSON with resource data and external authorization parameters
- Response Data Type: JSON Object
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | task_id, resource_id or error description | JSON | Created, id of task in global task queue or error |
400 | None | None | Bad Request |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" \ -X POST \ -d '{"auth": {"url": "https://test.com/yourscript"}, "name": "test_resource", "type": "RTMP-publish", "streams": {"someid1": {"name": "stream01", "resolution": "720p"}, "someid2": {"name": "stream02", "resolution": "1080p"}}}' \ https://api.cdnvideo.ru/cdn/api/v1/testaccount/resource/live/
Successful response example
{ "status": "accept", "task_id": "20181122103450831469", "resource_id": "1163546047721937079_p0q2zwj4yih" }
Unsuccessful response example
{"status": "error", "message": "Json invalid", "description": "required key name isn't provided"}
Update resource external authorization
Attention
This request completely replaces the resource configuration with the data passed in the body of the PUT request.
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/<resource_id>
- Method: PUT
- Headers: CDN-AUTH-TOKEN
- Request Data: JSON with new parameters of external authorization
- Response Data Type: JSON Object
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | task_id or error description | JSON | Updated, id of task in global task queue or error |
400 | None | None | Bad Request |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" \ -X PUT \ -d '{"auth": {"url": "https://test.com/yourscript2"}, "name": "test_resource", "type": "RTMP-publish", "streams": {"someid1": {"name": "stream01", "resolution": "360p"}}}' \ https://api.cdnvideo.ru/cdn/api/v1/testaccount/resource/live/1163546047721937079_p0q2zwj4yih
Successful response example
{ "status": "accept", "task_id": "20181122103856008585" }
Unsuccessful response example
{"status": "error", "message": "Json invalid", "description": "stream key length should be between 5 and 10. Not 17"}
Limitations $
Create resource with geo, IP, referer or useragent
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/
- Method: POST
- Headers: CDN-AUTH-TOKEN
- Request Data: JSON with resource data and limitations parameters
- Response Data Type: JSON Object
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | task_id, resource_id or error description | JSON | Created, id of task in global task queue or error |
400 | None | None | Bad Request |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" \ -X POST \ -d '{"name": "test_resource", "type": "RTMP-publish", "streams": {"someid1": {"name": "stream01", "resolution": "720p"}}, "limitations": {"geo": [{"default_action": "allow", "exclude": [{"country": "RU", "region": "BEL", "action": "deny"}], "times": [{"start": "2019-07-20T14:17:00Z", "end": "2019-07-20T14:18:00Z"}]}, {"default_action": "allow", "exclude": [{"country": "RU", "region": "CR", "action": "deny"}, {"country": "RU", "region": null, "action": "deny"}], "times": [{"start": "2019-07-20T14:19:00Z", "end": null}]}], "ip": [{"default_action": "deny", "exclude": [{"ip":"192.168.0.1/24"}], "times": [{"start": "2019-07-20T14:17:00Z", "end": "2019-07-20T14:18:00Z"}]}], "referer": [{"default_action": "deny", "exclude": [{"referer":"*.ru"}], "times": [{"start": null, "end": "2019-07-20T14:18:00Z"}]}], "useragent": [{"default_action": "deny", "exclude": [{"useragent": "browser_name"}], "times": [{"start": "2019-07-20T14:17:00Z", "end": "2019-07-20T14:18:00Z"}]}]}}' \ https://api.cdnvideo.ru/cdn/api/v1/<account_name>/resource/live/
Successful response example
{ "status": "accept", "task_id": "20180402162358692400", "resource_id": "1163546047721937079_p0q2zwj4yih" }
Unsuccessful response example
{ "status": "error", "message": "json invalid", "description": "limitations : Invalid time interval: start:2021-05-11T19:12:00Z, end:2021-05-09T22:12:00Z" }
Update resource limitations
Attention
This request completely replaces the resource configuration with the data passed in the body of the PUT request.
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/<resource_id>
- Method: PUT
- Headers: CDN-AUTH-TOKEN
- Request Data: JSON with new parameters of external authorization
- Response Data Type: JSON Object
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | task_id or error description | None | Updated, id of task in global task queue or error |
400 | None | None | Bad Request |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" \ -X PUT \ -d '{"name": "test_resource", "type": "RTMP-publish", "streams": {"someid1": {"name": "stream01", "resolution": "720p"}}, "limitations": { "ip": [{"default_action": "deny", "exclude": [{"ip":"192.168.0.1/24"}], "times": []}]}}' \ https://api.cdnvideo.ru/cdn/api/v1/<account_name>/resource/live/<resource_id>
Successful response example
{"status": "accept", "task_id": "20180402162358692401"}
Unsuccessful response example
{"status": "error", "message": "Not allowed method", "description": "Request is forbidden"}
Receiving Publication links
To receive the full publication links, you have to combine live resource parameters, received via GET-request.
Publication Link
<pub_protocol>://<primary|backup>/<application>/<stream_name>?auth=<password>
Example of final link for publishing:
rtmp://a.r.cdnvideo.net/livemaster/someid1_stream01?auth=MkE5MGtjbPljT52t491y6z14C
Link for Streaming
<dist_protocol>://<domain>/<application>/<master_stream>/playlist.m3u8
Example of final link for streaming:
https://p0q2zwj4yih.a.trbcdn.net/livemaster/jws2w_test_resource.smil/playlist.m3u8
Transcoding $
You can order the service of transcoding the input stream in several qualities. This will reduce the cost of hardware or software.
Important!
This service is paid according to the tariffs indicated in dashboard.
Transcoding profiles
We offer the following transcoding profiles:
Profile ID | Qualities | Video codec | Audio codec | Combining qualities into one stream |
---|---|---|---|---|
360_480_720 | 360p, 480p, 720p | h.264 | AAC/mp3 | + |
480_720_1080 | 480p, 720p, 1080p | h.264 | AAC/mp3 | + |
360_480_720_1080 | 360p, 480p, 720p, 1080p | h.264 | AAC/mp3 | + |
Order the service
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/
- Method: POST
- Headers: CDN-AUTH-TOKEN
- Request Data: JSON with resource data and selected transcoding profile
- Response Data Type: JSON Object
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | task_id, resource_id or error description | JSON | Created, id of task in global task queue or error |
400 | None | None | Bad Request |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" \ -X POST \ -d '{"name": "test_resource", "transcode_profile": "360_480_720", "type": "RTMP-publish", "streams": {"someid1": {"name": "stream01", "resolution": "720p"}}}' \ https://api.cdnvideo.ru/cdn/api/v1/testaccount/resource/live/
Successful response example
{ "status": "accept", "task_id": "20181122103450831469", "resource_id": "1163546047721937079_p0q2zwj4yih" }
Unsuccessful response example
{"status": "error", "message": "Json invalid", "description": "transcode_profile should be one of ['480_720_1080', '360_480_720', '360_480_720_1080']. Not 360_480"}
Attention
If you order a transcoding service, then you should specify ONLY ONE input stream.
Change the service
Attention
This request completely replaces the resource configuration with the data passed in the body of the PUT request.
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/
- Method: PUT
- Headers: CDN-AUTH-TOKEN
- Request Data: JSON with resource data and new transcoding profile
- Response Data Type: JSON Object
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | task_id or error description | JSON | Updated, id of task in global task queue or error |
400 | None | None | Bad Request |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" \ -X PUT \ -d '{"name": "test_resource", "transcode_profile": "360_480_720_1080", "type": "RTMP-publish", "streams": {"someid1": {"name": "stream01", "resolution": "720p"}}}' \ https://api.cdnvideo.ru/cdn/api/v1/testaccount/resource/live/1163546047721937079_p0q2zwj4yih
Successful response example
{ "status": "accept", "task_id": "20181122103450831471" }
Unsuccessful response example
{"status": "error", "message": "Json invalid", "description": "there must be only one stream to be transcoded. Not 0"}
Attention
If you order a transcoding service, then you should specify ONLY ONE input stream.
Deactivate the service
Attention
This request completely replaces the resource configuration with the data passed in the body of the PUT request.
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/
- Method: PUT
- Headers: CDN-AUTH-TOKEN
- Request Data: JSON with resource data and empty transcoding profile
- Response Data Type: JSON Object
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | task_id or error description | JSON | Updated, id of task in global task queue or error |
400 | None | None | Bad Request |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" \ -X PUT \ -d '{"name": "test_resource", "transcode_profile": "", "type": "RTMP-publish", "streams": {"someid1": {"name": "stream01", "resolution": "720p"}}}' \ https://api.cdnvideo.ru/cdn/api/v1/testaccount/resource/live/1163546047721937079_p0q2zwj4yih
Successful response example
{ "status": "accept", "task_id": "20181122103450831472" }
Unsuccessful response example
{"status": "error", "message": "Not allowed method", "description": "Request is forbidden"}
HLS-cache
Get all resources
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/
- Method: GET
- Headers: CDN-AUTH-TOKEN
- Response Data Type: JSON Array or JSON Object in case of error
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | All live resources configured in specified account or error description | JSON | Response with list of resources or error |
403 | None | None | Forbidden |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" https://api.cdnvideo.ru/cdn/api/v1/testaccount/resource/live/
Successful response example
[ { "origin": { "https": true, "servers": { "yourdomain.com": { "backup": false, "port": 80, "weight": 1 } } }, "cdn_domain": "wtx3l7rtrl6.a.trbcdn.net", "name": "live-qxthy19jjz", "streams": { "2it9dwypm4": { "id": "/stream/playlist.m3u8" } }, "names": ["test.cname.com"], "active": true, "creation_ts": 1551853456, "type": "HLS-cache", "id": "8053158264585032642_wtx3l7rtrl6", "resources": { "http": "wtx3l7rtrl6" }, "description": "" } ]
Unsuccessful response example
{"status": "error", "message": "Not allowed method", "description": "Request is forbidden"}
Attention
To get deactivated resources, use the query parameter "active" with the value "false"
Get specific resource
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/<resource_id>
- Method: GET
- Headers: CDN-AUTH-TOKEN
- Response Data Type: JSON Object
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | Live resource configured in specified account or error description | JSON | Response with resource or error |
403 | None | None | Forbidden |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" https://api.cdnvideo.ru/cdn/api/v1/testaccount/resource/live/8053158264585032642_wtx3l7rtrl6
Successful response example
{ "origin": { "https": true, "servers": { "yourdomain.com": { "backup": false, "port": 80, "weight": 1 } } }, "cdn_domain": "wtx3l7rtrl6.a.trbcdn.net", "name": "live-qxthy19jjz", "streams": { "2it9dwypm4": { "id": "/stream/playlist.m3u8" } }, "names": ["test.cname.com"], "active": true, "creation_ts": 1551853456, "type": "HLS-cache", "id": "8053158264585032642_wtx3l7rtrl6", "resources": { "http": "wtx3l7rtrl6" }, "description": "" }
Unsuccessful response example
{"status": "error", "message": "Not allowed method", "description": "Request is forbidden"}
Attention
To get deactivated resource, use the query parameter "active" with the value "false"
Create resource
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/
- Method: POST
- Headers: CDN-AUTH-TOKEN
- Request Data: JSON with resource data
- Response Data Type: JSON Object
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | task_id, resource_id or error description | JSON | Created, id of task in global task queue or error |
400 | None | None | Bad Request |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" \ -X POST \ -d '{"name": "live-qxthy20jjz", "type": "HLS-cache", "streams": {"3it9dwypm4": {"id": "/stream/playlist.m3u8"}}, "origin": {"https": false, "read_timeout": "10s", "connect_timeout": "10s", "send_timeout": "10s", "servers": {"yourdomain.com": {"port": 80, "weight": 1, "backup": false}}}, "names": ["test-cname.com"]}' \ https://api.cdnvideo.ru/cdn/api/v1/testaccount/resource/live/
Successful response example
{ "status": "accept", "task_id": "20190305103450831469", "resource_id": "9282601590143242685_pqy19d9z3pm" }
Unsuccessful response example
{"status": "error", "message": "Json invalid", "description": "required key name isn't provided"}
Update resource
Attention
This request completely replaces the resource configuration with the data passed in the body of the PUT request.
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/<resource_id>
- Method: PUT
- Headers: CDN-AUTH-TOKEN
- Request Data: JSON with new resource data
- Response Data Type: JSON Object
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | task_id or error description | JSON | Updated, id of task in global task queue or error |
400 | None | None | Bad Request |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" \ -X PUT \ -d '{"name": "live-qxthy20jjz-2", "type": "HLS-cache", "streams": {"4it9dwypm4": {"id": "/stream/playlist-2.m3u8"}}, "origin": {"https": false, "servers": {"yourdomain.com": {"port": 80, "weight": 1, "backup": false}}}}' \ https://api.cdnvideo.ru/cdn/api/v1/testaccount/resource/live/9282601590143242685_pqy19d9z3pm
Successful response example
{ "status": "accept", "task_id": "20190305103450831470" }
Unsuccessful response example
{"status": "error", "message": "Json invalid", "description": "stream key length should be between 5 and 10. Not 17"}
Deactivate resource
Attention
This request completely replaces the resource configuration with the data passed in the body of the PUT request.
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/<resource_id>
- Method: PUT
- Headers: CDN-AUTH-TOKEN
- Response Data Type: JSON Object
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | task_id or error description | JSON | Deactivated, id of task in global task queue or error |
400 | None | None | Bad Request |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" \ -X PUT \ -d '{"active": false, "name": "live-qxthy20jjz-2", "type": "HLS-cache", "streams": {"4it9dwypm4": {"id": "/stream/playlist-2.m3u8"}}, "origin": {"https": false, "servers": {"yourdomain.com": {"port": 80, "weight": 1, "backup": false}}}}' \ https://api.cdnvideo.ru/cdn/api/v1/testaccount/resource/live/9282601590143242685_pqy19d9z3pm
Successful response example
{ "status": "accept", "task_id": "20190305103450831479" }
Unsuccessful response example
{"status": "error", "message": "Not allowed method", "description": "Request is forbidden"}
Activate resource
Attention
This request completely replaces the resource configuration with the data passed in the body of the PUT request.
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/<resource_id>
- Method: PUT
- Headers: CDN-AUTH-TOKEN
- Response Data Type: JSON Object
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | task_id or error description | JSON | Activated, id of task in global task queue or error |
400 | None | None | Bad Request |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" \ -X PUT \ -d '{"active": true, "name": "live-qxthy20jjz-2", "type": "HLS-cache", "streams": {"4it9dwypm4": {"id": "/stream/playlist-2.m3u8"}}, "origin": {"https": false, "servers": {"yourdomain.com": {"port": 80, "weight": 1, "backup": false}}}}' \ https://api.cdnvideo.ru/cdn/api/v1/testaccount/resource/live/9282601590143242685_pqy19d9z3pm
Successful response example
{ "status": "accept", "task_id": "20190305103450831479" }
Unsuccessful response example
{"status": "error", "message": "Not allowed method", "description": "Request is forbidden"}
Local authorization $
Attention
It is not possible to enable local authorization for the entire HLS-cache resource. You can configure local authorization for a specific location.
Important!
If local authorization is enabled for locations that include playlists (m3u8, mpd), it is necessary to disable caching in these locations for them to work correctly.
Create resource with local authorization
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/
- Method: POST
- Headers: CDN-AUTH-TOKEN
- Request Data: JSON with resource data and local authorization parameters
- Response Data Type: JSON Object
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | task_id, resource_id or error description | JSON | Created, id of task in global task queue or error |
400 | None | None | Bad Request |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" \ -X POST \ -d '{"locations": {"~* \\.m3u8$": {"auth": {"md5": {"secret": "123", "forever": true, "anywhere": true}}}}, "name": "live-qxthy20jjz", "type": "HLS-cache", "streams": {"3it9dwypm4": {"id": "/stream/playlist.m3u8"}}, "origin": {"https": false, "servers": {"yourdomain.com": {"port": 80, "weight": 1, "backup": false}}}}' \ https://api.cdnvideo.ru/cdn/api/v1/testaccount/resource/live/
Successful response example
{ "status": "accept", "task_id": "20190305103450831469", "resource_id": "9282601590143242685_pqy19d9z3pm" }
Unsuccessful response example
{"status": "error", "message": "Json invalid", "description": "required key name isn't provided"}
Update resource local authorization
Attention
This request completely replaces the resource configuration with the data passed in the body of the PUT request.
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/<resource_id>
- Method: PUT
- Headers: CDN-AUTH-TOKEN
- Request Data: JSON with new parameters of local authorization
- Response Data Type: JSON Object
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | task_id or error description | JSON | Updated, id of task in global task queue or error |
400 | None | None | Bad Request |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" \ -X PUT \ -d '{"locations": {"~* \\.m3u8$": {"auth": {"md5": {"secret": "234", "forever": true, "anywhere": true}}, "cache": {"valid": {"2xx": "1s", "3xx": "1s"}}}, "/": {"cache": {"valid": {"2xx": "300s", "3xx": "1s", "4xx": "1s", "5xx": "1s"}}}}, "name": "live-qxthy20jjz", "type": "HLS-cache", "streams": {"3it9dwypm4": {"id": "/stream/playlist.m3u8"}}, "origin": {"https": false, "servers": {"yourdomain.com": {"port": 80, "weight": 1, "backup": false}}}}' \ https://api.cdnvideo.ru/cdn/api/v1/testaccount/resource/live/9282601590143242685_pqy19d9z3pm
Successful response example
{ "status": "accept", "task_id": "20190305103450831470" }
Unsuccessful response example
{"status": "error", "message": "Json invalid", "description": "stream key length should be between 5 and 10. Not 17"}
External authorization $
Important!
It is not possible to enable external authorization for the entire HLS-cache resource. You can configure external authorization for a specific location.
Create resource with external authorization
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/
- Method: POST
- Headers: CDN-AUTH-TOKEN
- Request Data: JSON with resource data and external authorization parameters
- Response Data Type: JSON Object
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | task_id, resource_id or error description | JSON | Created, id of task in global task queue or error |
400 | None | None | Bad Request |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" \ -X POST \ -d '{"locations": {"~* \\.m3u8$": {"auth": {"url": "https://test.com/yourscript"}}}, "name": "live-qxthy20jjz", "type": "HLS-cache", "streams": {"3it9dwypm4": {"id": "/stream/playlist.m3u8"}}, "origin": {"https": false, "servers": {"yourdomain.com": {"port": 80, "weight": 1, "backup": false}}}}' \ https://api.cdnvideo.ru/cdn/api/v1/testaccount/resource/live/
Successful response example
{ "status": "accept", "task_id": "20190305103450831469", "resource_id": "9282601590143242685_pqy19d9z3pm" }
Unsuccessful response example
{"status": "error", "message": "Json invalid", "description": "required key name isn't provided"}
Update resource external authorization
Attention
This request completely replaces the resource configuration with the data passed in the body of the PUT request.
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/<resource_id>
- Method: PUT
- Headers: CDN-AUTH-TOKEN
- Request Data: JSON with new parameters of external authorization
- Response Data Type: JSON Object
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | task_id or error description | JSON | Updated, id of task in global task queue or error |
400 | None | None | Bad Request |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" \ -X PUT \ -d '{"locations": {"~* \\.m3u8$": {"auth": {"url": "https://test.com/yourscript_new"}, "cache": {"valid": {"2xx": "1s", "3xx": "1s"}}}, "/": {"cache": {"valid": {"2xx": "300s", "3xx": "1s", "4xx": "1s", "5xx": "1s"}}}}, "name": "live-qxthy20jjz", "type": "HLS-cache", "streams": {"3it9dwypm4": {"id": "/stream/playlist.m3u8"}}, "origin": {"https": false, "servers": {"yourdomain.com": {"port": 80, "weight": 1, "backup": false}}}}' \ https://api.cdnvideo.ru/cdn/api/v1/testaccount/resource/live/9282601590143242685_pqy19d9z3pm
Successful response example
{ "status": "accept", "task_id": "20190305103450831470" }
Unsuccessful response example
{"status": "error", "message": "Json invalid", "description": "stream key length should be between 5 and 10. Not 17"}
Limitations $
Create resource with geo, IP, referer or useragent limitations
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/
- Method: POST
- Headers: CDN-AUTH-TOKEN
- Request Data: JSON with resource data and limitations parameters
- Response Data Type: JSON Object
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | task_id, resource_id or error description | JSON | Created, id of task in global task queue or error |
400 | None | None | Bad Request |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" \ -X POST \ -d '{"name": "test_resource", "type": "HLS-cache", "streams": {"someid1": {"id": "/stream/playlist.m3u8"}}, "origin": {"https": false, "servers": {"yourdomain.com": {"port": 80, "weight": 1, "backup": false}}}, "names": ["test-cname.com"], "limitations": {"geo": [{"default_action": "allow", "exclude": [{"country": "RU", "region": "BEL", "action": "deny"}], "times": [{"start": "2019-07-20T14:17:00Z", "end": "2019-07-20T14:18:00Z"}]}, {"default_action": "allow", "exclude": [{"country": "RU", "region": "CR", "action": "deny"}, {"country": "RU", "region": null, "action": "deny"}], "times": [{"start": "2019-07-20T14:19:00Z", "end": null}]}], "ip": [{"default_action": "deny", "exclude": [{"ip":"192.168.0.1/24"}], "times": [{"start": "2019-07-20T14:17:00Z", "end": "2019-07-20T14:18:00Z"}]}], "referer": [{"default_action": "deny", "exclude": [{"referer":"*.ru"}], "times": [{"start": null, "end": "2019-07-20T14:18:00Z"}]}], "useragent": [{"default_action": "deny", "exclude": [{"useragent": "browser_name"}], "times": [{"start": "2019-07-20T14:17:00Z", "end": "2019-07-20T14:18:00Z"}]}]}}' \ https://api.cdnvideo.ru/cdn/api/v1/<account_name>/resource/live/
Successful response example
{ "status": "accept", "task_id": "20180402162358692413", "resource_id": "1163546047721937079_p0q2zwj4yih" }
Unsuccessful response example
{ "status": "error", "message": "json invalid", "description": "limitations : Invalid time interval: start:2021-05-11T19:12:00Z, end:2021-05-09T22:12:00Z" }
Update resource limitations
Attention
This request completely replaces the resource configuration with the data passed in the body of the PUT request.
URL: https://api.cdnvideo.ru/cdn/api/v1/<your_account_name>/resource/live/<resource_id>
- Method: PUT
- Headers: CDN-AUTH-TOKEN
- Request Data: JSON with new parameters of external authorization
- Response Data Type: JSON Object
Status Code | Response Data | Response Format | Description |
---|---|---|---|
200 | task_id or error description | None | Updated, id of task in global task queue or error |
400 | None | None | Bad Request |
404 | None | None | Not Found |
500 | None | None | Internal Server Error |
503 | None | None | Service Unavailable |
Request example
curl -H "CDN-AUTH-TOKEN: $TOKEN" \ -X PUT \ -d '{"name": "test_resource", "type": "HLS-cache", "streams": {"someid1": {"id": "/stream/playlist-2.m3u8"}}, "origin": {"https": false, "servers": {"yourdomain.com": {"port": 80, "weight": 1, "backup": false}}}, "limitations": {"geo": [{"default_action": "allow", "exclude": [{"country": "RU", "region": "BEL", "action": "deny"}], "times": [{"start": "2019-07-20T14:17:00Z", "end": "2019-07-20T14:18:00Z"}]}, {"default_action": "allow", "exclude": [{"country": "RU", "region": "CR", "action": "deny"}, {"country": "RU", "region": null, "action": "deny"}], "times": [{"start": "2019-07-20T14:19:00Z", "end": null}]}], "ip": [{"default_action": "deny", "exclude": [{"ip":"192.168.0.1/24"}], "times": [{"start": "2019-07-20T14:17:00Z", "end": "2019-07-20T14:18:00Z"}]}], "referer": [{"default_action": "deny", "exclude": [{"referer":"*.ru"}], "times": [{"start": null, "end": "2019-07-20T14:18:00Z"}]}], "useragent": [{"default_action": "deny", "exclude": [{"useragent": "browser_name"}], "times": [{"start": "2019-07-20T14:17:00Z", "end": "2019-07-20T14:18:00Z"}]}]}}' \ https://api.cdnvideo.ru/cdn/api/v1/<account_name>/resource/live/<resource_id>
Successful response example
{ "status": "accept", "task_id": "20180402162358692413" }
Unsuccessful response example
{"status": "error", "message": "Not allowed method", "description": "Request is forbidden"}
Receiving Publication links
To receive the full streaming links, you have to combine live resource parameters, received via GET-request.
<pub_protocol>://<cdn_domain>/<stream_id>
<pub_protocol>://<names>/<stream_id>
Example of final CDN-links:
https://wtx3l7rtrl6.a.trbcdn.net/stream/playlist.m3u8
https://test.cname.com/stream/playlist.m3u8