api.video Node.js API client

api.video is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand & low latency live streaming features in your app.

Project description

api.video's Java Node.js is a lightweight client built in TypeScript that streamlines the coding process. Chunking files is handled for you, as is pagination and refreshing your tokens.

Getting started

Installation

With npm:

npm install @api.video/nodejs-client --save

...or with yarn:

yarn add @api.video/nodejs-client

Migration

If you're coming from @api.video/nodejs-sdk make sure to read our Migration guide first.

Development

To build and compile the typescript sources to javascript use:

npm install
npm run build

Code sample

const ApiVideoClient = require('@api.video/nodejs-client');
// or: import ApiVideoClient from '@api.video/nodejs-client';

(async () => {
    try {
        const client = new ApiVideoClient({ apiKey: "YOUR_API_KEY" });

        // create a video
        const videoCreationPayload = {
            title: "Maths video", // The title of your new video.
            description: "A video about string theory.", // A brief description of your video.
        };
        const video = await client.videos.create(videoCreationPayload);

        // upload a video file into the video container
        await client.videos.upload(video.videoId, "my-video-file.mp4");
    } catch (e) {
        console.error(e);
    }
})();

Documentation

API Endpoints

AnalyticsApi

MethodDescriptionHTTP request
getLiveStreamsPlays()Get play events for live streamGET /analytics/live-streams/plays
getVideosPlays()Get play events for videoGET /analytics/videos/plays

CaptionsApi

MethodDescriptionHTTP request
upload()Upload a captionPOST /videos/{videoId}/captions/{language}
get()Retrieve a captionGET /videos/{videoId}/captions/{language}
update()Update a captionPATCH /videos/{videoId}/captions/{language}
delete()Delete a captionDELETE /videos/{videoId}/captions/{language}
list()List video captionsGET /videos/{videoId}/captions

ChaptersApi

MethodDescriptionHTTP request
upload()Upload a chapterPOST /videos/{videoId}/chapters/{language}
get()Retrieve a chapterGET /videos/{videoId}/chapters/{language}
delete()Delete a chapterDELETE /videos/{videoId}/chapters/{language}
list()List video chaptersGET /videos/{videoId}/chapters

LiveStreamsApi

MethodDescriptionHTTP request
create()Create live streamPOST /live-streams
get()Retrieve live streamGET /live-streams/{liveStreamId}
update()Update a live streamPATCH /live-streams/{liveStreamId}
delete()Delete a live streamDELETE /live-streams/{liveStreamId}
list()List all live streamsGET /live-streams
uploadThumbnail()Upload a thumbnailPOST /live-streams/{liveStreamId}/thumbnail
deleteThumbnail()Delete a thumbnailDELETE /live-streams/{liveStreamId}/thumbnail

PlayerThemesApi

MethodDescriptionHTTP request
create()Create a playerPOST /players
get()Retrieve a playerGET /players/{playerId}
update()Update a playerPATCH /players/{playerId}
delete()Delete a playerDELETE /players/{playerId}
list()List all player themesGET /players
uploadLogo()Upload a logoPOST /players/{playerId}/logo
deleteLogo()Delete logoDELETE /players/{playerId}/logo

UploadTokensApi

MethodDescriptionHTTP request
createToken()Generate an upload tokenPOST /upload-tokens
getToken()Retrieve upload tokenGET /upload-tokens/{uploadToken}
deleteToken()Delete an upload tokenDELETE /upload-tokens/{uploadToken}
list()List all active upload tokensGET /upload-tokens

VideosApi

MethodDescriptionHTTP request
create()Create a video objectPOST /videos
upload()Upload a videoPOST /videos/{videoId}/source
uploadWithUploadToken()Upload with an delegated upload tokenPOST /upload
get()Retrieve a video objectGET /videos/{videoId}
update()Update a video objectPATCH /videos/{videoId}
delete()Delete a video objectDELETE /videos/{videoId}
list()List all video objectsGET /videos
uploadThumbnail()Upload a thumbnailPOST /videos/{videoId}/thumbnail
pickThumbnail()Set a thumbnailPATCH /videos/{videoId}/thumbnail
getStatus()Retrieve video status and detailsGET /videos/{videoId}/status

WatermarksApi

MethodDescriptionHTTP request
upload()Upload a watermarkPOST /watermarks
delete()Delete a watermarkDELETE /watermarks/{watermarkId}
list()List all watermarksGET /watermarks

WebhooksApi

MethodDescriptionHTTP request
create()Create WebhookPOST /webhooks
get()Retrieve Webhook detailsGET /webhooks/{webhookId}
delete()Delete a WebhookDELETE /webhooks/{webhookId}
list()List all webhooksGET /webhooks

Models

Authorization

API key

Most endpoints required to be authenticated using the API key mechanism described in our documentation. The access token generation mechanism is automatically handled by the client.

All you have to do is provide an API key when instantiating the ApiVideoClient:

const client = new ApiVideoClient({ apiKey: "YOUR_API_KEY" });

Get the access token

If you need to access the access-token value obtained using the API key, you can use the getAccessToken() method of the client:

const client = new ApiVideoClient({ apiKey: "YOUR_API_KEY" });
const accessToken = await client.getAccessToken();

Public endpoints

Some endpoints don't require authentication. These one can be called with an ApiVideoClient instantiated without API key:

const client = new ApiVideoClient();

Have you gotten use from this API client?

Please take a moment to leave a star on the client ⭐

This helps other users to find the clients and also helps us understand which clients are most popular. Thank you!

Contribution

Since this API client is generated from an OpenAPI description, we cannot accept pull requests made directly to the repository. If you want to contribute, you can open a pull request on the repository of our client generator. Otherwise, you can also simply open an issue detailing your need on this repository.

Was this page helpful?