@api.video/nodejs-client

中文文档
2.6.8发布于 2024/11/08MITTypeScriptESM + CJS近 30 天下载 1.2万

api.video nodejs API client

原始使用文档
文档目录14 节
  1. Table of contents
  2. Project description
  3. Getting started
  4. Installation
  5. Migration
  6. Development
  7. Code sample
  8. Documentation
  9. API Endpoints
  10. Models
  11. Rate Limiting
  12. Authorization
  13. Have you gotten use from this API client?
  14. Contribution

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
getAggregatedMetrics()Retrieve aggregated metricsGET /data/metrics/{metric}/{aggregation}
getMetricsBreakdown()Retrieve metrics in a breakdown of dimensionsGET /data/buckets/{metric}/{breakdown}
getMetricsOverTime()Retrieve metrics over timeGET /data/timeseries/{metric}

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
complete()Complete a live streamPUT /live-streams/{liveStreamId}/complete

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

SummariesApi

MethodDescriptionHTTP request
create()Generate video summaryPOST /summaries
update()Update summary detailsPATCH /summaries/{summaryId}/source
delete()Delete video summaryDELETE /summaries/{summaryId}
list()List summariesGET /summaries
getSummarySource()Get summary detailsGET /summaries/{summaryId}/source

TagsApi

MethodDescriptionHTTP request
list()List all video tagsGET /tags

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
getDiscarded()Retrieve a discarded video objectGET /discarded/videos/{videoId}
getStatus()Retrieve video status and detailsGET /videos/{videoId}/status
listDiscarded()List all discarded video objectsGET /discarded/videos
updateDiscarded()Update a discarded video objectPATCH /discarded/videos/{videoId}

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.

版本与发布记录

@api.video/nodejs-client 共发布 46 个版本,首次发布于 2021/05/25;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.6.8latest2024/11/082 年前
2.6.72024/11/042 年前
2.6.62024/10/212 年前
2.6.52024/10/172 年前
2.6.42024/10/082 年前
2.6.32024/10/022 年前

关于 @api.video/nodejs-client 的常见问题

@api.video/nodejs-client 是什么?

api.video nodejs API client

如何安装 @api.video/nodejs-client?

在项目目录运行 npm install @api.video/nodejs-client,或使用 pnpm add / yarn add / bun add。

@api.video/nodejs-client 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@api.video/nodejs-client 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@api.video/nodejs-client 可以商用吗?

@api.video/nodejs-client 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@api.video/nodejs-client 的下载量有多少?

根据 npm 官方下载统计,@api.video/nodejs-client 在 2026/10/06 – 2026/11/04 这 30 天内被下载 12,074 次,日均约 402 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@api.video/nodejs-client 还在维护吗?

最新版本 2.6.8 发布于 2024/11/08(2 年前);至今共发布 46 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/05/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。