AIOZ Stream 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.
AIOZ Stream's 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.
With npm:
npm install @aiozstream/nodejs-client
...or with yarn:
yarn add @aiozstream/nodejs-client
import StreamClient from "@aiozstream/nodejs-client";
(async () => {
try {
const client = new StreamClient({
publicKey: "YOUR_PUBLIC_KEY",
secretKey: "YOUR_SECRET_KEY",
});
const videoCreationPayload = {
title: "First video", // The title of your new video.
description: "A new video.", // A brief description of your video.
};
const video = await client.video.create(videoCreationPayload);
if (!video.data) {
throw new Error("Failed to create video");
}
if (!video.data.id) {
throw new Error("Failed to create video");
}
// Option 1: Use client upload with videoId
// await client.uploadVideo(video.data.id, "./path/to/video.mp4");
// console.log("Upload successfully");
// Option 2: Upload parts yourself
const uploadResult = await client.video.uploadPart(
video.data.id,
"./path/to/video.mp4",
);
console.log(uploadResult);
const checkResult = await client.video.uploadVideoComplete(video.data.id);
// Check if the video upload is complete
console.log(checkResult);
} catch (e) {
console.error(e);
}
})();
| Method | Description | HTTP request |
|---|---|---|
| getAggregatedMetrics() | Aggregate one metric | POST /analytics/metrics/data/{metric}/{aggregation} |
| getBreakdownMetrics() | Bucket one metric by dimension | POST /analytics/metrics/bucket/{metric}/{breakdown} |
| getDataUsage() | Delivery volume over time | GET /analytics/data |
| getOvertimeMetrics() | Bucket one metric by time | POST /analytics/metrics/timeseries/{metric}/{interval} |
| Method | Description | HTTP request |
|---|---|---|
| create() | Create API key | POST /api_keys |
| update() | Rename an API key | PATCH /api_keys/{id} |
| delete() | Delete an API key | DELETE /api_keys/{id} |
| list() | List API keys | GET /api_keys |
| Method | Description | HTTP request |
|---|---|---|
| uploadThumbnail() | Upload live stream media thumbnail | POST /live_streams/{id}/thumbnail |
| deleteThumbnail() | Delete live stream media thumbnail | DELETE /live_streams/{id}/thumbnail |
| addLiveStreamMulticasts() | Add live stream multicast | POST /live_streams/multicast/{stream_key} |
| createLiveStreamKey() | Create live stream key | POST /live_streams |
| createStreaming() | Create a new live stream media | POST /live_streams/{id}/streamings |
| deleteLiveStreamKey() | Delete live stream key | DELETE /live_streams/{id} |
| deleteLiveStreamMulticast() | Delete live stream multicast | DELETE /live_streams/multicast/{stream_key} |
| getLiveStreamKey() | Get live stream key | GET /live_streams/{id} |
| getLiveStreamKeys() | Get live stream key list | GET /live_streams |
| getLiveStreamMedia() | Get live stream media | GET /live_streams/{id}/media |
| getLiveStreamMedias() | Get live stream media | POST /live_streams/{id}/media |
| getLiveStreamMulticastByStreamKey() | Get live stream multicast by stream key | GET /live_streams/multicast/{stream_key} |
| getLiveStreamPlayerInfo() | Get live stream media public | GET /live_streams/player/{id}/media |
| getLiveStreamStatisticByStreamMediaId() | Get live stream statistic by stream media id | GET /live_streams/statistic/{stream_media_id} |
| getLiveStreamUsage() | Get usage details for a specific live stream | GET /live_streams/usage/{stream_id} |
| getStreaming() | Get live stream media streaming | GET /live_streams/{id}/streamings/{stream_id} |
| getStreamings() | Get live stream media streamings | GET /live_streams/{id}/streamings |
| getUserStreamsUsageDetail() | Get paginated list of streams with usage details for current user | GET /live_streams/usage/streams |
| updateLiveStreamKey() | Update live stream key | PUT /live_streams/{id} |
| updateLiveStreamMedia() | Update live stream media | PUT /live_streams/{id}/streamings |
| Method | Description | HTTP request |
|---|---|---|
| create() | Create media object | POST /media/create |
| update() | update media info | PATCH /media/{id} |
| delete() | Delete media | DELETE /media/{id} |
| uploadThumbnail() | Upload media thumbnail | POST /media/{id}/thumbnail |
| deleteThumbnail() | Delete media thumbnail | DELETE /media/{id}/thumbnail |
| createCaption() | Create a new media caption | POST /media/{id}/captions/{lan} |
| deleteCaption() | Delete a media caption | DELETE /media/{id}/captions/{lan} |
| getCaptions() | Get media captions | GET /media/{id}/captions |
| getCost() | get media transcoding cost | GET /media/cost |
| getDetail() | get media detail | GET /media/{id} |
| getMediaList() | Get user media list | POST /media |
| getMediaPlayerInfo() | Get media player info | GET /media/{id}/player.json |
| setDefaultCaption() | Set the default caption | PATCH /media/{id}/captions/{lan} |
| uploadMediaComplete() | Get upload media when complete | GET /media/{id}/complete |
| uploadPart() | Upload part of media | POST /media/{id}/part |
| Method | Description | HTTP request |
|---|---|---|
| create() | Create a media chapter | POST /media/{id}/chapters/{lan} |
| get() | Get media chapters | GET /media/{id}/chapters |
| delete() | Delete a media chapter | DELETE /media/{id}/chapters/{lan} |
| Method | Description | HTTP request |
|---|---|---|
| create() | Create a player theme | POST /players |
| get() | Get a player theme | GET /players/{id} |
| update() | Update a player theme | PATCH /players/{id} |
| delete() | Delete a player theme | DELETE /players/{id} |
| list() | List player themes | GET /players |
| uploadLogo() | Upload a player theme logo | POST /players/{id}/logo |
| deleteLogo() | Delete a player theme logo | DELETE /players/{id}/logo |
| attach() | Add a player theme to a media | POST /players/add-player |
| detach() | Remove a player theme from a media | POST /players/remove-player |
| Method | Description | HTTP request |
|---|---|---|
| create() | Create a playlist | POST /playlists/create |
| get() | Get a playlist | GET /playlists/{id} |
| update() | Update a playlist | PATCH /playlists/{id} |
| delete() | Delete a playlist | DELETE /playlists/{id} |
| list() | List playlists | POST /playlists |
| deleteThumbnail() | Delete a playlist thumbnail | DELETE /playlists/{id}/thumbnail |
| addMedia() | Add media to playlists | POST /playlists/{id}/items |
| getPublic() | Get a playlist for the player | GET /playlists/{id}/player.json |
| moveItem() | Reorder a playlist | PUT /playlists/{id}/items |
| removeMedia() | Remove an item from playlists | DELETE /playlists/{id}/items/{item_id} |
| Method | Description | HTTP request |
|---|---|---|
| getMe() | Get the current account | GET /user/me |
| Method | Description | HTTP request |
|---|---|---|
| create() | Create a webhook | POST /webhooks |
| get() | Get a webhook | GET /webhooks/{id} |
| update() | Update a webhook | PATCH /webhooks/{id} |
| delete() | Delete a webhook | DELETE /webhooks/{id} |
| list() | List webhooks | GET /webhooks |
| check() | Send a test event | POST /webhooks/check/{id} |
- AddMediaRequest
- AggregatedMetricsData
- AggregatedMetricsResponse
- ApiKey
- Asset
- AttachThemeRequest
- AudioConfig
- Controls
- CreateApiKeyData
- CreateApiKeyRequest
- CreateApiKeyResponse
- CreateLiveStreamKeyRequest
- CreateLiveStreamKeyResponse
- CreateMediaCaptionData
- CreateMediaCaptionResponse
- CreateMediaChapterData
- CreateMediaChapterResponse
- CreateMediaRequest
- CreateMediaResponse
- CreatePlaylistRequest
- CreateStreamingRequest
- CreateStreamingResponse
- DataUsage
- DataUsageData
- DataUsageRequest
- DataUsageResponse
- DeletedAt
- EditorProject
- ErrorBody
- GetLiveStreamKeyData
- GetLiveStreamKeyResponse
- GetLiveStreamKeysListData
- GetLiveStreamKeysListResponse
- GetLiveStreamMediaPublicResponse
- GetLiveStreamMediaResponse
- GetLiveStreamMediasRequest
- GetLiveStreamMediasResponse
- GetLiveStreamMulticastResponse
- GetLiveStreamStatisticResponse
- GetMediaCaptionsData
- GetMediaCaptionsResponse
- GetMediaChaptersData
- GetMediaChaptersResponse
- GetMediaDetailResponse
- GetMediaListData
- GetMediaListRequest
- GetMediaListResponse
- GetMediaPlayerInfoResponse
- GetStreamUsageResponse
- GetStreamingResponse
- GetStreamingsResponse
- GetTranscodeCostData
- GetTranscodeCostResponse
- GetUserStreamsUsageDetailResponse
- HighlightChunk
- HighlightChunkStatus
- HighlightClip
- HighlightManifest
- HighlightMedia
- HighlightMediaStatus
- ListApiKeysData
- ListApiKeysRequest
- ListApiKeysResponse
- ListPlaylistsData
- ListPlaylistsRequest
- ListPlaylistsResponse
- ListThemesData
- ListThemesRequest
- ListThemesResponse
- ListWebhooksData
- ListWebhooksRequest
- ListWebhooksResponse
- LiveStreamAssets
- LiveStreamKeyData
- LiveStreamMediaData
- LiveStreamMediaResponse
- LiveStreamMediasResponse
- LiveStreamMulticast
- LiveStreamStatisticResp
- ManifestType
- MeData
- MeResponse
- MediaAssets
- MediaCaption
- MediaChapter
- MediaObject
- MediaSummary
- MediaType
- MediaWatermark
- Metadata
- MetricFilter
- MetricItem
- MetricsContext
- MetricsPageData
- MetricsPageResponse
- MetricsRequest
- MoveItemRequest
- PlayerTheme
- PlayerThemeInput
- Playlist
- PlaylistData
- PlaylistItem
- PlaylistItemMedia
- PlaylistResponse
- QualityConfig
- QualityObject
- RemoveMediaRequest
- RenameApiKeyRequest
- RenditionUsage
- ResponseError
- ResponseSuccess
- SetDefaultCaptionRequest
- StreamUsageSummary
- Theme
- ThemeData
- ThemeResponse
- TimeFrame
- UpdateLiveStreamKeyData
- UpdateLiveStreamKeyRequest
- UpdateLiveStreamKeyResponse
- UpdateLiveStreamMediaRequest
- UpdateMediaInfoRequest
- UpsertLiveStreamMulticastInput
- User
- UserStreamsUsageResponse
- VideoConfig
- VideoCropInfo
- Webhook
- WebhookData
- WebhookResponse
- WriteWebhookRequest
AIOZ Stream 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.
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.
Here is an example of how to use these methods:
const client = new StreamClient({
secretKey: "YOUR_SECRET_KEY",
publicKey: "YOUR_PUBLIC_KEY"
});
const { headers, body } = const webhook = await client.webhook.listWithResponseHeaders();All endpoints required to be authenticated using the API key and public key mechanism described in our documentation.
All you have to do is provide an API key and public key when instantiating the StreamClient:
const client = new StreamClient({
secretKey: "YOUR_SECRET_KEY",
publicKey: "YOUR_PUBLIC_KEY"
});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!