Documentation
Learn everything about the Theta Network.

Theta Video API Docs

Create a pre-signed URL to Upload a Video

📘

You can skip the upload step if you have an external URL where your video is already hosted.

Request:

curl --location --request POST 'https://api.thetavideoapi.com/upload' \
--header 'x-tva-sa-id: srvacc_xxxxxxxxxxxxxxxxxxxxxxxxx' \
--header 'x-tva-sa-secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://api.thetavideoapi.com/upload',
  '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": {
        "uploads": [
            {
                "id": "upload_zzzzzzzzzzzzzzzzzzzzzzzzz",
                "service_account_id": "srvacc_xxxxxxxxxxxxxxxxxxxxxxxxx",
                "presigned_url": "https://storage.googleapis.com/files.thetavideoapi.com/srvacc_1f3z0062ij26bu1pa8h65we6h/upload_4d0j6tx7nbwmv96sp7y7uz550?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=beta-tva-dispatcher-sa%40beta-theta-video-api.iam.gserviceaccount.com%2F20210930%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20210930T161215Z&X-Goog-Expires=900&X-Goog-SignedHeaders=content-type%3Bhost&X-Goog-Signature=6522b1df0d2c1dc583cc9ae1a4f357b1a176c72da6d3f3c52516b024a75b35afcea1570fba165a0516607a55c79d7032509558c11126a09d8380c9d5fcbb505652c6d461dcb8277a281a5ab24e19ac34dc4431d25fcbc99e4022c6cc835fc6d2602fd99b89c01639fdff6d5175ed857452213b6946a1e0c611f1fc5608357d34687abc90dff7559ac1770d5093a454a24d52676566373c5238732ff2984ac411601972f8e595e8f0419ec96f24ca893b08a21c45ec4ddc455b047326b60018fe5a5e0ab646bacac37f3a4f340f1f41cf3ab985bd48a226984f238fd3c5ba48851b4be981b76d138f0fb06af6af358709e7fc58d721c1ef991d23fd8953dd1c7f",
                "presigned_url_expiration": "2021-09-30T16:27:15.432Z",
                "presigned_url_expired": false,
                "create_time": "2021-09-30T16:12:15.432Z",
                "update_time": "2021-09-30T16:12:15.432Z"
            }
        ]
    }
}

📘

You will need the "id" in this response later. It's used as the "source_upload_id" in the API to transcode a video using an upload.

Upload a Video using the pre-signed URL

Request:

