Using API to Publish Content
  • 12 Jul 2024
  • 8 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

Using API to Publish Content

  • Dark
    Light
  • PDF

Article summary

Introduction

The ViewLift CMS (VLCMS) Upload API allows you to programmatically upload and manage video content on the ViewLift platform. This guide provides detailed instructions on how to use the API, including required parameters, field descriptions, and example requests. The API enables you to streamline your content management workflow, ensuring efficient and automated video uploads with optional encoding, DRM settings, and metadata management.

Purpose

The purpose of the VLCMS Upload API is to facilitate the efficient and automated uploading of video content to the ViewLift platform. By using this API, you can:

  • Upload video files directly to the ViewLift CMS.

  • Automatically encode videos and manage DRM settings.

  • Attach metadata, images, and additional assets to your videos.

  • Schedule video publishing and visibility settings.

  • Integrate video content management into your existing workflow and applications.

Prerequisites

Before using the VLCMS Upload API, ensure you have met the following prerequisites:

  1. API Key: Obtain an API Key from the ViewLift CMS under Admin > SDK Management. You can generate up to 5 API Keys for your account.

  2. ViewLift S3 Bucket Access: Ensure your source files are located in your dedicated ViewLift S3 bucket. Contact your account manager to set up access for sending assets to this bucket.

  3. CURL Tool: Have the CURL command-line tool installed for making HTTP requests (alternatively, you can use any other HTTP client).

  4. Metadata Information: Prepare all necessary metadata, including title, description, author details, and image URLs, to include in your upload requests.

  5. Video File: Ensure your video file is correctly formatted and uploaded to the ViewLift S3 bucket.

Upload Request (with Encoding)

Follow these date formats when specifying airDateTime and seasonAirDateTime:

  • airDateTime: "2023-10-22T23:00:00.000 PM

  • seasonAirDateTime: "07/26/2019 7:30 AM"

Include these keys in your JSON payload:

  • drmEnabled: Boolean indicating if DRM is enabled.

  • externalId: Unique identifier for assets migrated or created via the API.

Requirements

  • When sending sourceKey (s3Url), do not send videoAssets, and vice versa.

  • Always include videoImageUrl when using this API.

  • EDL and CC files will only function when thesourceKey (s3Url) is included in the API; they will not work if videoAssets are sent in the API.

Recommendations

  • If posterImageUrl is unavailable, ignore it rather than passing null.

  • For schedule times not required up to year 2080, omit scheduleStartTime, scheduleEndTime, scheduleStartDate, scheduleEndDate.

  • When declaring schedule start and end times, include timezone.

  • If categories, tags, or closed captions aren't available, pass an empty array.

Sample JSON

{
    "site": "abc-tv",
    "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",
    "s3Url": "s3://boost-abc-tv/MezzFiles/archive/2023/10/TV show name-2023-10-22T18-00.mp4",
    "edlUrl": "s3://boost-abc-tv/Edl/2024/07/10/1720583818875_adlc240529_mod1.edl",
    "ccUrl": "s3://boost-abc-tv/Captions/2024/07/10/1720583826286_sample_webvtt.vtt",
    "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)

For uploading content with pre-existing renditions, use the following format:

API Endpoint: https://tools.viewlift.com/v2.0/content/video 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"
    }
}

Fields/Description Table:

Field

Type

Description

site

String

The site identifier where the video is to be uploaded.

author

String

The name of the author uploading the video.

description

String

A brief description of the video content.

drmEnabled

Boolean

Indicates if Digital Rights Management (DRM) is enabled for the video (true/false).

email

String

The email address of the author.

status

String

The status of the video upload, typically "open" or "closed".

filename

String

The name of the video file being uploaded.

isLiveStream

Boolean

Indicates if the video is a live stream (true/false).

free

Boolean

Indicates if the video is free to access (true/false).

fileSize

Integer

The size of the video file in megabytes (MB).

videoImageUrl

String

The URL of the video's thumbnail image.

posterImageUrl

String

The URL of the video's poster image.

title

String

The title of the video.

airDateTime

String

The date and time the video is scheduled to air, formatted as "YYYY-MM-DDTHH:MM".

airTimezone

String

The timezone of the air date/time (e.g., "US/Eastern").

year

Integer

The year the video was produced or aired.

thirdParty

String

The name of the third-party provider or partner associated with the video.

objectKey

String

The type of object being uploaded, typically "video".

isActive

Boolean

Indicates if the video is active (true/false).

isArchivedDate

Boolean

Indicates if the video is archived by date (true/false).

isCurrent

Boolean

Indicates if the video is current (true/false).

isPublishDate

Boolean

Indicates if the video is published by date (true/false).

isTrailer

Boolean

Indicates if the video is a trailer (true/false).

isTranslated

Boolean

Indicates if the video is translated (true/false).

isUpdateDate

Boolean

Indicates if the video has an update date (true/false).

isUpdated

Boolean

Indicates if the video is updated (true/false).

isVisible

Boolean

Indicates if the video is visible (true/false).

