All Projects → vimeo → Vimeo.js

vimeo / Vimeo.js

Licence: apache-2.0
Official Node.js library for the Vimeo API.

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Vimeo.js

Richtextview
iOS Text View (UIView) that Properly Displays LaTeX, HTML, Markdown, and YouTube/Vimeo Links
Stars: ✭ 953 (+341.2%)
Mutual labels:  vimeo
Plyr React
A simple, accessible and customisable react media player for Video, Audio, YouTube and Vimeo
Stars: ✭ 89 (-58.8%)
Mutual labels:  vimeo
Workflowshare
Workflow实例分享
Stars: ✭ 137 (-36.57%)
Mutual labels:  vimeo
Yaydl
yet another youtube down loader (Git mirror)
Stars: ✭ 45 (-79.17%)
Mutual labels:  vimeo
Network Avatar Picker
A npm module that returns user's social network avatar. Supported providers: facebook, instagram, twitter, tumblr, vimeo, github, youtube and gmail
Stars: ✭ 74 (-65.74%)
Mutual labels:  vimeo
React Modal Video
Accessible React Modal Video Component
Stars: ✭ 105 (-51.39%)
Mutual labels:  vimeo
Raspberrycast
📺 Transform your Raspberry Pi into a streaming device. Videos can be sent from mobile devices or computers (Chrome extension).
Stars: ✭ 726 (+236.11%)
Mutual labels:  vimeo
Vimeo.py
Official Python library for the Vimeo API.
Stars: ✭ 174 (-19.44%)
Mutual labels:  vimeo
Ac D3
Javascript Library for building Audiovisual Charts in D3
Stars: ✭ 76 (-64.81%)
Mutual labels:  vimeo
Jekyll Embed Video
Embed videos in Jekyll webpages without a plugin (Youtube, Vimeo, Twitch, Streamable, Mixer, Google Drive clips + more)
Stars: ✭ 135 (-37.5%)
Mutual labels:  vimeo
Kaku
🎧 Kaku is a highly integrated music player supports different online platform like YouTube, SoundCloud, Vimeo and more. Available on Mac, Windows and Linux.
Stars: ✭ 1,028 (+375.93%)
Mutual labels:  vimeo
Player.js
Interact with and control an embedded Vimeo Player.
Stars: ✭ 1,093 (+406.02%)
Mutual labels:  vimeo
Vime
Customizable, extensible, accessible and framework agnostic media player. Modern alternative to Video.js and Plyr. Supports HTML5, HLS, Dash, YouTube, Vimeo, Dailymotion...
Stars: ✭ 1,928 (+792.59%)
Mutual labels:  vimeo
Plyr
Plyr Mediaplayer (Video und Audio) im Front- und Backend
Stars: ✭ 30 (-86.11%)
Mutual labels:  vimeo
Gatsby Remark Oembed
A GatsbyJS Plugin that transforms oembed links into its corresponding embed code.
Stars: ✭ 154 (-28.7%)
Mutual labels:  vimeo
Vimeo Download Link
Class returns an object with video info for different resolutions and direct video download link
Stars: ✭ 11 (-94.91%)
Mutual labels:  vimeo
Socialcounters
jQuery/PHP - Collection of Social Media APIs that display number of your social media fans. Facebook Likes, Twitter Followers, Instagram Followers, YouTube Subscribers, etc..
Stars: ✭ 104 (-51.85%)
Mutual labels:  vimeo
Min Vid
Popout video player in Firefox
Stars: ✭ 180 (-16.67%)
Mutual labels:  vimeo
Vimeo Unity Sdk
Easily stream your Vimeo videos into Unity or record and publish out to Vimeo.
Stars: ✭ 159 (-26.39%)
Mutual labels:  vimeo
Alltube
Web GUI for youtube-dl
Stars: ✭ 1,925 (+791.2%)
Mutual labels:  vimeo

npm License Travis

This is a simple Node.js library for interacting with the Vimeo API.

