/vhx-js

VHX API Client – Javascript

Primary LanguageJavaScriptMIT LicenseMIT

Vimeo OTT/VHX Javascript API Client

Ready for use server-side, using Node. Not ready for use client-side, as we currently do not offer public API keys.

Installation

npm install @vhx/vhxjs

Documentation

For Full API reference go here.

Getting Started

Before requesting your first resource, you must setup your instance of the Vimeo OTT/VHX Client. This can be done with either:

Node:

const VhxApi = require('@vhx/vhxjs/dist/index.js');

const vhx = new VhxApi('YOUR_API_KEY_HERE');

Client (using a module bundler like Webpack/Rollup/etc.)

import VhxApi from '@vhx/vhxjs';

const vhx = new VhxApi('YOUR_API_KEY_HERE');

or through a standard script tag, (use client.js in the dist folder)

<script src="your_path/client.js"></script>
var vhx = new VhxApi('YOUR_API_KEY_HERE');

Depending on the endpoint, the resource will take either:

  • two arguments - an id, then an optional object with options
  • one argument - only an options object

The id can either be in the form of a numeric ID or an HREF (see example below).

This library uses Promises instead of callbacks. You can either use then/catch or async/await:

vhx.customers.retrieve('1234').then(res => console.log(res));

or

async getCustomers() => {
  const customers = await vhx.customers.retrieve('https://api.vhx.tv/customers/1234');
  console.log(customers);  // logs the object once the promise is resolved
}

Resources & Methods

products

customers

videos

collections

browse

analytics