vimeo / vimeo.js Goto Github PK
View Code? Open in Web Editor NEWOfficial Node.js library for the Vimeo API.
Home Page: https://developer.vimeo.com
License: Apache License 2.0
Official Node.js library for the Vimeo API.
Home Page: https://developer.vimeo.com
License: Apache License 2.0
One of the examples (auth_example.js) states, in a comment, 'If we already knew our access token, we can provide it as the third parameter'.
However it does not appear that this is possible and is therefore misleading.
Is there a quick (unauthenticated, preferably) route to hit to check if a video exists?
Currently using the https://vimeo.com/api/oembed.json?url=https://vimeo.com/[video-id]
route but don't really need the metadata json, just want to see if a video exists.
I feel like I'm missing something simple: where is the video_id field in the responses from the Vimeo API? Should I be parsing that out separately from the URI?
Hi,
I have the following:
"use strict";
const express = require("express");
const vimeo_module = require("vimeo");
const Vimeo = vimeo_module.Vimeo;
const CLIENT_ID = "from https://developer.vimeo.com/apps/96725";
const CLIENT_SECRET = "from https://developer.vimeo.com/apps/96725";
const ACCESS_TOKEN = "from https://developer.vimeo.com/apps/96725";
const ACCESS_TOKEN_URL = "https://api.vimeo.com/oauth/access_token";
const CALLBACK_URL = "mycallback";
const SCOPES = ['public', 'private', 'edit', 'interact'];
let state_data = {
state: "unauthorized",
user: ""
};
// CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN
let lib = new Vimeo(CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN);
let auth_endpoint = lib.buildAuthorizationEndpoint(CALLBACK_URL, SCOPES, state_data.state);
const vimeoRoute = express.Router();
vimeoRoute.get('/', (req, res) => {
let auth_link = `<a href='${auth_endpoint}'>Athentificate App</a>`;
console.log('auth_link', auth_link);
res.send(auth_link);
});
vimeoRoute.get('/callback', (req, res) => {
console.log('req.query', req.query);
if (req.query.state == "unauthorized") {
let code = req.query.code;
lib.accessToken( code, CALLBACK_URL, (err, token) => {
if (err) {
return res.end("error\n" + err);
}
if (token.access_token) {
lib.access_token = token.access_token;
state_data.user = token.user;
state_data.state = "authorized";
res.statusCode = 302;
res.setHeader('Location', '/');
res.end();
console.log("authorized")
} else {
throw new Error('no access token provided');
}
});
}
});
exports.default = vimeoRoute;
When I click the link I get redirected to https://api.vimeo.com/oauth/authorize? ...
After clicking Accept I get redirected to my callback url but then I get :
Error: {"error":"invalid_client","error_description":"A valid client ID must be provided along with any request made to Vimeo's API"}
The client identified I provided is the one I got form https://developer.vimeo.com/apps/96725
What could be wrong ?
In a usual flow, A client that uploads a video needs to get some information back on a successful upload. As far as I can see, the return value is empty.
streamingUpload returns 3 parameters, the first one supposed to contain the body of the response but it comes back empty, after that I receive the statusCode and the headers object.
I need to get the video ID back and as a workaround I noticed that I receive a "location" header that includes the video ID but it feels a bit dodgy.
I couldn't find a better solution here: https://developer.vimeo.com/api/upload
Any idea ?
fs.close() in the filestreamer.js is async but is not provided with a callback
I am trying to access Vimeo to upload some videos using single-user mode (as per https://developer.vimeo.com/api/authentication#authenticated-requests)
var lib = new Vimeo(MYPARAM1, MYPARAM2, MYPARAM3);
var vimeoAccessToken = MYPARAM3; // this was generated from the API Console
var scopes = ["public","private","purchased","create","edit","delete","interact","upload"];
var state = Random.id();
var redirect_uri = "http://localhost:3000/_oauth/vimeo"
var url = lib.buildAuthorizationEndpoint(redirect_uri, scopes, state);
console.log("vimeo url",url);
This prints out the URL ... it's a loooong string starting with https://api.vimeo.com/oauth/authorize?response_type=code&client_id=
and looks good (I think?).
I am not sure how to authenticate, as the example talks about a user clicking on something to get a "code"... as this is server based, there's no user interaction.
When I try and run a test:
lib.streamingUpload('/Users/adamginsburg/Movies/Copter.m4v', function (error, body, status_code, headers) {
if (error) {
console.log(error);
throw new Meteor.Error("Vimeo Upload Error", error);
} else {
console.log(body)
console.log(status_code)
lib.request(headers.location, function (error, body, status_code, headers) {
console.log(body);
});
}
});
I get an error: "[Error: {"error":"A valid user token must be passed."}]"
Any help, please?
Since some hours
https://player.vimeo.com/api/player.js
is not accessible anymore
so individual players returns this error:
Refused to execute script from 'https://player.vimeo.com/api/player.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
Proper tests should be added
Hi !
I'm using the v3 of the API and I think the response of /me is really weird....
We have to do uri.replace('/users/','') to have the id .... (same thing with link for the username)
This is basics fields, do you plan to add then in the future ?
The response (Example from the doc)
{
"uri": "\/users\/3766357",
"name": "Handstick",
"link": "http:\/\/vimeo.dev\/handstick",
"location": "Vimeo HQ",
"bio": "I'm a staff member consisting of a stick with a plastic hand duct taped to the end. I attended Oxford.\n\nI am the Director of Hands here at Vimeo.",
"created_time": "2010-05-07T20:35:08+00:00",
"account": "plus",
"pictures": [
{
"type": "portrait",
"width": 30,
"height": 30,
"link": "http:\/\/b.vimeocdn.com\/ps\/631\/357\/6313574_30.jpg"
},
{
"type": "portrait",
"width": 75,
"height": 75,
"link": "http:\/\/b.vimeocdn.com\/ps\/631\/357\/6313574_75.jpg"
},
{
"type": "portrait",
"width": 100,
"height": 100,
"link": "http:\/\/b.vimeocdn.com\/ps\/631\/357\/6313574_100.jpg"
},
{
"type": "portrait",
"width": 300,
"height": 300,
"link": "http:\/\/b.vimeocdn.com\/ps\/631\/357\/6313574_300.jpg"
}
],
"websites": [
],
"stats": [
],
"metadata": {
"connections": {
"activities": "\/users\/3766357\/activities",
"albums": "\/users\/3766357\/albums",
"channels": "\/users\/3766357\/channels",
"feed": "\/users\/3766357\/feed",
"followers": "\/users\/3766357\/followers",
"following": "\/users\/3766357\/following",
"groups": "\/users\/3766357\/groups",
"likes": "\/users\/3766357\/likes",
"portfolios": "\/users\/3766357\/portfolios",
"videos": "\/users\/3766357\/videos",
"watchlater": "\/users\/3766357\/watchlater",
"shared": "\/users\/3766357\/shared\/videos"
}
}
}
Hi,
I am trying to upload video to vimeo.The Ajax post is aborted.but the video is saved with out contentin vimeo.If i pass space instead of actual path also video is saved without content
Here is code
function testVideoUpload1(callback){
var Vimeo = require('vimeo').Vimeo;
//CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN
var vimeoDetails = reactConfig.vimeoDetails;
var lib = new Vimeo(vimeoDetails.clientId, vimeoDetails.clientSecret, vimeoDetails.clientAccessToken);
lib.streamingUpload("/AppGenFlux/Wildlife.wmv", function (err, body, status, headers) {
if (err) {
return console.log("eror = "+err);
}
console.log("status = "+status);
console.log("location = "+headers.location);
// callback(body);
lib.request(headers.location, function (error, body, status_code, headers) {
console.log(1);
console.log(body);
callback(body);
});
});
How to use the upload request or streamingUpload method and get the bytes loaded to create a sort of progress bar?
lib.request({ query : { query : 'myquery' }})
Looks a little redundant. Maybe change query to params?
I am using streamingUpload to upload videos, but would like to set the 'upgrade_to_1080' option to true.. as far as I can see, this is currently impossible
Recent changes to the API?
I've been using this API in my application for a while now and all of the sudden I'm getting an error when I try to upload a video.
streamingUpload is no longer working for me and I am receiving the following error: The Vimeo API does not currently support Transfer-Encoding: chunked. Contact us at https://vimeo.com/help/contact if you have any questions.
I'm not sure what the issue is here. The file is completely intact on the system and everything in the code is correct like it was and has been working until recently. No changes to anything on the server, or the project itself.
Hey,
I'm using Vimeo.js for uploads in my app. It was all working very well up until today. All uploads return this error now:
Error: {"error":"Unable to complete video upload. Please get in touch with the app's creator.","link":null,"developer_message":"The upload server returned a non 200 http status code.","error_code":4011}
at IncomingMessage.<anonymous> (/home/xxxx/node_modules/vimeo/lib/vimeo.js:162:15)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
Any idea what can it be?
please help me about it
i get this error
POST /users/uploadvideo 200 47.563 ms - 12
/opt/lampp/htdocs/beyond1/node_modules/vimeo/lib/vimeo.js:445
} else if (fileSize > response.upload_quota.space.free) {
^
TypeError: Cannot read property 'space' of undefined
at /opt/lampp/htdocs/beyond1/node_modules/vimeo/lib/vimeo.js:445:49
at IncomingMessage. (/opt/lampp/htdocs/beyond1/node_modules/vimeo/lib/vimeo.js:177:9)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1055:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
[nodemon] app crashed - waiting for file changes before starting...
After updating to the 2.0.0 version (so the 3.4 API version) using the following request:
vimeoApi.request(`/videos/${vimeoId}?fields=status,files`, (error, body, status_code, headers) => {
...
});
will only give the status and not the files field.
According to the documentation, GET requests should have the JSON filter fields applied to the path. The Vimeo.js lib does this correctly.
For all other requests (POST, PUT, DELETE, PATCH), the documentation says that you need to pass the parameters through the body. The Vimeo.js lib follows this documentation, and sets the request body equal to the query parameters.
The actual API works differently, even for non-GET requests the JSON filtering field needs to be applied to the path, according to a Vimeo support team member here. From my experience, adding the filtering fields to the body of the request will be ignored by the Vimeo servers.
Thanks to Tommy who posted that answer and also supported me directly via email, I'm posting this here to hopefully save someone else the hours it took me to figure all this out.
I was wondering if there was a http call that could allow me to get a list of videos within a folder using folder Id.
Hi,
I am trying to use "POST /videos/{id}/pictures" call in order to update the default thumbnail of a video.
Using the current version of vimeo-api, the only response I get is "The app is not allowed to perform this actions".
When updating the version that the library sends to 3.2 - The actions works great.
Is there a reason for not updating the version?
Thanks!
Can you publish the latest version of this library to NPM? The NPM version does not currently include the latest fixes for file uploads...
Nested request bodies exist in the api, and are not consistently supported across the api libraries.
We need to always take nested arrays
array('privacy' => array ('view' => 'nobody') )
and if using querystring request format, expand them
"privacy.view=nobody"
See problems here:
https://vimeo.com/forums/api/topic:265764
The stackoverflow link also features my answer. The link to my repo with the potential bugfix is here: https://github.com/johnnycrab/vimeo.js
What do you think? I can also create a pull request, if needed.
Thanks!
Johnny
Hi, i've try to use your library to request vimeo API and get specific channel videos.
this is my code :
var vimeo = new Vimeo(settings.vimeo.client_id, settings.vimeo.client_secret, settings.vimeo.access_token);
vimeo.request({
path : 'channels/'+params.channel_id + '/videos',
query : {
sort : 'date',
direction : 'desc'
}
}, function (err, res) {
if (err) {
return callback(err);
}
callback(null, res);
});
If I try this code, i get this error on nodeJS :
Error: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
</body></html>
at IncomingMessage.<anonymous> (/home/throrin19/Development/Web/goomeoeventsapi/node_modules/vimeo-api/lib/vimeo.js:152:15)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:943:16
at process._tickDomainCallback (node.js:463:13)
I decide to test this request on postman and it works.
What is wrong ?
The title says all. It's possible to set the video's title (actually, it is always "undefined") through the function of upload?
Many thanks,
João Pedro Viana.
Should be an easy fix
I created an APP to upload video using Javascript SDK.
I did not request for upload acecess
I generated access token ticking all options.
Then I proceeded to use the SDK to call upload, a TypeError is raised.
node_modules/vimeo/lib/vimeo.js:177
callback(null, body, res.statusCode, res.headers)
^
TypeError: Cannot read property 'space' of undefined
at node_modules/vimeo/lib/vimeo.js:445:49
at IncomingMessage.<anonymous> (node_modules/vimeo/lib/vimeo.js:177:9)
I confirmed that line 445 in vimeo.js:
this.request('/me?fields=upload_quota.space.free', function (err, response, status) {
if (err) {
return errorCallback('Unable to pull the users upload quota. [' + err + ']')
} else if (fileSize > response.upload_quota.space.free) {
return errorCallback('User does not have any more free space to upload this video.')
}
the 'response' object is empty (status=200) hence 'upload_quota' is undefined,
Hence: Cannot read property 'space' of undefined
While I am waiting for my upload access to get approved, I am guessing free space check response is not playing sane until the upload permission is approved.
In any case, it should be proper error handling than a TypeError?
Regards,
Mohammad
I'm trying to upload videos through the API. First I'm making an authenticated POST to /me/videos
and I'm successfully receiving the data as stated in de API docs. When I want to make a followup PUT request to the upload_link_secure
url, I receive a 404?
I'm also not really sure I'm sending the file data the right way (but I guess that's not what causing the 404)
const ul = new Promise(resolve => {
lib.request({
method: 'POST',
path: `/me/videos/`,
query: { type: 'streaming' }
}, (err, body, statusCode) => {
resolve(body);
});
});
ul.then(uploadData => {
lib.request({
method: 'PUT',
path: uploadData.upload_link_secure,
formData: file.file,
headers: {
'Content-Type': file.type,
'Content-Length': file.size
}
}, (err, body, statusCode) => {
console.log('cb', statusCode);
});
});
Hello,
according to the following link,
https://help.vimeo.com/hc/en-us/articles/224819007-Can-my-upload-script-support-resumable-uploads-or-a-progress-bar-?flash_digest=ebcf64d9b1169b33257ebf61ec2293e31284a8cb
this library can support tus uploads.
I am following your example, but as i found
client.upload method supports only relative path files from server as i suppose.
Although the tus protocol supports JavaScript File object.
I found on node_modules/vimeo/lib/vimeo.js the below code
var file = fs.createReadStream(filePath)
var upload = new tus.Upload(file, { ...
So is any workaround to bypass the path restriction and give file?
Hi i am using that code to get thumbnail image of video
$.ajax({
url: 'vimeo.com/api/v2/video/'; + id + '.json',
dataType: 'jsonp',
success: function (data) {
$("#file" + fileid).attr('src', data[0].thumbnail_large);
}
});
its working for public video but for private video its not working. can anyone help ??
I read that Vimeo is using the tus protocol for resumable uploads. Is this something that will work its way down to the Vimeo JS API eventually?
Hi,
by the examples it is not clear to how to set handle user specific access-token in a multi-user authentification scenario.
The library example and docs show setting lib.access_token = token.access_token
after successfully receiving it, this rises some questions:
lib.access_token
get overwritten by the new user access_token
?new Vimeo(...)
instance on each request and store the token in a session?Using express
in the example below.
// ... constant declaration
const vimeo = new Vimeo(VIMEO_CLIENT_ID, VIMEO_CLIENT_SECRET);
// renders a link that redirects the user to vimeo auth
app.get('/', (req, res, next) => {
const vimeoState = 1; // TODO: change to generate random string
const loginUrl = vimeo.buildAuthorizationEndpoint(VIMEO_REDIRECT_URL, VIMEO_SCOPES, vimeoState);
res.render('index', {loginUrl});
});
// handle response
app.get('/auth', (req, res, next) => {
const code = req.query.code;
const state = req.query.state;
vimeo.accessToken(code, VIMEO_REDIRECT_URL, (err, token) => {
if (err) { return next(err); }
if (token.access_token) {
// Note: what to do if multiple users connected?
vimeo.access_token = token.access_token;
req.session.vimeo = {token};
}
});
});
See the code below:
path : '/videos',
query : {
page: 2,
per_page : 50,
query : '4K',
sort : 'relevant',
direction : 'desc',
filter:'content_rating',
filter_content_rating:['safe','unrated']
}
I setup filter_content_rating as an array, but the result I get only contains 'unrated' content. All the 'safe' contents are filtered away!
Also, if I change to filter_content_rating:['safe','unrated','safe'], only get 'safe' contents.
That means the API can only filter out the content with the last element of the array parameter.
Hi, just a heads up it doesn't look possible to install vimeo-api via npm since 'recently'
npm http GET https://registry.npmjs.org/vimeo-api
npm http 304 https://registry.npmjs.org/vimeo-api
npm http GET https://registry.npmjs.org/vimeo-api/-/vimeo-api-0.9.3.tgz
npm http 200 https://registry.npmjs.org/vimeo-api/-/vimeo-api-0.9.3.tgz
npm ERR! Error: shasum check failed for /home/m/tmp/npm-24984-QBusgU1y/1403475940283-0.060830639442428946/tmp.tgz
npm ERR! Expected: 8c8e3aab8f1b43569a0a2797b73c9a3e5bda4953
npm ERR! Actual: c9b1293650cf157a260ff7d153f0c5e9efcf11e6
npm ERR! From: https://registry.npmjs.org/vimeo-api/-/vimeo-api-0.9.3.tgz
... may need a republish as it doesn't look to have reached all npm clusters.
I am running a local server on localhost:8000 and initializing the library with the clientID, clientSecrets, and accessToken. When I make the streamingUpload API call on a video uploaded by a user, I get the following error messages in my chrome developer console.:
XMLHttpRequest cannot load https://api.vimeo.com/me/videos. Response to preflight request doesn't pass access control check: A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'http://localhost:8000' is therefore not allowed access. The credentials mode of an XMLHttpRequest is controlled by the withCredentials attribute.
Uncaught TypeError: res.setEncoding is not a function
Uncaught Error: Network error
Any idea what might be causing this?
When calling replace
method with these params :
vimeoClient.replace(localPath, uri, callback, progressReport, errorReport)
The culprit is setting params
to undefined at line 512 of vimeo.js :
params = undefined
and then trying to set params.file_name
http://nodejs.org/api/stream.html#stream_readable_read_size not https://github.com/vimeo/vimeo.js/blob/master/lib/vimeo.js#L140
could potentially cause dropped data
This library should check if rate limiting is in effect and not to hammer the API.
It could be an enhancement, that will allow developers to avoid the hassle of implementing their own method by parsing the headers.
If I would like to upload a video that should be private what would be the prefered way?
Call POST on /me/videos and then upload to a specific uri?
Should all these option be passed into query?
```
{
description : "some description",
name : 'name name name',
privacy : {
add : true,
download : true,
embed : "private",
view : 'unlisted'
}
Hey,
I had been experiencing problems when for example setting the video presets of a single video. This is done via a PUT request to the appropriate path, however without any body. Node.js sets a Transfer-Encoding:chunked header, as there is no content-length specified (we hadn't been setting the content-length header on empty-body requests).
So the API server responds with a 411, stating that Transfer-Encoding:chunked is not supported.
A fix would be to explicitly set Content-Length:0
when dealing with PUT / PATCH / POST / DELETE requests.
johnnycrab@a7b61d7?diff=unified
shows a possible fix. I made a comment on the needed line.
What do you think?
Needs to be tested more
Node.js modules need a code extension for running with TypeScript
looks like currently it doesn't use params passed in options for request
Hello.
I am doing the following code:
`'use strict';
const Vimeo = require('vimeo').Vimeo;
const credentials = require('./credentials.js');
const client = new Vimeo(credentials.client_identifier, credentials.client_secrets, credentials.access_token);
console.log(client);
client.upload(
'sample.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)
}
)
`
And it's giving me the above error. Console.log(client) shows the correct credentials. I've tried multiple access tokens with various levels of access. What could be causing this?
Any help appreciated!
Hi,
I'm planning to use this module in our production server. But the 3 console.log that are in vimeo.js are really spamming our webserver output log, rendering it totally useless.
I don't think those console.log should be in the 1.0 version of the module (nothing wrong with printing errors & such, but we must not print every request that works correctly !). If you really want to enable some sort of logging for it, I think you should at least add an option to enable/disable them.
Sometimes when uploading, I'm getting the following error:
write EPROTO 0:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:openssl\ssl\s23_clnt.c:782
"Irregularly" means quite often, but not always.
Any ideas why this is happening?
Cheers!
Hi all,
I use Video.get_info
to get information about videos, and the return value number_of_plays
is 0.
I check it with vimeo api playground, the api(below) return the correct value.
https://developer.vimeo.com/api/playground/videos/{video_od}
Hi,
Thanks for your work on this project.
I'm running on an issue using the FileStreamer through the streamingUpload method, after uploading the video, the video file is locked and can't be removed. This is probably due to the video file descriptor which is not closed while the upload is done.
Adding the following line when the upload is done solves the problem. (tested on version 0.10.35)
fs_module.close(_self._fd);
What do you think ?
Hope it helps.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.