docs: Queries

Getting a subset of videos

If you want to get a subset of videos from a project based on arbitrary values in the video object, queries are what you want!

To query the videos in a project you provide us with some JavaScript code that we run. Your code is then run against all the video objects in a project and you choose to return the video objects (or some subset of data from them) when you have the correct video objects.

It’s easy!

It might sound a little daunting but given a basic use case the code you have to provide is super simple:

if (video.views > 9000) { return video }

This will return all videos that have more than 9000 views. Easy, right?

It’s powerful!

This method of querying is super powerful, and allows you to do very cool stuff that makes other development tasks simpler.

Let’s say we have a backend where we handle our users, users can belong to a group and you store the groupId in the field in a video object when it is uploaded.

Now let’s say we want to get all the videos for a user, that user belongs to a list of groups with groupIds: [99, 23, 31, 76, 22] but only if they are uploaded within the last week. And we want to list the show the thumbnail and the group name, so all we really need is the video id, thumbnail url, and the groupId that the video belonged to.

This will then return an array of json objects with the just the values i needed.

Note: You can throw errors from within the filter. When throwing an error, the execution is stopped, and only that one error is returned.


In the example above you can see that we are using lodash utility library and moment.js a date/time utility library. These libraries are available in the scope of your code.

Usage example:


_.includes(collecttion, value);





API Reference

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


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.