Vimeo Interactions

This feature requires a User Access Token.

Now that you can make authenticated requests, you can interact with a video.

We provide resource interactions that allow users to easily interact with Vimeo resources via the API. These interactions allow you to like a video, join a group, follow a channel, and more. Below, I’ll describe how to interact with a video (for one, never look it in the eye).

Interacting with a Video

First, make an authenticated request for a video. The response will contain the information you need.

curl -H "Authorization : bearer <ACCESS TOKEN>" https://api.vimeo.com/videos/31436718
...
"interactions": {
    "watchlater":{
        "added":false,
        "added_time":null,
        "uri":"\/users\/8607249\/watchlater\/31436718"
    },
    "like":{
        "added":true,
        "added_time":null,
         "uri":"\/users\/8607249\/likes\/31436718"
    }
}, 
….

Notice the field interactions. This describes some of the common actions a user might perform with this resource. The two we currently provide are “like” and “watchlater”. These two interactions behave identically, so let’s focus on “like”.

Within the like object, there will be three parameters: added, added_on, and uri.

  • added - boolean - This field describes the current state of the interaction. “true” means you have already performed this interaction (e.g., you have liked this video) and “false” means the interaction has not yet happened.

  • added_on - date - This field will be null if added is false, and a date if added is true. This field tells you at what date the interaction was performed (e.g., at what date you liked this video).

  • uri - string - This field contains the API endpoint that allows you to perform the interaction. If added is false, you should make a PUT request to this URI to perform the interaction. If added is true, you should make a DELETE request to this uri to undo the interaction.

If you have not yet liked the Bug Report video, you can like it by making the following PUT request.

curl -H "Authorization : bearer <ACCESS TOKEN>" -XPUT https://api.vimeo.com/me/likes/31436718

If you have already liked the Bug Report video, you can unlike it by making the following DELETE request.

curl -H "Authorization : bearer <ACCESS TOKEN>" -XDELETE https://api.vimeo.com/me/likes/31436718

If you are not allowed to interact with this video, you will receive a 400 or 500-level status code. These errors are always accompanied by a description of the problem — if it’s not clear, check out our help section.

Developing with interactions

When developing your API integration, we recommend that you call the URL directly from the video response instead of trying to build it yourself. In the PHP library, this looks like the following example:

$video = $lib->request(‘/videos/31436718’);

if ($action === ‘unlike’) {
    $method = ‘DELETE’;
} else if ($action === ‘like’) {
    $method = ‘PUT’;
}

$like = $lib->request($video[‘interactions’][‘like’][‘uri’], $method);

NEXT TIME : Conditional HTTP Requests.