Using API to Publish Content
  • 24 Jun 2024
  • 4 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

Using API to Publish Content

  • Dark
    Light
  • PDF

Article summary

VLCMS Upload API

You can upload content to the ViewLift CMS via an API. To upload to the ViewLift CMS, an API Key is needed, which is generated in the ViewLift CMS after logging into your account. Once you upload content to the CMS, the API will respond with an ID for that asset, and you will be able to get details of that asset from the CMS or the List API.

ViewLift API Key

To request a ViewLift Token, you’ll need a ViewLift API Key. You can generate up to 5 API Keys for your account in the CMS by going to Admin -> SDK Management:

image.png

Uploading (with Encoding) Prerequisite

If you wish to upload the original source file, and have the ViewLift encoding system process the file to create the encoded renditions of the video asset, as a prerequisite, the content you wish to upload must be already located in your dedicated ViewLift S3 bucket. That location is then used to pull the asset, put it through the encoding process, and create the object with the metadata and renditions in the ViewLift Platform and CMS. This is the most typical use case for VOD content. You can contact your account manager to set up access for you to send assets to your dedicated ViewLift S3 bucket.

Upload Request (with Encoding)
Follow these date formats

  • airDateTime:" 2023-10-22T23:00:00.000 PM”
  • seasonAirDateTime: "07/26/2019 7:30 AM"

When you need the ViewLift Platform to encode the asset from the Mezz file, only some metadata and information is required. You can get the value for the “site” key from your account manager.

Keys I've added: drmEnabled, externalId, siteOwner, videoResolution

  • drmEnabled is a boolean

  • externalId is a string used for referencing internally assets that are migrated or created via uploadandpublish api; Please keep these values unique to each asset

  • siteOwner is a string, just make this the same as site​​​​

  • videoResolution is a string that either either "SD" or "HD"

Requirement:

  • If you are sending the sourceKey you do not need to send videoAssets ; this applies vice versa.

  • Always send the videoImageUrl as you have above when using this api.

Recommendations:

  • If you do not have a posterImageUrl you can ignore it rather than passing null

  • I see you are passing the scheduled times that goes to year 2080, you don't have to pass it if you don't require scheduleStartTime, scheduleEndTime, scheduleStartDate, scheduleEndDate.

  • If you are declaring the schedule start and end times, pass the timezone also

  • If you do have any categories, tags, closedCaptions to send, you can ignore it rather than passing an empty array.

Sample JSON:

{
    "site": "abc-tv",
    "siteOwner": "abctv",
    "title": "The TV Show'\''s TV Show",
    "description": "ABC'\''s Insights: The TV Show",
    "drmEnabled": false,
    "status": "open",
    "fileName": "TVshowname-2023-10-22T18-00.mp4",
    "sourceKey": "s3://boost-abc-tv/MezzFiles/archive/2023/10/TV show name-2023-10-22T18-00.mp4",
    "author": "BEK",
    "email": "xyzabc@gmail.com",
    "videoImageUrl": "http://v-abc-tv.viewlift.com/MezzFiles/images/2023/10/TV show name-2023-10-22T18-00.png",
    "airDateTime": "2023-10-22T23:00:00.000",
    "seasonAirDateTime": "8/8/2019 5:00 AM", 
    "airTimezone": "US/Eastern", 
    "seasonAirTimezone": "US/Eastern", 
    "year": 2019,
    "thirdParty": "abc-tv",
    "objectKey": "video",
    "isTrailer": false,
    "isLiveStream": false,
    "free": false,
    "licenses": [],
    "scheduleEndDate": "1/1/2080", 
    "scheduleEndTime": "12:00 PM", 
    "scheduleStartDate": "8/8/2019", 
    "scheduleStartTime": "12:00 AM", 
    "timezone": "US/Eastern", 
    "externalId": "3bc82664-0eda-4442-a8b6-682c36349254"
}
 

Upload Request (without Encoding)

When you already have the renditions created and want to set those renditions, not needing to go through the encoding process, you can use the following format below.

image.png

API: ​https://tools.viewlift.com/vlcms/video/uploadAndPublish
Method: ​POST ​Headers: ​xApiKey ​Body:


