@api.video/nodejs-client
v2.6.8
Published
api.video nodejs API client
Downloads
5,792
Readme
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
- Getting started
- Documentation
- Have you gotten use from this API client?
- Contribution
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
Method | Description | HTTP request
------------- | ------------- | -------------
getAggregatedMetrics() | Retrieve aggregated metrics | GET /data/metrics/{metric}/{aggregation}
getMetricsBreakdown() | Retrieve metrics in a breakdown of dimensions | GET /data/buckets/{metric}/{breakdown}
getMetricsOverTime() | Retrieve metrics over time | GET /data/timeseries/{metric}
CaptionsApi
Method | Description | HTTP request
------------- | ------------- | -------------
upload() | Upload a caption | POST /videos/{videoId}/captions/{language}
get() | Retrieve a caption | GET /videos/{videoId}/captions/{language}
update() | Update a caption | PATCH /videos/{videoId}/captions/{language}
delete() | Delete a caption | DELETE /videos/{videoId}/captions/{language}
list() | List video captions | GET /videos/{videoId}/captions
ChaptersApi
Method | Description | HTTP request
------------- | ------------- | -------------
upload() | Upload a chapter | POST /videos/{videoId}/chapters/{language}
get() | Retrieve a chapter | GET /videos/{videoId}/chapters/{language}
delete() | Delete a chapter | DELETE /videos/{videoId}/chapters/{language}
list() | List video chapters | GET /videos/{videoId}/chapters
LiveStreamsApi
Method | Description | HTTP request
------------- | ------------- | -------------
create() | Create live stream | POST /live-streams
get() | Retrieve live stream | GET /live-streams/{liveStreamId}
update() | Update a live stream | PATCH /live-streams/{liveStreamId}
delete() | Delete a live stream | DELETE /live-streams/{liveStreamId}
list() | List all live streams | GET /live-streams
uploadThumbnail() | Upload a thumbnail | POST /live-streams/{liveStreamId}/thumbnail
deleteThumbnail() | Delete a thumbnail | DELETE /live-streams/{liveStreamId}/thumbnail
complete() | Complete a live stream | PUT /live-streams/{liveStreamId}/complete
PlayerThemesApi
Method | Description | HTTP request
------------- | ------------- | -------------
create() | Create a player | POST /players
get() | Retrieve a player | GET /players/{playerId}
update() | Update a player | PATCH /players/{playerId}
delete() | Delete a player | DELETE /players/{playerId}
list() | List all player themes | GET /players
uploadLogo() | Upload a logo | POST /players/{playerId}/logo
deleteLogo() | Delete logo | DELETE /players/{playerId}/logo
SummariesApi
Method | Description | HTTP request
------------- | ------------- | -------------
create() | Generate video summary | POST /summaries
update() | Update summary details | PATCH /summaries/{summaryId}/source
delete() | Delete video summary | DELETE /summaries/{summaryId}
list() | List summaries | GET /summaries
getSummarySource() | Get summary details | GET /summaries/{summaryId}/source
TagsApi
Method | Description | HTTP request
------------- | ------------- | -------------
list() | List all video tags | GET /tags
UploadTokensApi
Method | Description | HTTP request
------------- | ------------- | -------------
createToken() | Generate an upload token | POST /upload-tokens
getToken() | Retrieve upload token | GET /upload-tokens/{uploadToken}
deleteToken() | Delete an upload token | DELETE /upload-tokens/{uploadToken}
list() | List all active upload tokens | GET /upload-tokens
VideosApi
Method | Description | HTTP request
------------- | ------------- | -------------
create() | Create a video object | POST /videos
upload() | Upload a video | POST /videos/{videoId}/source
uploadWithUploadToken() | Upload with an delegated upload token | POST /upload
get() | Retrieve a video object | GET /videos/{videoId}
update() | Update a video object | PATCH /videos/{videoId}
delete() | Delete a video object | DELETE /videos/{videoId}
list() | List all video objects | GET /videos
uploadThumbnail() | Upload a thumbnail | POST /videos/{videoId}/thumbnail
pickThumbnail() | Set a thumbnail | PATCH /videos/{videoId}/thumbnail
getDiscarded() | Retrieve a discarded video object | GET /discarded/videos/{videoId}
getStatus() | Retrieve video status and details | GET /videos/{videoId}/status
listDiscarded() | List all discarded video objects | GET /discarded/videos
updateDiscarded() | Update a discarded video object | PATCH /discarded/videos/{videoId}
WatermarksApi
Method | Description | HTTP request
------------- | ------------- | -------------
upload() | Upload a watermark | POST /watermarks
delete() | Delete a watermark | DELETE /watermarks/{watermarkId}
list() | List all watermarks | GET /watermarks
WebhooksApi
Method | Description | HTTP request
------------- | ------------- | -------------
create() | Create Webhook | POST /webhooks
get() | Retrieve Webhook details | GET /webhooks/{webhookId}
delete() | Delete a Webhook | DELETE /webhooks/{webhookId}
list() | List all webhooks | GET /webhooks
Models
- AccessToken
- AdditionalBadRequestErrors
- AnalyticsAggregatedMetricsResponse
- AnalyticsAggregatedMetricsResponseContext
- AnalyticsAggregatedMetricsResponseContextTimeframe
- AnalyticsData
- AnalyticsMetricsBreakdownResponse
- AnalyticsMetricsBreakdownResponseContext
- AnalyticsMetricsBreakdownResponseData
- AnalyticsMetricsOverTimeResponse
- AnalyticsMetricsOverTimeResponseContext
- AnalyticsMetricsOverTimeResponseData
- AnalyticsPlays400Error
- AnalyticsPlaysResponse
- AuthenticatePayload
- BadRequest
- BytesRange
- Caption
- CaptionsListResponse
- CaptionsUpdatePayload
- Chapter
- ChaptersListResponse
- ConflictError
- DiscardedVideoUpdatePayload
- FilterBy
- FilterBy1
- FilterBy2
- Link
- ListTagsResponse
- ListTagsResponseData
- LiveStream
- LiveStreamAssets
- LiveStreamCreationPayload
- LiveStreamListResponse
- LiveStreamUpdatePayload
- Metadata
- Model403ErrorSchema
- NotFound
- Pagination
- PaginationLink
- PlayerSessionEvent
- PlayerTheme
- PlayerThemeAssets
- PlayerThemeCreationPayload
- PlayerThemeUpdatePayload
- PlayerThemesListResponse
- Quality
- RefreshTokenPayload
- RestreamsRequestObject
- RestreamsResponseObject
- SummariesListResponse
- Summary
- SummaryCreationPayload
- SummarySource
- SummaryUpdatePayload
- TokenCreationPayload
- TokenListResponse
- TooManyRequests
- UnrecognizedRequestUrl
- UploadToken
- Video
- VideoAssets
- VideoClip
- VideoCreationPayload
- VideoSource
- VideoSourceLiveStream
- VideoSourceLiveStreamLink
- VideoStatus
- VideoStatusEncoding
- VideoStatusEncodingMetadata
- VideoStatusIngest
- VideoStatusIngestReceivedParts
- VideoThumbnailPickPayload
- VideoUpdatePayload
- VideoWatermark
- VideosListResponse
- Watermark
- WatermarksListResponse
- Webhook
- WebhooksCreationPayload
- WebhooksListResponse
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.