![badge](https://img.shields.io/twitter/follow/api_video?style=social)
![badge](https://img.shields.io/github/stars/apivideo/nodejs-sdk?style=social)
![badge](https://img.shields.io/discourse/topics?server=https%3A%2F%2Fcommunity.api.video)
![](https://github.com/apivideo/API_OAS_file/blob/master/apivideo_banner.png)
api.video is an API that encodes on the go to facilitate immediate playback, enhancing viewer streaming experiences across multiple devices and platforms. You can stream live or on-demand online videos within minutes.
api.video NodeJS SDK
DEPRECATION WARNING: this SDK will soon be deprecated and will no longer be maintained. It has been replaced by the NodeJS API client. Please use it instead.
![Build Status](https://scrutinizer-ci.com/g/ApiVideo/nodejs-sdk/badges/build.png?b=master&s=e01c30ae25aa2b0472299c1d961faf67e48bda65)
The api.video web-service helps you put video on the web without the hassle.
This documentation helps you use the corresponding NodeJS client.
Installation
npm install @api.video/nodejs-sdk
Usage
const apiVideo = require('@api.video/nodejs-sdk');
(async () => {
try {
const client = new apiVideo.Client({ apiKey: 'xxx' });
const video = await client.videos.upload('test/data/small.webm', { title: 'Course #4 - Part B' });
console.log(video);
} catch (e) {
console.error(e);
}
})();
See sandbox.spec.js for more usage examples.
Full API
const client = new apiVideo.Client({ apiKey: 'xxx' });
client.videos.get(videoId);
client.videos.getStatus(videoId);
client.videos.search(parameters = {});
client.videos.create(title, properties = {});
client.videos.upload(source, properties = {}, videoId = null);
client.videos.download(source, title, properties = {});
client.videos.update(videoId, properties);
client.videos.makePublic(videoId);
client.videos.makePrivate(videoId);
client.videos.delete(videoId);
result = client.tokens.generate();
result.then(function(token) {
});
client.videos.uploadThumbnail(source, videoId);
client.videos.updateThumbnailWithTimecode(videoId, timecode);
client.videos.captions.get(videoId, language);
client.videos.captions.getAll(videoId);
client.videos.captions.upload(source, properties);
client.videos.captions.updateDefault(videoId, language, isDefault);
client.videos.captions.delete(videoId, language);
client.videos.chapters.get(videoId, language);
client.videos.chapters.getAll(videoId);
client.videos.chapters.upload(source, properties);
client.videos.chapters.delete(videoId, language);
client.players.get(playerId);
client.players.search(parameters = {});
client.players.create(properties = {});
client.players.uploadLogo(source, playerId, link);
client.players.update(playerId, properties);
client.players.deleteLogo(playerId);
client.players.delete(playerId);
client.lives.get(liveStreamId);
client.lives.search(parameters = {});
client.lives.create(name, properties = {});
client.lives.update(liveStreamId, properties);
client.lives.delete(liveStreamId);
client.lives.uploadThumbnail(source, liveStreamId);
client.analyticsVideo.get(videoId, period);
client.analyticsLive.get(liveStreamId, period);
client.analyticsLive.get(sessionId, parameters);
Full API Details Implementation
Videos
Function | Parameters | Description | Required | Allowed Values |
---|
get | videoId(string) | Video identifier | :heavy_check_mark: | - |
getStatus | videoId(string) | Video identifier | :heavy_check_mark: | - |
search | - | - | - | - |
- | parameters(object) | Search parameters | :x: | - currentPage(int)
- pageSize(int)
- sortBy(string)
- sortOrder(string)
- keyword(string)
- tags(string|array(string))
- metadata(array(string))
|
create | - | - | - | - |
- | title(string) | Video title | :heavy_check_mark: | - |
- | properties(object) | Video properties | :x: | - description(string)
- tags(array(string))
- playerId(string)
- metadata(array(
array( 'key' => 'Key1', 'value' => 'value1' ), array( 'key' => 'Key2', 'value' => 'value2' ) ) - panoramic(bool)
- public(bool)
- mp4Support(bool)
|
upload | - | - | - | - |
- | source(string) | Video media file | :heavy_check_mark: | - |
- | properties(object) | Video properties | :x: | - title(string)
- description(string)
- tags(array(string))
- playerId(string)
- metadata(array(
array( 'key' => 'Key1', 'value' => 'value1' ), array( 'key' => 'Key2', 'value' => 'value2' ) )
|
- | videoId(string) | Video identifier | :x: | - |
uploadThumbnail | - | - | - | - |
- | source(string) | Image media file | :heavy_check_mark: | - |
- | videoId(string) | Video identifier | :heavy_check_mark: | - |
updateThumbnailWithTimeCode | - | - | - | - |
- | videoId(string) | Video identifier | :heavy_check_mark: | - |
- | timecode(string) | Video timecode | :heavy_check_mark: | 00:00:00.00 (hours:minutes:seconds.frames) |
update | - | - | - | - |
- | videoId()string | Video identifier | :heavy_check_mark: | - |
- | properties(object) | Video properties | :heavy_check_mark: | - title(string)
- description(string)
- tags(array(string))
- playerId(string)
- metadata(array(
array( 'key' => 'Key1', 'value' => 'value1' ), array( 'key' => 'Key2', 'value' => 'value2' ) ) - panoramic(bool)
- public(bool)
- mp4Support(bool)
|
makePublic | videoId(string) | Video identifier | :heavy_check_mark: | - |
makePrivate | videoId(string) | Video identifier | :heavy_check_mark: | - |
delete | videoId(string) | Video identifier | :heavy_check_mark: | - |
Players
Function | Parameters | Description | Required | Allowed Values |
---|
get | playerId(string) | Player identifier | :heavy_check_mark: | - |
create | properties(object) | Player properties | :x: | - shapeMargin(int)
- shapeRadius(int)
- shapeAspect(string)
- shapeBackgroundTop(string)
- shapeBackgroundBottom(string)
- text(string)
- link(string)
- linkHover(string)
- linkActive(string)
- trackPlayed(string)
- trackUnplayed(string)
- trackBackground(string)
- backgroundTop(string)
- backgroundBottom(string)
- backgroundText(string)
- enableApi(bool)
- enableControls(bool)
- forceAutoplay(bool)
- hideTitle(bool)
|
uploadLogo | - | - | - | - |
- | source(string) | Logo file | :heavy_check_mark: | - |
- | playerId(string) | Player identifier | :heavy_check_mark: | - |
- | link(string) | Logo link | :heavy_check_mark: | - |
search | - | - | - | - |
- | parameters(object) | Search parameters | :x: | - currentPage(int)
- pageSize(int)
- sortBy(string)
- sortOrder(string)
|
update | - | - | - | - |
- | playerId(string) | Player identifier | :heavy_check_mark: | - |
- | properties(object) | Player properties | :heavy_check_mark: | - shapeMargin(int)
- shapeRadius(int)
- shapeAspect(string)
- shapeBackgroundTop(string)
- shapeBackgroundBottom(string)
- text(string)
- link(string)
- linkHover(string)
- linkActive(string)
- trackPlayed(string)
- trackUnplayed(string)
- trackBackground(string)
- backgroundTop(string)
- backgroundBottom(string)
- backgroundText(string)
- enableApi(bool)
- enableControls(bool)
- forceAutoplay(bool)
- hideTitle(bool)
|
deleteLogo | playerId(string) | Player identifier | :heavy_check_mark: | - |
delete | playerId(string) | Player identifier | :heavy_check_mark: | - |
Captions
Function | Parameters | Description | Required | Allowed Values |
---|
get | - | - | - | - |
- | videoId(string) | Video identifier | :heavy_check_mark: | - |
- | language(string) | Language identifier | :heavy_check_mark: | 2 letters (ex: en, fr) |
getAll | videoId(string) | Video identifier | :heavy_check_mark: | - |
upload | - | - | - | - |
- | source(string) | Caption file | :heavy_check_mark: | - |
- | properties(string) | Caption properties | :heavy_check_mark: | - videoId(string)
- language(string - 2 letters)
|
updateDefault | - (object) | - | - | - |
- | videoId | Video identifier | :heavy_check_mark: | - |
- | language (string) | Language identifier | :heavy_check_mark: | 2 letters (ex: en, fr) |
- | isDefault (string) | Set default language | :heavy_check_mark: | true/false |
delete | - | - | - | - |
- | videoId | Video identifier | :heavy_check_mark: | - |
- | language (string) | Language identifier | :heavy_check_mark: | 2 letters (ex: en, fr) |
Chapters
Function | Parameters | Description | Required | Allowed Values |
---|
get | - | - | - | - |
- | videoId(string) | Video identifier | :heavy_check_mark: | - |
- | language(string) | Language identifier | :heavy_check_mark: | 2 letters (ex: en, fr) |
getAll | videoId(string) | Video identifier | :heavy_check_mark: | - |
upload | - | - | - | - |
- | source(string) | Chapter file | :heavy_check_mark: | - |
- | properties(string) | Chapter properties | :heavy_check_mark: | - videoId(string)
- language(string - 2 letters)
|
delete | - | - | - | - |
- | videoId | Video identifier | :heavy_check_mark: | - |
- | language (string) | Language identifier | :heavy_check_mark: | 2 letters (ex: en, fr) |
Lives
Function | Parameters | Description | Required | Allowed Values |
---|
get | liveStreamId(string) | Live identifier | :heavy_check_mark: | - |
search | - | - | - | - |
- | parameters(object) | Search parameters | :x: | - currentPage(int)
- pageSize(int)
- sortBy(string)
- sortOrder(string)
|
create | - | - | - | - |
- | name(string) | Live name | :heavy_check_mark: | - |
- | properties(object) | Live properties | :x: | - record(boolean)
- playerId(string)
|
uploadThumbnail | - | - | - | - |
- | source(string) | Image media file | :heavy_check_mark: | - |
- | liveStreamId(string) | Live identifier | :heavy_check_mark: | - |
update | - | - | - | - |
- | liveStreamId()string | Live identifier | :heavy_check_mark: | - |
- | properties(object) | Live properties | :heavy_check_mark: | - name(string)
- record(boolean)
- playerId(string)
|
delete | liveStreamId(string) | Live identifier | :heavy_check_mark: | - |
AnalyticsVideo
Function | Parameters | Description | Required | Allowed Values/Format |
---|
get | - | - | - | - |
- | videoId(string) | Video identifier | :heavy_check_mark: | - |
- | period (string) | Period research | :x: | - For a day : 2018-01-01
- For a week: 2018-W01
- For a month: 2018-01
- For a year: 2018
- Date range: 2018-01-01/2018-01-15
|
AnalyticsLive
Function | Parameters | Description | Required | Allowed Values/Format |
---|
get | - | - | - | - |
- | liveStreamId(string) | Live identifier | :heavy_check_mark: | - |
- | period (string) | Period research | :x: | - For a day : 2018-01-01
- For a week: 2018-W01
- For a month: 2018-01
- For a year: 2018
- Date range: 2018-01-01/2018-01-15
|
AnalyticsSessionEvent
Function | Parameters | Description | Required | Allowed Values/Format |
---|
get | - | - | - | - |
- | sessionId(string) | Session identifier | :heavy_check_mark: | - |
- | parameters(array) | Search parameters | :x: | - currentPage(int)
- pageSize(int)
|
Tokens
Function | Parameters | Description | Required | Allowed Values |
---|
generate | - | Token for delegated upload | - | - |
Account
Function | Parameters | Description | Required | Allowed Values |
---|
get | - | Get account informations (quota, features) | - | - |
More on api.video
A full technical documentation is available on https://docs.api.video/
Test
npm run test
You can also run a bunch of commands against your actual sandbox:
API_KEY=xxx npm run test:sandbox
Use the Sandbox API Key and not your production key.