{
"site":"<site-value>",
"author":"<author name>",
"description":"<Description of the Video",
"drmEnabled":false,
"email":"<email of the author>",
"status":"open",
"filename":"<samplefilename.mp4>",
"isLiveStream":false,
"free":false,
"fileSize":26,
"videoImageUrl":"https://cdn.com/asset.jpg";,
"posterImageUrl":"https://cdn.com/asset.jpg";,
"title":"<Video Title>",
"airDateTime":"2019-07-11T14:36:00Z",
"airTimezone":"US/Eastern",
"year":2018,
"thirdParty":"draft-kings",
"objectKey":"video",
"isActive":false,
"isArchivedDate":false,
"isCurrent":true,
"isPublishDate":true,
"isTrailer":false,
"isTranslated":false,
"isUpdateDate":true,
"isUpdated":false,
"isVisible":true,
"licenses":[
{
"id":"28733590-8e8e-11e9-8182-d18c0906e027",
"title":"India License"
}
],
"pricingOverrides":{

},
"scheduleEndDate":"2019-07-10T00:00:00Z",
"scheduleEndTime":"4:44 PM",
"scheduleStartDate":"2019-07-10T00:00:00Z",
"scheduleStartTime":"2:40 PM",
"seasonAirDateTime":"2019-07-10T14:35:00Z",
"seasonAirTimezone":"US/Eastern",
"languageCode":"default",
"runtime":"30 (runtime in seconds)",
"videoAssets":{
"mpeg":[
{
"bitrate":925,
"codec":"H264",
"renditionValue":"_360p",
"url":"https://storage-location.com/enc-asset-url-360.mp4"
},
{
"bitrate":1721,
"codec":"H264",
"renditionValue":"_720p",
"url":"https://storage-location.com/enc-asset-url-720.mp4"
},
{
"bitrate":2686,
"codec":"H264",
"renditionValue":"_1080p",
"url":"https://storage-location.com/enc-asset-url-1080.mp4"
}
],
"hls":"https://storage-location.com/enc-asset-url.m3u8",
"hlsDetail":{
"url":"https://storage-location.com/enc-asset-url.m3u8"
},
"type":"videoAsset"
}
}
 

If the Upload request is successful, the response will have the video ID as the “guid” in the response body as shown below.

200 Response​:
{ 
   "responseCode": 200, 
   "response": { 
       "videoStatus": "publish", 
       "publishDate": "2017-11-16T14:23:46Z", 
       "guid": "546b6c7c-06b7-4919-8f2e-37197b7b9dac" 
    }
}
 

If the request is not valid, whether it’s an invalid API Key, or an invalid request, you will get a 400 Bad Request response:

400 Response​: Status: 400 Bad Request, { 
"responseCode": 400, 
} 
 

Thumbnail Image Sizes API

curl --location 'https://tools.viewlift.com/v2.0/content/video' \
--header 'xApiKey: <YOUR_X_API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
    "images": {
        "_16x9Images": [
            {
                "url": <PUBLIC_URL_OF_IMAGE_UPLOADED_ON_S3>
            }
        ]
    }
}' 

API for Additional Image Sizes

curl --location 'https://tools.viewlift.com/v2.0/content/video' \
 \
--header 'xApiKey: <YOUR_X_API_KEY>' \
 \
--header 'Content-Type: application/json' \
 \
--data \
 '{
    "images": {
        "_16x9Images": [
            {
                "url": <PUBLIC_URL_OF_IMAGE_UPLOADED_ON_S3>
            }
        ],
       "_1x1Images": [
              {
                "url": <PUBLIC_URL_OF_IMAGE_UPLOADED_ON_S3>
              }
         ],
       "_32x9Images": [
              {
                "url": <PUBLIC_URL_OF_IMAGE_UPLOADED_ON_S3>
              }
        ],
        "_9x16Images": [
              {
                "url": <PUBLIC_URL_OF_IMAGE_UPLOADED_ON_S3>
              }
        ],
        "_3x4Images": [
              {
                "url": <PUBLIC_URL_OF_IMAGE_UPLOADED_ON_S3>
              }
        ],
        
    }
}'

For questions or issues regarding Token Generation, reach out to ​techsupport@viewlift.com​.


Was this article helpful?