curl --location --request PUT 'https://storage.googleapis.com/files.thetavideoapi.com/srvacc_1f3z0062ij26bu1pa8h65we6h/upload_4d0j6tx7nbwmv96sp7y7uz550?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=beta-tva-dispatcher-sa%40beta-theta-video-api.iam.gserviceaccount.com%2F20210930%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20210930T161215Z&X-Goog-Expires=900&X-Goog-SignedHeaders=content-type%3Bhost&X-Goog-Signature=6522b1df0d2c1dc583cc9ae1a4f357b1a176c72da6d3f3c52516b024a75b35afcea1570fba165a0516607a55c79d7032509558c11126a09d8380c9d5fcbb505652c6d461dcb8277a281a5ab24e19ac34dc4431d25fcbc99e4022c6cc835fc6d2602fd99b89c01639fdff6d5175ed857452213b6946a1e0c611f1fc5608357d34687abc90dff7559ac1770d5093a454a24d52676566373c5238732ff2984ac411601972f8e595e8f0419ec96f24ca893b08a21c45ec4ddc455b047326b60018fe5a5e0ab646bacac37f3a4f340f1f41cf3ab985bd48a226984f238fd3c5ba48851b4be981b76d138f0fb06af6af358709e7fc58d721c1ef991d23fd8953dd1c7f' \
--header 'Content-Type: application/octet-stream' \
--data-binary '@/Users/renegarcia/Downloads/file_example.mp4'
var request = require('request');
var options = {
  'method': 'PUT',
  'url': 'https://storage.googleapis.com/files.thetavideoapi.com/srvacc_1f3z0062ij26bu1pa8h65we6h/upload_4d0j6tx7nbwmv96sp7y7uz550?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=beta-tva-dispatcher-sa%40beta-theta-video-api.iam.gserviceaccount.com%2F20210930%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20210930T161215Z&X-Goog-Expires=900&X-Goog-SignedHeaders=content-type%3Bhost&X-Goog-Signature=6522b1df0d2c1dc583cc9ae1a4f357b1a176c72da6d3f3c52516b024a75b35afcea1570fba165a0516607a55c79d7032509558c11126a09d8380c9d5fcbb505652c6d461dcb8277a281a5ab24e19ac34dc4431d25fcbc99e4022c6cc835fc6d2602fd99b89c01639fdff6d5175ed857452213b6946a1e0c611f1fc5608357d34687abc90dff7559ac1770d5093a454a24d52676566373c5238732ff2984ac411601972f8e595e8f0419ec96f24ca893b08a21c45ec4ddc455b047326b60018fe5a5e0ab646bacac37f3a4f340f1f41cf3ab985bd48a226984f238fd3c5ba48851b4be981b76d138f0fb06af6af358709e7fc58d721c1ef991d23fd8953dd1c7f',
  'headers': {
    'Content-Type': 'application/octet-stream'
  },
  body: "<file contents here>"

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

Response:

empty

Transcode a Video using an Upload

Request:

curl --location --request POST 'https://api.thetavideoapi.com/video' \
--header 'x-tva-sa-id: srvacc_xxxxxxxxxxxxxxxxxxxxxxxxx' \
--header 'x-tva-sa-secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
--header 'Content-Type: application/json' \
--data-raw '{
    "source_upload_id": "upload_zzzzzzzzzzzzzzzzzzzzzzzzz",
    "playback_policy": "public"
}'
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://api.thetavideoapi.com/video',
  'headers': {
    'x-tva-sa-id': 'srvacc_xxxxxxxxxxxxxxxxxxxxxxxxx',
    'x-tva-sa-secret': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({"source_upload_id":"upload_zzzzzzzzzzzzzzzzzzzzzzzzz","playback_policy":"public"})

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

Response:

{
    "status": "success",
    "body": {
        "videos": [
            {
                "id": "video_vvvvvvvvvvvvvvvvvvvvvvvvvv",
                "playback_uri": null,
                "create_time": "2021-09-30T16:43:00.806Z",
                "update_time": "2021-09-30T16:43:00.806Z",
                "service_account_id": "srvacc_xxxxxxxxxxxxxxxxxxxxxxxxx",
                "file_name": null,
                "state": "created",
                "sub_state": "none",
                "source_upload_id": "upload_zzzzzzzzzzzzzzzzzzzzzzzzz",
                "source_uri": null,
                "playback_policy": "public",
                "progress": 0,
                "error": null,
                "duration": null,
                "resolution": null,
                "metadata": {}
            }
        ]
    }
}

Transcode a Video using an external URI

Request:

curl --location --request POST 'https://api.thetavideoapi.com/video' \
--header 'x-tva-sa-id: srvacc_xxxxxxxxxxxxxxxxxxxxxxxxx' \
--header 'x-tva-sa-secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
--header 'Content-Type: application/json' \
--data-raw '{
    "source_uri": "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",
    "playback_policy": "public"
}'
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://api.thetavideoapi.com/video',
  'headers': {
    'x-tva-sa-id': 'srvacc_xxxxxxxxxxxxxxxxxxxxxxxxx',
    'x-tva-sa-secret': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({"source_uri":"http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4","playback_policy":"public"})

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

Response:

{
    "status": "success",
    "body": {
        "videos": [
            {
                "id": "video_vvvvvvvvvvvvvvvvvvvvvvvvvv",
                "playback_uri": null,
                "create_time": "2021-09-30T16:50:56.662Z",
                "update_time": "2021-09-30T16:50:56.662Z",
                "service_account_id": "srvacc_xxxxxxxxxxxxxxxxxxxxxxxxx",
                "file_name": null,
                "state": "created",
                "sub_state": "none",
                "source_upload_id": null,
                "source_uri": "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",
                "playback_policy": "public",
                "progress": 0,
                "error": null,
                "duration": null,
                "resolution": null,
                "metadata": {}
            }
        ]
    }
}

GET your Video to check it's progress

Request:

curl --location --request GET 'https://api.thetavideoapi.com/video/video_vvvvvvvvvvvvvvvvvvvvvvvvvv' \
--header 'x-tva-sa-id: srvacc_xxxxxxxxxxxxxxxxxxxxxxxxx' \
--header 'x-tva-sa-secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://api.thetavideoapi.com/video/video_vvvvvvvvvvvvvvvvvvvvvvvvvv',
  '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 of in progress video:

{
    "status": "success",
    "body": {
        "videos": [
            {
                "id": "video_vvvvvvvvvvvvvvvvvvvvvvvvvv",
                "playback_uri": null,
                "create_time": "2021-09-30T16:50:56.662Z",
                "update_time": "2021-09-30T16:51:48.467Z",
                "service_account_id": "srvacc_xxxxxxxxxxxxxxxxxxxxxxxxx",
                "file_name": null,
                "state": "processing",
                "sub_state": "transcoding",
                "source_upload_id": null,
                "source_uri": "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",
                "playback_policy": "public",
                "progress": 9.58,
                "error": null,
                "duration": null,
                "resolution": null,
                "metadata": {}
            }
        ]
    }
}

Response of finished video:

{
    "status": "success",
    "body": {
        "videos": [
            {
                "id": "video_vvvvvvvvvvvvvvvvvvvvvvvvvv",
                "playback_uri": "https://media.thetavideoapi.com/video_vvvvvvvvvvvvvvvvvvvvvvvvvv/master.m3u8",
                "create_time": "2021-09-30T16:50:56.662Z",
                "update_time": "2021-09-30T17:00:57.520Z",
                "service_account_id": "srvacc_xxxxxxxxxxxxxxxxxxxxxxxxx",
                "file_name": null,
                "state": "success",
                "sub_state": "none",
                "source_upload_id": null,
                "source_uri": "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",
                "playback_policy": "public",
                "progress": 100,
                "error": null,
                "duration": "596473",
                "resolution": 720,
                "metadata": {}
            }
        ]
    }
}

Enable Theta p2p Video Delivery

To enable Theta p2p Video Delivery for the transcoded video, please follow the steps in this guide.

Updated 3 months ago



Theta Video API Docs


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.