Socket
Socket
Sign inDemoInstall

@api.video/nodejs-client

Package Overview
Dependencies
10
Maintainers
3
Versions
37
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @api.video/nodejs-client

api.video nodejs API client


Version published
Weekly downloads
965
decreased by-31.56%
Maintainers
3
Install size
2.89 MB
Created
Weekly downloads
 

Changelog

Source

[2.5.7] - 2024-04-23

  • Add *WithResponseHeaders() methods

Readme

Source

badge   badge   badge

api.video Node.js 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.

Table of contents

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

Rate Limiting

api.video implements rate limiting to ensure fair usage and stability of the service. The API provides the rate limit values in the response headers for any API requests you make. The /auth endpoint is the only route without rate limitation.

In this Node.js client, you can access these headers by using the *WithResponseHeaders() versions of the methods. These methods return both the response body and the headers, allowing you to check the X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Retry-After headers to understand your current rate limit status.

Read more about these response headers in the API reference.

Here is an example of how to use these methods:

const client = new ApiVideoClient({ apiKey: "YOUR_API_KEY" });
const { body: videos, headers } = await client.videos.listWithResponseHeaders();
console.log('Rate Limit:', headers['x-ratelimit-limit']);
console.log('Rate Limit Remaining:', headers['x-ratelimit-remaining']);
console.log('Rate Limit Retry after:', headers['x-ratelimit-retry-after']);

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.

Keywords

FAQs

Last updated on 24 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc