Skip to content

API for Restream 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.

Find below examples for monitoring and configuring of the options in connection with Restreaming service.

Configuration for Restream Resource

Get all resources

URL: https://api.cdnvideo.ru/app/restream/v2/<your_account_name>/resources

  • Method: GET
  • Headers: CDN-AUTH-TOKEN
  • Response Data Type: JSON Object
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:cdn2_OSKVHEJCGDOPEQJJXQN284ZTQUEPJ2' https://api.cdnvideo.ru/app/restream/v2/aloha/resources

Successful response example

{
    "account": "aloha",
    "modification_ts": 1572586121,
    "data": {
        "resources": [
            {
            "resource_id": "ewq-123-ewq",
            "name": "asdfasfewefse",
            "type": "short",
            "active": true,
            "creation_ts": 1572586121,
            "modification_ts": 1572586121,
            "restreams": [
                {
                    "schedule": [
                        {
                            "start": "2019-10-30T13:30:59Z",
                            "stop": "2019-10-30T13:31:00Z"
                        },
                        {
                            "start": "2019-10-30T13:40:59Z",
                            "stop": "2019-10-30T13:41:00Z"
                        }
                    ],
                    "source": "rtmp://a.r.cdnvideo.net/livemaster/aaaaa_teststream1",
                    "transcoded": false,
                    "transcode_quality": "",
                    "target_type": "customRTMP",
                    "target_url": "rtmp://a.rtmp.com/live2",
                    "target_key": "key1",
                    "login": "",
                    "password": "",
                    "backup": {
                        "target_url": "rtmp://b.com/live2?q=1",
                        "login": "",
                        "password": ""
                    }
                },
                {
                    "schedule": [],
                    "source": "rtmp://a.r.cdnvideo.net/livemaster/aaaaa_teststream1_tcode360p",
                    "transcoded": true,
                    "transcode_quality": "360p",
                    "target_type": "customRTMP",
                    "target_url": "rtmp://a.rtmp.com/live2",
                    "target_key": "key1_360",
                    "login": "",
                    "password": "",
                    "backup": {}
                }
            ]
            }
        ]
    }
}

Unsuccessful response example

{"success": False, "code": 400, "message": "Client not found"}

Get specific resource

URL: https://api.cdnvideo.ru/app/restream/v2/<your_account_name>/resources/<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:cdn2_OSKVHEJCGDOPEQJJXQN284ZTQUEPJ2' https://api.cdnvideo.ru/app/restream/v2/aloha/resources/ewq-123-ewq

Successful response example

{
  "account": "aloha",
  "resource_id": "ewq-123-ewq",
  "modification_ts": 1583852573,
  "data": {
    "active": true,
    "name": "asdfasfewefse",
    "type": "short",
    "restreams": [
      {
        "schedule": [
          {
            "start": "2019-10-30T13:30:59Z",
            "stop": "2019-10-30T13:31:00Z"
          },
          {
            "start": "2019-10-30T13:40:59Z",
            "stop": "2019-10-30T13:41:00Z"
          }
        ],
        "source": "rtmp://a.r.cdnvideo.net/livemaster/aaaaa_teststream1",
        "transcoded": false,
        "transcode_quality": "",
        "target_type": "customRTMP",
        "target_url": "rtmp://a.rtmp.com/live2",
        "target_key": "key1",
        "login": "",
        "password": "",
        "backup": {
          "target_url": "rtmp://b.com/live2?q=1",
          "login": "",
          "password": ""
        }
      },
      {
        "schedule": [],
        "source": "rtmp://a.r.cdnvideo.net/livemaster/aaaaa_teststream1_tcode360p",
        "transcoded": true,
        "transcode_quality": "360p",
        "target_type": "customRTMP",
        "target_url": "rtmp://a.rtmp.com/live2",
        "target_key": "key1_360",
        "login": "",
        "password": "",
        "backup": {}
      }
    ],
    "resource_id": "ewq-123-ewq",
    "creation_ts": 1583852573,
    "modification_ts": 1583852573
  }
}

Unsuccessful response example

