npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

oddworks-vimeo-provider

v1.4.2

Published

An Oddworks provider plugin for Vimeo APIs

Downloads

5

Readme

Oddworks Vimeo Provider

A Vimeo provider plugin for the Oddworks content server.

pipeline status

Installation

Install the npm package as a Node.js library:

npm install --save oddworks-vimeo-provider

For full Vimeo API documentation see developer.vimeo.com/api.

Oddworks Server Integration

The Oddworks-Vimeo provider is designed to be integrated with an Oddworks server catalog, specifically as a provider. To initialize the plugin in your server:

const vimeoProvider = require('oddworks-vimeo-provider');

// See https://gitlab.com/oddnetworks/oddworks/core/tree/master/lib/services/catalog#patterns
// for more information regarding an Oddcast Bus.
const bus = createMyOddcastBus();

const options = {
    bus: bus,
    accessToken: process.env.VIMEO_ACCESS_TOKEN
};

vimeoProvider.initialize(options).then(provider => {
    console.log('Initialized provider "%s"', provider.name);
}).catch(err => {
    console.error(err.stack || err.message || err);
});

The initialization process will attach Oddcast listeners for the following queries:

  • bus.query({role: 'provider', cmd: 'get', source: 'vimeo-video'})
  • bus.query({role: 'provider', cmd: 'get', source: 'vimeo-album'})

To use them you send Oddcast commands to save a specification object:

// To create a collection based on a Vimeo album:
bus.sendCommand({role: 'catalog', cmd: 'setItemSpec'}, {
    channel: 'abc',
    type: 'collectionSpec',
    source: 'vimeo-album',
    album: {uri: '/users/12345/albums/678901'}
});

// To create a video based on a Vimeo video:
bus.sendCommand({role: 'catalog', cmd: 'setItemSpec'}, {
    channel: 'abc',
    type: 'videoSpec',
    source: 'vimeo-video',
    video: {uri: '/videos/1234567'}
});

Transform Functions

This library provides a default transform function for collections and assets. It is fine to use the default, but you can provide your own like this:

const vimeoProvider = require('oddworks-vimeo-provider');
const bus = createMyOddcastBus();

const options = {
    bus: bus,
    collectionTransform: myCollectionTransform,
    videoTransform: myVideoTransform
};

vimeoProvider.initialize(options).then(provider => {
    console.log('Initialized provider "%s"', provider.name);
}).catch(err => {
    console.error(err.stack || err.message || err);
});

Your transform functions myCollectionTransform and myVideoTransform will be called when the vimeo-collection and vimeo-video have respectively received a response from the Vimeo API.

The myCollectionTransform and myVideoTransform functions will each be called with 2 arguments: The spec object and the Vimeo API response object for an album or video, respectively.

See lib/default-collection-transform and lib/default-video-transform for more info.

Vimeo API Client

You can create a stand-alone API client outside of the Oddworks provider:

const vimeoProvider = require('oddworks-vimeo-provider');

const client = vimeoProvider.createClient({
    bus: bus,
    accessToken: process.env.VIMEO_ACCESS_TOKEN
});

Client Methods

All methods return a Promise.

Query Strings

All methods support query strings. Simply provide the {query} key a hash of the query strings to use. This is handy for certain endpoints like list endpoints.

List endpoints such as client.getAlbums(), client.getVideosByAlbum({albumUri}), or client.getVideos() are pageable. The default number of items per page is 25 and the max number of items per-page is 50. If your account contains more than 25 videos or albums, or your album contains more than 25 videos, you will need to pass query params in order to fetch the rest of your data.

Example:

const albumId = '12345';
const query = {
  page: 2,
  per_page: 25
};

client
  .getVideosByAlbum({albumId, query})
  .then(res => {
    console.log(JSON.stringify(res, null, 2));
  });

Command Line Interface

You can interact with the Vimeo client using the CLI tool. To get started, run:

bin/vimeo --help

To authenticate the API you'll need to export the following environment variables:

  • VIMEO_ACCESS_TOKEN The Vimeo API access token

To get help with commands:

bin/vimeo list --help
bin/vimeo req --help

License

Apache 2.0 © Odd Networks