Get started with the Vimeo API

There is a lot of information about the Vimeo API at https://developer.vimeo.com/api/start. Most of your questions are answered there!

Direct Help

Installation

npm install vimeo

Usage

All API requests and examples in this file must create a Vimeo object. Your CLIENT_ID and CLIENT_SECRET can be found on your app page under the Authentication tab. If you have not yet created an API app with Vimeo, you can create one at https://developer.vimeo.com/apps.

You can optionally provide an ACCESS_TOKEN to the constructor. Access tokens are required only to make requests, and you can set them later through the setAccessToken method.

You can generate acces tokens on your Vimeo app page or through the API.

var Vimeo = require('vimeo').Vimeo;
var client = new Vimeo(CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN);

Generate your access token

All requests require access tokens. There are two types of access tokens:

  • Unauthenticated: Access tokens without a user. These tokens can view only public data.
  • Authenticated: Access tokens with a user. These tokens interact on behalf of the authenticated user.

Unauthenticated

Unauthenticated API requests must generate an access token. You should not generate a new access token for each request. Instead, request an access token once and use it forever.

// `scope` is an array of permissions your token needs to access. You
// can read more at https://developer.vimeo.com/api/authentication#supported-scopes
client.generateClientCredentials(scope, function (err, response) {
  if (err) {
    throw err;
  }

  var token = response.access_token;

  // Other useful information is included alongside the access token,
  // which you can dump out to see, or visit our API documentation.
  //
  // We include the final scopes granted to the token. This is
  // important because the user, or API, might revoke scopes during
  // the authentication process.
  var scopes = response.scope;
});

Authenticated

  1. Build a link to Vimeo so your users can authorize your app.