{"success": False, "code": 400, "message": "Client not found"}

Create resource

URL: https://api.cdnvideo.ru/app/restream/v2/<your_account_name>/resources

  • 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 resource_id или описание ошибки JSON Created resource
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:cdn2_2YXPIWIYRT15SZGQ2Q0JN362PUDXIE'
  -X POST
  -d '{
        "active": true,
        "name": "asdfasfewefse",
        "type": "short",
        "restreams": [
            {
                "schedule": [
                    {
                        "start": "2019-10-30T13:30:59Z",
                        "stop": "2019-10-30T13:31:00Z"
                    },
                    {
                        "start": "2019-10-30T13:40:59Z",
                        "stop": "2019-10-30T13:41:00Z"
                    }
                ],
                "source": "rtmp://a.r.cdnvideo.net/livemaster/aaaaa_teststream1",
                "transcoded": false,
                "transcode_quality": "",
                "target_type": "customRTMP",
                "target_url": "rtmp://a.rtmp.com/live2",
                "target_key": "key1",
                "login": "",
                "password": "",
                "backup": {
                    "target_url": "rtmp://b.com/live2?q=1",
                    "login": "",
                    "password": ""
                }
            },
            {
                "schedule": [],
                "source": "rtmp://a.r.cdnvideo.net/livemaster/aaaaa_teststream1_tcode360p",
                "transcoded": true,
                "transcode_quality": "360p",
                "target_type": "customRTMP",
                "target_url": "rtmp://a.rtmp.com/live2",
                "target_key": "key1_360",
                "login": "",
                "password": "",
                "backup": {}
            }
        ]
    }'
  https://api.cdnvideo.ru/app/restream/v2/aloha/resources

Successful response example

{
"success":true,
"code":200,
"message":"OK",
"resource_id": "123-qwe-123"
}

Unsuccessful response example

{"success": False, "code": 400, "message": "Client not found"}

Update resource

URL: https://api.cdnvideo.ru/app/restream/v2/<your_account_name>/resources/<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 OK or error description JSON Updated resource
400 None None Bad Request
404 None None Not Found
500 None None Internal Server Error
503 None None Service Unavailable

Request exampl

curl -H 'cdn-auth-token:cdn2_2YXPIWIYRT15SZGQ2Q0JN362PUDXIE'
  -X PUT
  -d '{
        "active": true,
        "name": "asdfasfewefse",
        "type": "short",
        "restreams": [
            {
            "schedule": [
                {
                    "start": "2019-10-30T13:30:59Z",
                    "stop": "2019-10-30T13:31:00Z"
                },
                {
                    "start": "2019-10-30T13:40:59Z",
                    "stop": "2019-10-30T13:41:00Z"
                }
            ],
            "source": "rtmp://a.r.cdnvideo.net/livemaster/aaaaa_teststream1",
            "transcoded": false,
            "transcode_quality": "",
            "target_type": "customRTMP",
            "target_url": "rtmp://a.rtmp.com/live2",
            "target_key": "key1",
            "login": "",
            "password": "",
            "backup": {
                "target_url": "rtmp://b.com/live2?q=1",
                "login": "",
                "password": ""
            }
        },
        {
            "schedule": [],
            "source": "rtmp://a.r.cdnvideo.net/livemaster/aaaaa_teststream1_tcode360p",
            "transcoded": true,
            "transcode_quality": "360p",
            "target_type": "customRTMP",
            "target_url": "rtmp://a.rtmp.com/live2",
            "target_key": "key1_360",
            "login": "",
            "password": "",
            "backup": {}
        }]}'
  https://api.cdnvideo.ru/app/restream/v2/aloha/resources/123-qwe-123

Successful response example

{
"success":true,
"code":200,
"message":"OK"
}

Unsuccessful response example

{"success": False, "code": 400, "message": "Client not found"}

Get resource status

URL: https://api.cdnvideo.ru/app/restream/v2/<your_account_name>/status

  • Method: GET
  • Headers: CDN-AUTH-TOKEN
  • Response Data Type: JSON Object
