The api.video API Reference

Welcome to the api.video developer hub. You'll find comprehensive guides and documentation to help you start working with api.video as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Node.js SDK

Description

A Node.JS implementation of api.video. The code repository is hosted at https://github.com/apivideo/nodejs-sdk.

There is a sample video upload project using Node.js. The code is on GitHub, and the example is running in production. The project is also descried in a Medium blog post.

Installation

npm install @api.video/nodejs-sdk

Client Creation

const apiVideo = require('@api.video/nodejs-sdk');
`

Create client for Production and authenticate

const client = new apiVideo.Client({ apiKey: 'xxx' });
`

Create client for Sandbox and authenticate

const client = new apiVideo.ClientSandbox({ apiKey: 'xxx' });
`

Videos

For details on the expected responses for these calls, please refer back to the video API documentation.

Create and upload a video resource

let result = client.videos.upload('/path/to/video.mp4', {title: 'Course #4 - Part B'});

 result.then(function(video) {
  console.log(video.title);
}).catch(function(error) {
  console.error(error);
});
`

Update video properties

let result = client.videos.update('viXxxxXxxxXxxxxxxxXX', {description: 'Course #4 - Part B'});

 result.then(function(video) {
   console.log(video.description);
 });
`

Search video by tags filter and paginate results

let result = client.videos.search({currentPage: 1, pageSize: 25, tags: ['finance']});

 result.then(function(videos) {
  for (let x = 0; x < videos.length; x += 1) {
    if (Object.prototype.hasOwnProperty.call(videos, x)) {
      let video = videos[x];
      console.log(video.title);
    }
  }
});
`

Delete video resource

let result = client.videos.delete('viXxxxXxxxXxxxxxxxXX');
result.then(function(statusCode) {
  console.log(statusCode);
}).catch(function(error) {
  console.error(error);
});
`

Upload a video thumbnail

let result = client.videos.uploadThumbnail('/path/to/thumbnail.jpg', 'viXxxxXxxxXxxxxxxxXX');

 result.then(function(video) {
  console.log(video.title);
});
`

Update video thumbnail by picking image with video timecode

let result = client.videos.updateThumbnailWithTimecode('viXxxxXxxxXxxxxxxxXX', '00:15:22.05');

 result.then(function(video) {
  console.log(video.title);
});
`

Delegated Upload

For expected responses for these calls, refer back to delegated video APIs.

Generate a token for someone to upload a video into your account

result = client.tokens.generate(); // string(3): "xyz"
 result.then(function(token) {
  // ...then upload from anywhere without authentication:
  //  curl https://ws.api.video/upload?token=xyz -F [email protected]
});
`

Live

For expected responses for these calls, refer back to Live Streaming APIs.

Show a live

client.lives.get(liveStreamId);
`

List or search lives

client.lives.search(parameters = {});

Create live properties

client.lives.create(name, properties = {});

Update live properties

client.lives.update(liveStreamId, properties);

Delete live (file and data)

client.lives.delete(liveStreamId);

Upload a thumbnail for live

client.lives.uploadThumbnail(source, liveStreamId);

Example:

Create a live stream

let result = client.lives.create('This is a live');
`

Captions

For expected responses for these calls, refer back to Caption APIs.

Upload video caption

let result = client.captions.upload('path/to/caption.vtt', {videoId: 'viXxxxXxxxXxxxxxxxXX', language: 'en'});

 result.then(function(caption) {
   console.log(caption.src);
});

Get video caption by language

let result = client.captions.get('viXxxxXxxxXxxxxxxxXX', 'en');

 result.then(function(caption) {
   console.log(caption.src);
});

Update the default caption language

let result = client.captions.updateDefault('viXxxxXxxxXxxxxxxxXX', 'en', true);

 result.then(function(caption) {
   console.log(caption.default);
});

Delete caption by language

let result = > client.captions.delete('viXxxxXxxxXxxxxxxxXX', 'en');
 result.then(function(statusCode) {
   console.log(statusCode);
}).catch(function(error) {
  console.error(error);
});

Upload video chapter

let result = client.chapters.upload('path/to/chapter.vtt', {videoId: 'viXxxxXxxxXxxxxxxxXX', language: 'en'});

 result.then(function(chapter) {
  console.log(chapter.src);
});

Chapters

For expected responses for these calls, refer back to Chapter APIs.

Get caption for a video

client.videos.chapters.get(videoId, language);

Get all chapters for a video

client.videos.chapters.getAll(videoId);

Upload a chapter file for a video (.vtt)

client.videos.chapters.upload(source, properties);

Delete video's chapter

client.videos.chapters.delete(videoId, language);

Players

For expected responses for these calls, refer back to Player APIs.

Create players with default values

let result = client.players.create();

 result.then(function(player) {
   console.log(player.playerId);
});

Get a player

let result = client.players.get('plXxxxXxxxXxxxxxxxXX');

 result.then(function(player) {
   console.log(player.playerId);
});

Search a player with paginate results

let result = client.players.search({currentPage: 1, pageSize: 50});

 result.then(function(players) {
   for (let x = 0; x < players.length; x += 1) {
    if (Object.prototype.hasOwnProperty.call(players, x)) {
      let player = players[x];
      console.log(player.playerId);
    }
  }
});

set player properties

let properties = {
  shapeMargin: 10,
  shapeRadius: 3,
  shapeAspect: "flat",
  shapeBackgroundTop: "rgba(50, 50, 50, .7)",
  shapeBackgroundBottom: "rgba(50, 50, 50, .8)",
  text: "rgba(255, 255, 255, .95)",
  link: "rgba(255, 0, 0, .95)",
  linkHover: "rgba(255, 255, 255, .75)",
  linkActive: "rgba(255, 0, 0, .75)",
  trackPlayed: "rgba(255, 255, 255, .95)",
  trackUnplayed: "rgba(255, 255, 255, .1)",
  trackBackground: "rgba(0, 0, 0, 0)",
  backgroundTop: "rgba(72, 4, 45, 1)",
  backgroundBottom: "rgba(94, 95, 89, 1)",
  backgroundText: "rgba(255, 255, 255, .95)",
  enableApi: true,
  enableControls: true,
  forceAutoplay: false,
  hideTitle: true,
  forceLoop: true
};
let result = client.players.update('plXxxxXxxxXxxxxxxxXX', properties);

result.then(function(player) {
  console.log(player.forceLoop);
});

Upload a player logo

let result = client.players.uploadLogo('/path/to/logo.png', 'plXxxxXxxxXxxxxxxxXX', 'https://api.video');

result.then(function(player) {
  console.log(player.logo);
});

Delete a player

let result = client.players.delete('plXxxxXxxxXxxxxxxxXX');
result.then(function(statusCode) {
  console.log(statusCode);
}).catch(function(error) {
  console.error(error);
});

Statistics

For expected responses for these calls, refer back to Raw Statistics APIs.

Get video analytics between period

client.analyticsVideo.get(videoId, period);

#### Search videos analytics between period, filter with tags or metadata
client.analyticsVideo.search(parameters);

Get live analytics between period

client.analyticsLive.get(liveStreamId, period);

Search lives analytics between period, filter with tags or metadata

client.analyticsLive.search(parameters);

Get analytics session events

client.analyticsLive.get(sessionId, parameters);

Updated 2 months ago

Node.js SDK


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.