var url = client.buildAuthorizationEndpoint(redirect_uri, scopes, state)
Name Type Description
redirect_uri string The URI the user is redirected to in Step 3. This value must be provided to every step of the authorization process, including creating your app, building your authorization endpoint, and exchanging your authorization code for an access token.
scope array An array of permissions your token needs to access. You can read more at https://developer.vimeo.com/api/authentication#supported-scopes.
state string A value unique to this authorization request. You should generate it randomly and validate it in Step 3.
  1. Your user needs to access the authorization endpoint (either by clicking the link or through a redirect). On the authorization endpoint, the user has the option to deny your app any scopes you have requested. If they deny your app, they are redirected back to your redirect_url with an error parameter.

  2. If the user accepts your app, they are redirected back to your redirect_uri with a code and state query parameter (eg. http://yourredirect.com?code=abc&state=xyz).

    1. You must validate that the state matches your state from Step 1.
    2. If the state is valid, you can exchange your code and redirect_uri for an access token.
// `redirect_uri` must be provided, and must match your configured URI.
client.accessToken(code, redirect_uri, function (err, response) {
  if (err) {
    return response.end("error\n" + err);
  }

  if (response.access_token) {
    // At this state the code has been successfully exchanged for an
    // access token
    client.setAccessToken(response.access_token);

    // Other useful information is included alongside the access token,
    // which you can dump out to see, or visit our API documentation.
    //
    // We include the final scopes granted to the token. This is
    // important because the user, or API, might revoke scopes during
    // the authentication process.
    var scopes = response.scope;

    // We also include the full user response of the newly
    // authenticated user.
    var user = response.user;
  }
});

Make requests

The API library has a request method that takes two parameters.

Options

This object contains your request information in key/value pairs.

Name Type Description
method string The HTTP method (e.g.: GET)
path string The URL path (e.g.: /users/dashron)
query string An object containing all of your parameters (for example, {"per_page": 5, "filter": "featured"}. )
headers object An object containing all additional headers (for example, {"If-Modified-Since": "Mon, 03 Mar 2014 16:29:37 -0500"}

Callback

This function is called once the upload process is complete.

Name Type Description
error error If this is provided, it means the request failed. The other parameters may or may not contain additional information. Check the status code to understand exactly what error you have encountered.
body object The parsed request body. All responses are JSON, so we parse this for you and give you the result.
status_code number The HTTP status code of the response. This partially informs you about the success of your API request.
headers object An object containing all of the response headers.
client.request(/*options*/{
  // This is the path for the videos contained within the staff picks
  // channels
  path: '/channels/staffpicks/videos',
  // This adds the parameters to request page two, and 10 items per
  // page
  query: {
    page: 2,
    per_page: 10,
    fields: 'uri,name,description,duration,created_time,modified_time'
  }
}, /*callback*/function (error, body, status_code, headers) {
  if (error) {
    console.log('error');
    console.log(error);
  } else {
    console.log('body');
    console.log(body);
  }

  console.log('status code');
  console.log(status_code);
  console.log('headers');
  console.log(headers);
});

Rate limiting

You should ensure to set JSON filter fields on all requests to ensure a steady and higher X-RateLimit-Limit.

There is an open issue#51 to reflect that the current documentation states that POST, PUT, DELETE, and PATCH requests must provide parameters in the body, but this doesn't work with the JSON filter request. Here is an example of a properly formed DELETE request:

client.request(/*options*/{
  method: 'DELETE',
  path: '/channels/12345?fields=uri'
}, /*callback*/function (error, body, status_code, headers) {
  if (error) {
    console.log('error');
    console.log(error);
  } else {
    console.log('body');
    console.log(body);
  }

  console.log('status code');
  console.log(status_code);
  console.log('headers');
  console.log(headers);
});

Uploading videos

The API library has an upload method that takes five parameters.

Internally, this library executes a tus upload approach and sends a file to the server with the tus upload protocol and tus-js-client.

Name Type Description
path string Full path to the upload file on the local system.
params object (optional) Parameters to send when creating a new video (name, privacy restrictions, and so on). See the /me/videos documentation for supported parameters.
completeCallback function A callback that is executed when the upload is complete. It has one argument, uri, that is the /videos/:id URI for your uploaded video.
progressCallback function A callback that is executed periodically during file uploading. This callback receives two parameters, bytesUploaded and bytesTotal. You can use this to determine how much of a percentage has been uploaded to the Vimeo servers.
errorCallback function A callback that is executed when any errors happen during the upload process. It has one argument, err, that is a string error message.
client.upload(
  '/home/aaron/Downloads/ada.mp4',
  function (uri) {
    console.log('File upload completed. Your Vimeo URI is:', uri)
  },
  function (bytesUploaded, bytesTotal) {
    var percentage = (bytesUploaded / bytesTotal * 100).toFixed(2)
    console.log(bytesUploaded, bytesTotal, percentage + '%')
  },
  function (error) {
    console.log('Failed because: ' + error)
  }
)

Replacing video files

To replace the source file of a video, call the replace method. It accepts five parameters:

Name Type Description
path string Full path to the upload file on the local system.
videoUri string Video URI of the video file to replace.
completeCallback function A callback that is executed when the upload is complete. It has one argument, uri, that is the /videos/:id URI for your uploaded video.
progressCallback function A callback that is executed periodically during file uploading. This callback receives two parameters, bytesUploaded and bytesTotal. You can use this to determine how much of a percentage has been uploaded to the Vimeo servers.
errorCallback function A callback that is executed when any errors happen during the upload process. It has one argument, err, that will be a string error message.
client.upload(
  '/home/aaron/Downloads/ada-v2.mp4',
  '/videos/15'
  function (uri) {
    console.log('File upload completed. Your Vimeo URI is:', uri)
  },
  function (bytesUploaded, bytesTotal) {
    var percentage = (bytesUploaded / bytesTotal * 100).toFixed(2)
    console.log(bytesUploaded, bytesTotal, percentage + '%')
  },
  function (error) {
    console.log('Failed because: ' + error)
  }
)

Troubleshooting

If you have any questions or problems, create a ticket or contact us.

Contributors

To see the contributors, please visit the contributors graph.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].