-
Notifications
You must be signed in to change notification settings - Fork 178
Vonage Media
Vonage Media • Docs
Documentation / Vonage Media
Client class to interact with the Media API which enables users to manage their media items programmatically.
This client is only available as a standalone client. It cannot be instantiated from the server-sdk package.
Create a standalone Secret client
import { Media } from '@vonage/media';
const mediaClient = new Media({
apiKey: VONAGE_API_KEY,
apiSecret: VONAGE_API_SECRET
});
Client
new Media(credentials, options?): Media
• credentials: AuthInterface
| AuthParams
• options?: ConfigParams
Client.constructor
node_modules/@vonage/server-client/dist/client.d.ts:11
protected auth: AuthInterface;
Client.auth
node_modules/@vonage/server-client/dist/client.d.ts:9
protected authType: AuthenticationType = AuthenticationType.JWT;
Client.authType
protected config: ConfigParams;
Client.config
node_modules/@vonage/server-client/dist/client.d.ts:10
static transformers: __module;
Client.transformers
node_modules/@vonage/server-client/dist/client.d.ts:7
addAuthenticationToRequest(request): Promise<VetchOptions>
• request: VetchOptions
Promise
<VetchOptions
>
Client.addAuthenticationToRequest
node_modules/@vonage/server-client/dist/client.d.ts:12
deleteMediaItem(mediaId): Promise<void>
Deletes a specific media item by its unique identifier.
• mediaId: string
The unique identifier of the media item to be deleted.
Promise
<void
>
A promise that resolves once the media item is successfully deleted.
Delete a media item
await mediaClient.deleteMediaItem('my-media-id');
getMediaItem(mediaId): Promise<MediaItem>
Retrieves information about a specific media item by its unique identifier.
• mediaId: string
The unique identifier of the media item.
Promise
<MediaItem
>
A promise that resolves to a MediaItem object representing the retrieved media item.
Retrieve a media item by its ID
const media = await mediaClient.getMediaItem('my-media-id');
console.log(`Media item ${media.id} is ${media.public ? 'public' : 'private'}`);
console.log(` - Title: ${media.title}`);
console.log(` - Description: ${media.description}`);
getMediaPage(params): Promise<MediaItemPageResponse>
Retrieves a page of media items based on the specified parameters.
• params: MediaParameters
= {}
Optional parameters for customizing the media page request.
Promise
<MediaItemPageResponse
>
A promise that resolves to a MediaItemPageResponse object representing the page of media items.
List the first page of media items
const resp = await mediaClient.getMediaPage();
console.log(`There are ${resp.count} media items in total`);
console.log(`Showing ${resp._embedded.media.length} media items on this page`);
listAllMediaItems(params): AsyncGenerator<MediaItem, void & MediaItem, undefined>
Retrieves a paginated list of media items, yielding each item sequentially.
• params: MediaParameters
= {}
Optional parameters for customizing the media list request.
AsyncGenerator
<MediaItem
, undefined
>
An asynchronous generator that yields MediaItem objects.
List all media items
for await (const media of mediaClient.listAllMediaItems()) {
console.log(`Media item ${media.id} is ${media.public ? 'public' : 'private'}`);
console.log(` - Title: ${media.title}`);
console.log(` - Description: ${media.description}`);
};
List all public media items
for await (const media of mediaClient.listAllMediaItems({ public: true })) {
console.log(`Media item ${media.id} is public`);
console.log(` - Title: ${media.title}`);
console.log(` - Description: ${media.description}`);
};
sendDeleteRequest<T>(url): Promise<VetchResponse<T>>
• T
• url: string
Promise
<VetchResponse
<T
>>
Client.sendDeleteRequest
node_modules/@vonage/server-client/dist/client.d.ts:13
sendFormSubmitRequest<T>(url, payload?): Promise<VetchResponse<T>>
• T
• url: string
• payload?
Promise
<VetchResponse
<T
>>
Client.sendFormSubmitRequest
node_modules/@vonage/server-client/dist/client.d.ts:14
sendGetRequest<T>(url, queryParams?): Promise<VetchResponse<T>>
• T
• url: string
• queryParams?
Promise
<VetchResponse
<T
>>
Client.sendGetRequest
node_modules/@vonage/server-client/dist/client.d.ts:17
sendPatchRequest<T>(url, payload?): Promise<VetchResponse<T>>
• T
• url: string
• payload?
Promise
<VetchResponse
<T
>>
Client.sendPatchRequest
node_modules/@vonage/server-client/dist/client.d.ts:20
sendPostRequest<T>(url, payload?): Promise<VetchResponse<T>>
• T
• url: string
• payload?
Promise
<VetchResponse
<T
>>
Client.sendPostRequest
node_modules/@vonage/server-client/dist/client.d.ts:23
sendPutRequest<T>(url, payload?): Promise<VetchResponse<T>>
• T
• url: string
• payload?
Promise
<VetchResponse
<T
>>
Client.sendPutRequest
node_modules/@vonage/server-client/dist/client.d.ts:26
sendRequest<T>(request): Promise<VetchResponse<T>>
• T
• request: VetchOptions
Promise
<VetchResponse
<T
>>
Client.sendRequest
node_modules/@vonage/server-client/dist/client.d.ts:32
sendRequestWithData<T>(
method,
url,
payload?): Promise<VetchResponse<T>>
• T
• method: HTTPMethods
• url: string
• payload?
Promise
<VetchResponse
<T
>>
Client.sendRequestWithData
node_modules/@vonage/server-client/dist/client.d.ts:29
updateMediaItem(media): Promise<void>
Updates the information of a specific media item based on the provided data.
• media: MediaItem
The updated media item data.
Promise
<void
>
A promise that resolves once the media item is successfully updated.
Update a media item
const media = await mediaClient.getMediaItem('my-media-id');
media.title = 'My new title';
media.description = 'My new description';
await mediaClient.updateMediaItem(media);
type MediaItem: object;
Represents a media item.
accountId: string;
The ID of your Nexmo account. This is the same as your API key.
optional description: string;
An optional description of the media file.
etag: string;
An identifier for the content. This will change if the content of the file has been changed (i.e., if you upload a new version of the file). For more information, see Wikipedia: HTTP ETag.
id: string;
A UUID representing the object.
maxDownloadsAllowed: number;
The maximum number of times the file may be downloaded.
mediaSize: number;
The size of the file in bytes.
metadataPrimary: string;
A user-set string containing metadata about the media file.
metadataSecondary: string;
A user-set string containing further metadata about the media file.
mimeType: string;
The IETF MIME type of the file.
originalFileName: string;
The filename of the object as it was originally uploaded.
public: boolean;
Whether the item is available for download without authentication.
storeId: string;
An internal identifier of how the file is stored.
timeCreated: string;
A timestamp for the time that the file was created.
timeLastUpdated: string;
A timestamp for the time that the file was last modified.
timesDownloaded: number;
The number of times the file has been downloaded.
optional title: string;
An optional title for the media file.
type MediaItemPageResponse: object;
Represents the response data for a page of media items.
_embedded: object;
A collection of media items.
_embedded.media: MediaItemResponse[];
_links: object & APILinks;
Links to navigate through pages.
optional first: APILink;
Link to the first page.
optional last: APILink;
Link to the last page.
optional next: APILink;
Link to the next page.
optional prev: APILink;
Link to the previous page.
optional start: APILink;
Link to the start page.
count: number;
The total number of records returned by your request.
page_index: number;
The page_index used in your request.
page_size: number;
The amount of records returned in this response.
Vonage API's will return information using snake_case
. This represents the
pure response before the client will transform the keys into camelCase
.
lib/types/Responses/mediaItemResponsePage.ts:11
type MediaItemResponse: object;
Represents the response data for a media item.
accountId: string;
The ID of your Nexmo account. This is the same as your API key.
etag: string;
An identifier for the content. This will change if the content of the file has been changed (i.e., if you upload a new version of the file). For more information, see Wikipedia: HTTP ETag.
id: string;
A UUID representing the object.
maxDownloadsAllowed: number;
The maximum number of times the file may be downloaded.
mediaSize: number;
The size of the file in bytes.
metadataPrimary: string;
A user-set string containing metadata about the media file.
metadataSecondary: string;
A user-set string containing further metadata about the media file.
mimeType: string;
The IETF MIME type of the file.
originalFileName: string;
The filename of the object as it was originally uploaded.
public: boolean;
Whether the item is available for download without authentication.
storeId: string;
An internal identifier of how the file is stored.
timeCreated: string;
A timestamp for the time that the file was created.
timeLastUpdated: string;
A timestamp for the time that the file was last modified.
timesDownloaded: number;
The number of times the file has been downloaded.
Vonage API's will return information using snake_case
. This represents the
pure response before the client will transform the keys into camelCase
.
lib/types/Responses/mediaItemResponse.ts:8
type MediaParameters: object;
Represents parameters for querying media items.
optional endTime: string;
Retrieve results created on or before this timestamp.
optional order: "ascending" | "descending";
The order of search results. Must be one of 'ascending' or 'descending'.
optional pageIndex: number;
Which page to retrieve in pagination.
optional pageSize: number;
How many items at most per page.
optional startTime: string;
Retrieve results created on or after this timestamp.