Add & Stream Video content

Use this guide to understand how to upload video files into one of Videograph's environments and generate HLS stream playback url.
1 Generate API Access token key pair Videograph uses token key pair that consists of Token ID and a secret key to authenticate API calls. You can generate a new access token in settings of your Videograph dashboard. API Access Tokens are specific to an environment. Make sure you select the right environment tin which you want to upload the video files. The access token should have Video Read and Write permissions.
2 Send POST request to upload video You can manually upload a video file from your computer using Videograph Dashboard or Send POST Request either from Videograph Dashboard / other party API tools. API requests work best if you have the input video file URL. Below is basic code you require to create a Video. object for a successful content creation request.
curl --request POST \
     --url https://api.videograph.ai/video/services/api/v1/contents \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
     "content": [
          {
               "url": "https://d19nx8bm4jzw4h.cloudfront.net/Tears-of-steel.mp4"
          }
     ],
     "playback_policy": [
          "public"
     ],
     "title": "Demo Video"
}
'
const sdk = require('api')('@videograph/v1.0#4ac1hlcq4cun5');

sdk.auth('APITOKEN', 'SECRETKEY');
sdk.postVideoServicesApiV1Contents({
  content: [{url: 'https://d19nx8bm4jzw4h.cloudfront.net/Tears-of-steel.mp4'}],
  playback_policy: ['public'],
  title: 'Demo Video'
})
  .then(({ data }) => console.log(data))
  .catch(err => console.error(err));
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.videograph.ai/video/services/api/v1/contents', [
  'body' => '{"content":[{"url":"https://d19nx8bm4jzw4h.cloudfront.net/Tears-of-steel.mp4"}],"playback_policy":["public"],"title":"Demo Video"}',
  'headers' => [
    'accept' => 'application/json',
    'authorization' => 'Basic APITOKEN',
    'content-type' => 'application/json',
  ],
]);

echo $response->getBody();
import requests

url = "https://api.videograph.ai/video/services/api/v1/contents"

payload = {
    "content": [{"url": "https://d19nx8bm4jzw4h.cloudfront.net/Tears-of-steel.mp4"}],
    "playback_policy": ["public"],
    "title": "Demo Video"
}
headers = {
    "accept": "application/json",
    "content-type": "application/json",
    "authorization": "Basic APITOKEN"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"content\":[{\"url\":\"https://d19nx8bm4jzw4h.cloudfront.net/Tears-of-steel.mp4\"}],\"playback_policy\":[\"public\"],\"title\":\"Demo Video\"}");
Request request = new Request.Builder()
  .url("https://api.videograph.ai/video/services/api/v1/contents")
  .post(body)
  .addHeader("accept", "application/json")
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "Basic APITOKEN")
  .build();

Response response = client.newCall(request).execute();

After posting the content creation request successfully. You will receive an API response with Content ID and Playback ID along with Status saying “Preparing” or “Ready”

{
  "code": 200,
  "data": {
    "contentId": "fa6d3dc8-c78c-4c67-98ef",
    "created_at": 1673353801033,
    "description": "",
    "duration": 0,
    "metadata": [],
    "mp4_support": true,
    "playbackPolicy": [
      "public"
    ],
    "save_original_copy": false,
    "status": "Pending",
    "statusId": 1,
    "test_video": true,
    "title": "Demo Video"
  },
  "message": "Data success",
  "status": "Success"
}
3 Wait till you see “ready” status of the content As soon as you send a POST request Videograph will start downloading the video file and processing it. For video files with shorter duration usually this process take a few seconds. For larger video files this process might take few minutes or longer depending on the connection speed and the video formats. Once the video file is ready for Playback, the content “status” changes from “processing” to “ready”. In order to retrieve the asset status you can either use Webhooks or manually poll with “Get Content Details” API. Below is a sample API request to get the content details. Make sure that you don’t poll this API more than once per second.
curl --request GET \
     --url https://api.videograph.ai/video/services/api/v1/contents/CONTENT_ID \
     --header 'accept: application/json' \
     --header 'authorization: Basic APITOKEN'
const sdk = require('api')('@videograph/v1.0#4ac1hlcq4cun5');

sdk.auth('APITOKEN', 'SECRETKEY');
sdk.getVideoServicesApiV1ContentsContent_id({CONTENT_ID: 'CONTENT_ID'})
  .then(({ data }) => console.log(data))
  .catch(err => console.error(err));
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.videograph.ai/video/services/api/v1/contents/CONTENT_ID', [
  'headers' => [
    'accept' => 'application/json',
    'authorization' => 'Basic APITOKEN',
  ],
]);

echo $response->getBody();
import requests

url = "https://api.videograph.ai/video/services/api/v1/contents/CONTENT_ID"

headers = {
    "accept": "application/json",
    "authorization": "Basic APITOKEN"
}

response = requests.get(url, headers=headers)

print(response.text)
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.videograph.ai/video/services/api/v1/contents/CONTENT_ID")
  .get()
  .addHeader("accept", "application/json")
  .addHeader("authorization", "Basic APITOKEN")
  .build();

Response response = client.newCall(request).execute();
4 Play the content using Playback ID To Play a content in your application, you can use the Playback HLS url returned to API response of POST request.An easy way to watch the content preview is from Videograph’s dashboard. If you want to watch full video you can copy the “Link to Video” URL and paste it in your browser to start watching it.
5 Manage your content from Video dashboard. Once you have created your assets in Videograph’s environment, you can create Video Clips, Generate thumbnails, Add subtitles, and Add metadata to your content from Videograph Dashboard.