Pixaven Blog

Get Public Video Thumbnails With Fetch Endpoint

Get Public Video Thumbnails With Fetch Endpoint

Some of our users work a lot with publicly-facing videos and user generated content available on certain outlets such as YouTube. Today we deployed a set of features to the Pixaven API which will make their daily work a little bit easier. Our Fetch Endpoint endpoint now supports fetching and transforming thumbnails of public videos.

To use this new feature simply modify image url passed to the Pixaven API as a part of Image Fetch request. The pattern used for fetching thumbnails of public videos outlet:video_id. For example, to fetch and transform thumbnail image of YouTube video represented by ID dQw4w9WgXcQ use youtube:dQw4w9WgXcQ as url in the fetch parameters.

Those thumbnails can be easily transformed with the entire suite of high-precision operations the Pixaven API offers. Say you would like to get a thumbnail of a YouTube video described by ID a6bBbTWgxCU, resize that image to a maximum width of 720px, adjust sharpness with unsharp mask, and lastly increase saturation just tiny bit. A cURL request would look like this:

curl https://api.pixaven.com/1.0/fetch -X POST -u your-api-key: \
-H "Content-Type: application/json" \
-d '{
    "url": "youtube:a6bBbTWgxCU",
    "resize": {
        "width": 720
    },
    "adjust": {
        "unsharp": 1.5,
        "saturation": 5.5
    }
}'

Here’s a quick example of said operation implemented with our official Node integration:

const Pixaven = require("pixaven");

/**
* Instantiate `pix`
*/

const pix = new Pixaven("your-api-key");

/**
* Fetch thumbnail of YouTube's video `a6bBbTWgxCU`
* resize it to a maximum width of 720 pixels width,
* and adjust sharpness (1.5) and saturation (5.5)
*/

pix
    .fetch("youtube:a6bBbTWgxCU")
    .resize({
        width: 720
    })
    .adjust({
        unsharp: 1.5,
        saturation: 5.5
    })
    .toJSON((err, meta) => {
        if (err) {
            return console.log(err);
        }
    });

We currently support YouTube, Vimeo, and Dailymotion outlets with more to follow. For the full reference, please check out updated API docs for Thumbnails of Public Videos.

Should you have questions about the Fetch endpoint or requests for other features do not hesitate to contact us anytime.