How can we help?

Assigning Categories to Videos Using the API Follow

Once you've created categories to organize your videos and playlists, you will want to begin assigning these category values to your content. Review the developer tutorial below to assign the categories to your videos using our API.

 

For instructions on getting your API or app keys, see API and App Keys.

 

Update Video Endpoint

To add or update category values on videos, you will be using the update video endpoint from our API.

 

The payload will change depending on if you are adding a category and values to the video for the first time or if instead, you are updating the values of a category already associated with the video.

 

Adding a category and values to a video

To add a category and it's values to a video in your library we need to use the update video PUT Request. 

PUT https://api.zype.com/videos/{video_id}

Sample URL with API credential would look like this:

http://api.zype.com/videos/5f592b64fdb9aa0d04351?api_key=YOUR_API_KEY

The Payload needs a top 'video' object and a then a 'categories_attributes' array with the category id and the values we want to add inside an array.

Sample JSON payload:

{
"video": {
"categories_attributes": [
{
"category_id": "5cbe058cc1c8d71268e94c29",
"value": ["Value1","Value2"]
}
]
}
}

 

Updating a category value to a video already associated with a category

To update category values on a video already associated with the category, an extra parameter is required on the payload. This value is a unique identifier in the video-category relationship, which is unique for this specific video-category pair and can be found on the video object using the List Videos or View Video endpoints.

Sample JSON payload:

{
"video": {
"categories_attributes": [
{
"id": "5f592d2dda6f6800012c3b51",
"category_id": "5cbe058cc1c8d71268e94c29",
"value": ["Value2","Value3"]
}
]
}
}

Note: Using the request without the "Video-Category" id on a video already associated with the intended category will result in a 422 error, even if no actual category values are selected for the video. 

error 422 | "message": "Could not update video: Categories is invalid"

 

Where can I find the unique video-category identifier?

The unique identifier for the video-category relationship can be found on the video object using the List Videos or View Video endpoints.

GET https://api.zype.com/videos/{video_id}

 

On the 'category' array of each video object, each element will have the unique video-category identifier ('_id'), the category id, and the values currently selected for the video for that category.  

"response": {
"_id": "5f592b64fdb9aa0001d04351", <- video_id
"active": true,
"categories": [
{
"_id": "5f592d2dda6f6800012c3b4f", <- video-category uid
"category_id": "5e8e759b74ab2d00013af6fe",
"title": "My Category Title",
"value": ["Value2","Value3"]
},
{
"_id": "5f592d2dda6f6800012c3b52", <- video-category uid
"category_id": "5cae5f70e3cac814cbe12e5c",
"title": "Audio Language",
"value": ["spanish"]
},
....

 

 

Comments

Please sign in to leave a comment.