licenses

Array

An array of license objects associated with the video.

licenses.id

String

The unique identifier for the license.

licenses.title

String

The title of the license.

pricingOverrides

Object

An object for any pricing overrides associated with the video.

scheduleEndDate

String

The date the video is scheduled to end, formatted as "YYYY-MM-DDTHH:MM

".

scheduleEndTime

String

The time the video is scheduled to end.

scheduleStartDate

String

The date the video is scheduled to start, formatted as "YYYY-MM-DDTHH:MM

".

scheduleStartTime

String

The time the video is scheduled to start.

seasonAirDateTime

String

The date and time the video season is scheduled to air, formatted as "YYYY-MM-DDTHH:MM

".

seasonAirTimezone

String

The timezone of the season air date/time (e.g., "US/Eastern").

languageCode

String

The language code for the video (e.g., "default").

runtime

String

The runtime of the video in seconds.

videoAssets

Object

An object containing details about the video assets.

videoAssets.mpeg

Array

An array of MPEG rendition objects associated with the video.

mpeg.bitrate

Integer

The bitrate of the MPEG rendition.

mpeg.codec

String

The codec used for the MPEG rendition (e.g., "H264").

mpeg.renditionValue

String

The rendition value (e.g., "_360p", "_720p", "_1080p").

mpeg.url

String

The URL of the MPEG rendition.

videoAssets.hls

String

The URL of the HLS rendition.

hlsDetail.url

String

The detailed URL of the HLS rendition.

videoAssets.type

String

The type of video asset, typically "videoAsset".

Uploading Video Content to ViewLift CMS

To upload video content to the ViewLift CMS using the ViewLift API, you can use the following CURL request. This example demonstrates how to upload a video with specific parameters.

CURL Request

curl --location 'https://tools.viewlift.com/v2.0/content/video' \
--header 'xApiKey: <YOUR_X_API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
  "drm": {
    "provider": "NONE"
  },
  "autoPublish": true,
  "images": {
    "_16x9Images": [
      {
        "url": "s3://abcTV-network-prod/thumbnails/Who_steps_up_besides_Abby.jpg"
      }
    ],
 "_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>"
            }
        ]
     
  },
  "s3Url": "s3://abcTV-network-prod/MezzFiles/2024/04/1713718300810_whostepsupbesidesabby.mp4",
  "title": "Who steps up besides Abby - duplicate test",
  "description": "Who steps up besides Abby",
  "gameSportRadarId": ""
}'

Parameters/Description Table

Parameters

Description

drm

Specifies the DRM settings for the video. In this case, "provider": "NONE" indicates no DRM protection.

autoPublish

Boolean indicating whether the video should be automatically published once uploaded (true in this example)

images

Object containing URLs of images associated with the video, formatted for different aspect ratios.

16x9Images: Array of images with URLs pointing to thumbnails in 16:9 aspect ratio.

s3Url

The S3 URL where the video file is located. This URL should point to the video file in your S3 bucket.

title

Title of the video, which in this case is "Who steps up besides Abby- duplicate test".

description

Description of the video content, describing "Who steps up besides Abby".

Frequently Asked Questions (FAQ)

1. How can I obtain a ViewLift API Key?

  • You can generate up to 5 API Keys for your account by accessing the ViewLift CMS and navigating to Admin > SDK Management.

2. What is the purpose of the ViewLift CMS Upload API?

  • The ViewLift CMS Upload API enables developers to programmatically upload video content to the ViewLift CMS, facilitating automated content management workflows.

3. What are the prerequisites for uploading content with encoding?

  • Before uploading content with encoding, ensure your source video file is stored in your dedicated ViewLift S3 bucket. Contact your account manager to set up access for asset delivery to this bucket.

4. How should I format dates in my upload requests?

  • Use the specified date formats:

    • airDateTime: "2023-10-22T23:00:00.000 PM

    • seasonAirDateTime: "07/26/2019 7:30 AM"

5. What are the mandatory keys in the JSON payload for upload requests with encoding?

  • Required keys include drmEnabled, externalId, title, description, s3Url, airDateTime, and videoImageUrl.

6. How should I handle optional parameters and recommendations in my upload requests?

  • Omit optional parameters such as posterImageUrl if not available instead of passing null. For schedule times beyond 2080, exclude scheduleStartTime, scheduleEndTime, scheduleStartDate, and scheduleEndDate.

7. How do I upload content with pre-existing renditions?

  • Use the uploadAndPublish endpoint to upload content with pre-existing video renditions. Specify metadata and multiple renditions including HLS URLs and bitrates in the JSON payload.

8. What is the Thumbnail Image Sizes API used for?

  • The Thumbnail Image Sizes API allows management of various image sizes associated with video content, supporting different aspect ratios such as 16:9, 1:1, 32:9, 9:16, and 3:4.

9. How do I handle errors or issues with the API?

  • If you encounter issues or have questions about API usage, including token generation or troubleshooting, contact ViewLift technical support at techsupport@viewlift.com.


Was this article helpful?