Status Code Response Data Response Format Description
200 All resources status configured in specified account or error description JSON Response with statuses 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:cdn2_2YXPIWIYRT15SZGQ2Q0JN362PUDXIE'
  -X GET
  https://api.cdnvideo.ru/app/restream/v2/aloha/status

Successful response example

{
  "account": "aloha",
  "data": [
    {
      "resource_id": "ewq-123-ewq",
      "status": [
        {
          "status": {
            "code": 3,
            "description": "Source stream is not published"
          },
          "source": "url",
          "target_url": "url",
          "target_key": "key1"
        },
        {
          "status": {
            "code": 3,
            "description": "Source stream is not published"
          },
          "source": "url",
          "target_url": "url2",
          "target_key": "key1"
        },
        {
          "status": {
            "code": 3,
            "description": "Source stream is not published"
          },
          "source": "url",
          "target_url": "url3",
          "target_key": "key1"
        }
      ]
    }
  ]
}

Unsuccessful response example

{"success": False, "code": 400, "message": "Client not found"}

Get specific resource status

URL: https://api.cdnvideo.ru/app/restream/v2/<your_account_name>/status?resource_id=<resource_id>

  • Method: GET
  • Headers: CDN-AUTH-TOKEN
  • Response Data Type: JSON Object
Status Code Response Data Response Format Description
200 Resource status configured in specified account or error description JSON Response with status 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:cdn2_2YXPIWIYRT15SZGQ2Q0JN362PUDXIE'
  -X GET
  https://api.cdnvideo.ru/app/restream/v2/aloha/status?resource_id=ewq-123-ewq

Successful response example

{
  "account": "aloha",
  "data": [
    {
      "resource_id": "ewq-123-ewq",
      "status": [
        {
          "status": {
            "code": 3,
            "description": "Source stream is not published"
          },
          "source": "url",
          "target_url": "url",
          "target_key": "key1"
        },
        {
          "status": {
            "code": 3,
            "description": "Source stream is not published"
          },
          "source": "url",
          "target_url": "url2",
          "target_key": "key1"
        },
        {
          "status": {
            "code": 3,
            "description": "Source stream is not published"
          },
          "source": "url",
          "target_url": "url3",
          "target_key": "key1"
        }
      ]
    }
  ]
}

Unsuccessful response example

{"success": False, "code": 400, "message": "Client not found"}

Get specific resource status history

URL: https://api.cdnvideo.ru/app/restream/v2/<your_account_name>/history?resource_id=<resource_id>&start<YYYY-mm-ddTHH:MM:SSZ>&end<YYYY-mm-ddTHH:MM:SSZ>

  • Method: GET
  • Headers: CDN-AUTH-TOKEN
  • Response Data Type: JSON Object
Status Code Response Data Response Format Description
200 Resource status history configured in specified account or error description JSON Response with status history 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:cdn2_2YXPIWIYRT15SZGQ2Q0JN362PUDXIE'
  -X GET
  https://api.cdnvideo.ru/app/restream/v2/aloha/history?resource_id=ewq-123-ewq&start=2020-03-01T12:00:00Z&end=2020-03-01T14:00:00Z

Successful response example

{
    "account": "aloha",
    "resource_id": "ewq-123-ewq",
    "start": "2020-03-01T12:00:00",
    "end": "2020-03-01T13:00:00",
    "data": [
        {
            "source": "url",
            "history": {
                "target_url1": {
                    "target_key1”: [
                        {
                            "code": 2,
                            "description": "Source stream not found",
                            "time": 1583065877
                        },
                        {
                            "code": 0,
                            "description": "OK",
                            "time": 1583065879
                        },
                        {
                            "code": 7,
                            "description": "Restream stopped",
                            "time": 1583067077
                        }
                    ]
                }
            }
        },
        {
            "source": "url2",
            "history": {
                "target_url2": {
                    "target_key2: [
                        {
                            "code": 5,
                            "description": "No status changes found",
                            "time": 1583074800
                        }
                    ]
                }
            }
        }
    ]
}

Unsuccessful response example

{"success": False, "code": 400, "message": "Client not found"}