Theta Video API: Livestream

Create a Livestream

📘

Each Service Account can create max 3 livestreams.

📘

If not specified, default transrate resolutions are ['160p', '240p', '360p', '720p', 'source'], or you can specify any subset of this list.

Request:

curl -X POST 'https://api.thetavideoapi.com/stream' \
-H 'x-tva-sa-id: srvacc_xxxxxxxxxxxxxxxxxxxxxxxxx' \
-H 'x-tva-sa-secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{
    "name": "demo", 
    "resolutions": ["160p", "240p", "360p", "720p", "source"], 
    "source_resolution": "720p",
    "fps": 60
}'
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://api.thetavideoapi.com/stream',
  'headers': {
    'x-tva-sa-id': 'srvacc_xxxxxxxxxxxxxxxxxxxxxxxxx',
    'x-tva-sa-secret': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({"name":"demo", "resolutions":["160p","240p","360p","720p","source"], "source_resolution":"720p", "fps":60})
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

Response:

{
   "status":"success",
   "body":{
      "id":"stream_xxxxxxxxxxxxxxxxxxxxxxxxx",
      "service_account_id":"srvacc_xxxxxxxxxxxxxxxxxxxxxxxxx",
      "name":"demo",
      "resolutions":[
         "160p",
         "240p",
         "360p",
         "720p",
         "source"
      ],
      "source_resolution":"720p",
      "fps":"60",
      "status":"off",
      "update_time":"2022-06-08T00:57:02.462Z",
      "playback_url":null,
      "thumbnail_url":null,
      "stream_server":"rtmp://live5in.thetavideoapi.com/live",
      "stream_key":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
   }
}

Retrieve a Livestream

Request:

curl -X GET 'https://api.thetavideoapi.com/stream/stream_xxxxxxxxxxxxxxxxxxxxxxxxx' \
-H 'x-tva-sa-id: srvacc_xxxxxxxxxxxxxxxxxxxxxxxxx' \
-H 'x-tva-sa-secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://api.thetavideoapi.com/stream/stream_xxxxxxxxxxxxxxxxxxxxxxxxx',
  'headers': {
    'x-tva-sa-id': 'srvacc_xxxxxxxxxxxxxxxxxxxxxxxxx',
    'x-tva-sa-secret': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

Response:

{
   "status":"success",
   "body":{
      "id":"stream_xxxxxxxxxxxxxxxxxxxxxxxxx",
      "service_account_id":"srvacc_xxxxxxxxxxxxxxxxxxxxxxxxx",
      "name":"demo",
      "resolutions":[
         "160p",
         "240p",
         "360p",
         "720p",
         "source"
      ],
      "source_resolution":"720p",
      "fps":"60",
      "status":"off",
      "update_time":"2022-06-08T00:57:02.462Z",
      "playback_url":null,
      "thumbnail_url":null,
      "stream_server":"rtmp://live5in.thetavideoapi.com/live",
      "stream_key":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
   }
}

List Livestreams of a Service Account

📘

Query parameter:

  • status: on or off. If not specified, it lists streams of both status of the service account.

Request:

curl -X GET 'https://api.thetavideoapi.com/service_account/srvacc_xxxxxxxxxxxxxxxxxxxxxxxxx/streams' \
-H 'x-tva-sa-id: srvacc_xxxxxxxxxxxxxxxxxxxxxxxxx' \
-H 'x-tva-sa-secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://api.thetavideoapi.com/service_account/srvacc_xxxxxxxxxxxxxxxxxxxxxxxxx/streams',
  'headers': {
    'x-tva-sa-id': 'srvacc_xxxxxxxxxxxxxxxxxxxxxxxxx',
    'x-tva-sa-secret': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

Response:

{
   "status":"success",
   "body":{
      "total_count":2,
      "streams":[
         {
            "id":"stream_y1h6erhtin642vqj0cf7kvqrs",
            "service_account_id":"srvacc_1f3z0062ij26bu1pa8h65we6h",
            "name":"demo",
            "resolutions":[
               "160p",
               "240p",
               "360p",
               "720p",
               "source"
            ],
            "source_resolution":"720p",
            "fps":"60",
            "status":"off",
            "update_time":"2022-06-08T00:57:02.462Z",
            "playback_url":null,
            "thumbnail_url":null
         },
         {
            "id":"stream_8miijx66ymsnd1ehf1w5v0fk1",
            "service_account_id":"srvacc_1f3z0062ij26bu1pa8h65we6h",
            "name":"demo",
            "resolutions":[
               "160p",
               "240p",
               "360p",
               "720p",
               "source"
            ],
            "source_resolution":"720p",
            "fps":null,
            "status":"off",
            "update_time":"2022-04-22T05:09:58.377Z",
            "playback_url":null,
            "thumbnail_url":null
         }
      ]
   }
}

List Livestream's Clips

📘

Query parameter (for pagination):

  • page: default is 1, for the first page
  • number: number of clips per page, default is 10

📘

For pagination purpose, in addition to the list of clip returned, response also has a total_count indicating total count of clips belonging to this livestream.

Request:

curl -X GET 'https://api.thetavideoapi.com/stream/stream_xxxxxxxxxxxxxxxxxxxxxxxxx/clips' \
-H 'x-tva-sa-id: srvacc_xxxxxxxxxxxxxxxxxxxxxxxxx' \
-H 'x-tva-sa-secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://api.thetavideoapi.com/stream/stream_xxxxxxxxxxxxxxxxxxxxxxxxx/clips',
  'headers': {
    'x-tva-sa-id': 'srvacc_xxxxxxxxxxxxxxxxxxxxxxxxx',
    'x-tva-sa-secret': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

Response:

{
   "status":"success",
   "body":{
      "total_count":35,
      "clips":[
         {
            "id":"clip_xxxxxxxxxxxxxxxxxxxxxxxxxx0",
            "stream_id":"stream_xxxxxxxxxxxxxxxxxxxxxxxxx",
            "resource_url":"https://storage.googleapis.com/clips.thetavideoapi.com/clip/stream_xxxxxxxxxxxxxxxxxxxxxxxxx/2022-05-17-23-17-53_520268.mp4",
            "create_time":"1652829473180",
            "elapsed_time":"520268"
         },
         ...
         {
            "id":"clip_xxxxxxxxxxxxxxxxxxxxxxxxxx9",
            "stream_id":"stream_xxxxxxxxxxxxxxxxxxxxxxxxx",
            "resource_url":"https://storage.googleapis.com/beta-clips.thetavideoapi.com/clip/stream_xxxxxxxxxxxxxxxxxxxxxxxxx/2022-05-17-23-16-21_520177.mp4",
            "create_time":"1652829381575",
            "elapsed_time":"520177"
         }
      ]
   }
}

Did this page help you?