docs: Update

Updating a videos user data

All video objects have a user data field where you can store arbitrary data, this is how you update that data.

To update the user data field, you have to pass us javascript code that describes how the json structure should change.

Depending on what you want to achieve this can range from a very simple function that just writes a value to the json structure to more complex code that handles collisions etc.



Incrementing a value:

For this example, we assume that you have an application that allows sharing of a video. The initial create call should set the video.userdata.shares to 0, and every time a video is shared you want to increment a value in the user data field by 1.

This can easily be achieved by sending this code to the /v1/update/ endpoint:

video.userdata.shares = video.userdata.shares + 1;

This allow you to change the user data of a video in ways that allow the data to be updated from several sources at the same time without having to worry about overwriting data.

Note that you have access to then entire video object, but you can only write to data under video.userdata.

Marking a video as popular:

To expand on our example we can implement a check that marks a video as popular if it gets shared a lot, but only if it has a lot of views in the embed player.

Example source code:

It’s easy to see how this then could be combined with our programmable webhooks to create a workflow that would trigger some action based on when videos are marked as popular. You could have the webhook trigger a new update that marks the video as featured for a limited time and have your client easily display the most popular videos.

API reference

API Reference

Get in-depth information about SYNQs API and SDKs. Authentication functions, parameters, response formats, and error codes - find it all here.

Open API reference
SYNQ on GitHub

SDKs on GitHub

Easily use SYNQs API in the programming language of your choice. Download and install helpers for Objective-C, Java, JavaScript, Python and more.

Go to GitHub