Skip to content

Vonage Media

github-actions edited this page Jul 5, 2024 · 31 revisions

Vonage MediaDocs


Documentation / Vonage Media

Vonage Media

Classes

Media

Client class to interact with the Media API which enables users to manage their media items programmatically.

Remarks

This client is only available as a standalone client. It cannot be instantiated from the server-sdk package.

Example

Create a standalone Secret client

import { Media } from '@vonage/media';

const mediaClient = new Media({
 apiKey: VONAGE_API_KEY,
 apiSecret: VONAGE_API_SECRET
});

Extends

  • Client

Constructors

new Media()
new Media(credentials, options?): Media
Parameters

credentials: AuthInterface | AuthParams

options?: ConfigParams

Returns

Media

Inherited from

Client.constructor

Defined in

node_modules/@vonage/server-client/dist/client.d.ts:11

Properties

auth
protected auth: AuthInterface;
Inherited from

Client.auth

Defined in

node_modules/@vonage/server-client/dist/client.d.ts:9

authType
protected authType: AuthenticationType = AuthenticationType.JWT;
Overrides

Client.authType

Defined in

lib/media.ts:33

config
protected config: ConfigParams;
Inherited from

Client.config

Defined in

node_modules/@vonage/server-client/dist/client.d.ts:10

transformers
static transformers: __module;
Inherited from

Client.transformers

Defined in

node_modules/@vonage/server-client/dist/client.d.ts:7

Methods

addAuthenticationToRequest()
addAuthenticationToRequest(request): Promise<VetchOptions>
Parameters

request: VetchOptions

Returns

Promise<VetchOptions>

Inherited from

Client.addAuthenticationToRequest

Defined in

node_modules/@vonage/server-client/dist/client.d.ts:12

deleteMediaItem()
deleteMediaItem(mediaId): Promise<void>

Deletes a specific media item by its unique identifier.

Parameters

mediaId: string

The unique identifier of the media item to be deleted.

Returns

Promise<void>

A promise that resolves once the media item is successfully deleted.

Example

Delete a media item

await mediaClient.deleteMediaItem('my-media-id');
Defined in

lib/media.ts:172

getMediaItem()
getMediaItem(mediaId): Promise<MediaItem>

Retrieves information about a specific media item by its unique identifier.

Parameters

mediaId: string

The unique identifier of the media item.

Returns

Promise<MediaItem>

A promise that resolves to a MediaItem object representing the retrieved media item.

Example

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}`);
Defined in

lib/media.ts:120

getMediaPage()
getMediaPage(params): Promise<MediaItemPageResponse>

Retrieves a page of media items based on the specified parameters.

Parameters

params: MediaParameters = {}

Optional parameters for customizing the media page request.

Returns

Promise<MediaItemPageResponse>

A promise that resolves to a MediaItemPageResponse object representing the page of media items.

Example

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`);
Defined in

lib/media.ts:93

listAllMediaItems()
listAllMediaItems(params): AsyncGenerator<MediaItem, void & MediaItem, undefined>

Retrieves a paginated list of media items, yielding each item sequentially.

Parameters

params: MediaParameters = {}

Optional parameters for customizing the media list request.

Returns

AsyncGenerator<MediaItem, undefined>

An asynchronous generator that yields MediaItem objects.

Examples

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}`);
};
Defined in

lib/media.ts:61

sendDeleteRequest()
sendDeleteRequest<T>(url): Promise<VetchResponse<T>>
Type Parameters

T

Parameters

url: string

Returns

Promise<VetchResponse<T>>

Inherited from

Client.sendDeleteRequest

Defined in

node_modules/@vonage/server-client/dist/client.d.ts:13

sendFormSubmitRequest()
sendFormSubmitRequest<T>(url, payload?): Promise<VetchResponse<T>>
Type Parameters

T

Parameters

url: string

payload?

Returns

Promise<VetchResponse<T>>

Inherited from

Client.sendFormSubmitRequest

Defined in

node_modules/@vonage/server-client/dist/client.d.ts:14

sendGetRequest()
sendGetRequest<T>(url, queryParams?): Promise<VetchResponse<T>>
Type Parameters

T

Parameters

url: string

queryParams?

Returns

Promise<VetchResponse<T>>

Inherited from

Client.sendGetRequest

Defined in

node_modules/@vonage/server-client/dist/client.d.ts:17

sendPatchRequest()
sendPatchRequest<T>(url, payload?): Promise<VetchResponse<T>>
Type Parameters

T

Parameters

url: string

payload?

Returns

Promise<VetchResponse<T>>

Inherited from

Client.sendPatchRequest

Defined in

node_modules/@vonage/server-client/dist/client.d.ts:20

sendPostRequest()
sendPostRequest<T>(url, payload?): Promise<VetchResponse<T>>
Type Parameters

T

Parameters

url: string

payload?

Returns

Promise<VetchResponse<T>>

Inherited from

Client.sendPostRequest

Defined in

node_modules/@vonage/server-client/dist/client.d.ts:23

sendPutRequest()
sendPutRequest<T>(url, payload?): Promise<VetchResponse<T>>
Type Parameters

T

Parameters

url: string

payload?

Returns

Promise<VetchResponse<T>>

Inherited from

Client.sendPutRequest

Defined in

node_modules/@vonage/server-client/dist/client.d.ts:26

sendRequest()
sendRequest<T>(request): Promise<VetchResponse<T>>
Type Parameters

T

Parameters

request: VetchOptions

Returns

Promise<VetchResponse<T>>

Inherited from

Client.sendRequest

Defined in

node_modules/@vonage/server-client/dist/client.d.ts:32

sendRequestWithData()
sendRequestWithData<T>(
   method, 
   url, 
payload?): Promise<VetchResponse<T>>
Type Parameters

T

Parameters

method: HTTPMethods

url: string

payload?

Returns

Promise<VetchResponse<T>>

Inherited from

Client.sendRequestWithData

Defined in

node_modules/@vonage/server-client/dist/client.d.ts:29

updateMediaItem()
updateMediaItem(media): Promise<void>

Updates the information of a specific media item based on the provided data.

Parameters

media: MediaItem

The updated media item data.

Returns

Promise<void>

A promise that resolves once the media item is successfully updated.

Example

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);
Defined in

lib/media.ts:144

Type Aliases

MediaItem

type MediaItem: object;

Represents a media item.

Type declaration

accountId
accountId: string;

The ID of your Nexmo account. This is the same as your API key.

description?
optional description: string;

An optional description of the media file.

etag
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
id: string;

A UUID representing the object.

maxDownloadsAllowed
maxDownloadsAllowed: number;

The maximum number of times the file may be downloaded.

mediaSize
mediaSize: number;

The size of the file in bytes.

metadataPrimary
metadataPrimary: string;

A user-set string containing metadata about the media file.

metadataSecondary
metadataSecondary: string;

A user-set string containing further metadata about the media file.

mimeType
mimeType: string;

The IETF MIME type of the file.

originalFileName
originalFileName: string;

The filename of the object as it was originally uploaded.

public
public: boolean;

Whether the item is available for download without authentication.

storeId
storeId: string;

An internal identifier of how the file is stored.

timeCreated
timeCreated: string;

A timestamp for the time that the file was created.

timeLastUpdated
timeLastUpdated: string;

A timestamp for the time that the file was last modified.

timesDownloaded
timesDownloaded: number;

The number of times the file has been downloaded.

title?
optional title: string;

An optional title for the media file.

Defined in

lib/types/mediaItem.ts:4


MediaItemPageResponse

type MediaItemPageResponse: object;

Represents the response data for a page of media items.

Type declaration

_embedded
_embedded: object;

A collection of media items.

_embedded.media
_embedded.media: MediaItemResponse[];
_links
_links: object & APILinks;

Links to navigate through pages.

Type declaration
first?
optional first: APILink;

Link to the first page.

last?
optional last: APILink;

Link to the last page.

next?
optional next: APILink;

Link to the next page.

prev?
optional prev: APILink;

Link to the previous page.

start?
optional start: APILink;

Link to the start page.

count
count: number;

The total number of records returned by your request.

page_index
page_index: number;

The page_index used in your request.

page_size
page_size: number;

The amount of records returned in this response.

Remarks

Vonage API's will return information using snake_case. This represents the pure response before the client will transform the keys into camelCase.

Defined in

lib/types/Responses/mediaItemResponsePage.ts:11


MediaItemResponse

type MediaItemResponse: object;

Represents the response data for a media item.

Type declaration

accountId
accountId: string;

The ID of your Nexmo account. This is the same as your API key.

etag
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
id: string;

A UUID representing the object.

maxDownloadsAllowed
maxDownloadsAllowed: number;

The maximum number of times the file may be downloaded.

mediaSize
mediaSize: number;

The size of the file in bytes.

metadataPrimary
metadataPrimary: string;

A user-set string containing metadata about the media file.

metadataSecondary
metadataSecondary: string;

A user-set string containing further metadata about the media file.

mimeType
mimeType: string;

The IETF MIME type of the file.

originalFileName
originalFileName: string;

The filename of the object as it was originally uploaded.

public
public: boolean;

Whether the item is available for download without authentication.

storeId
storeId: string;

An internal identifier of how the file is stored.

timeCreated
timeCreated: string;

A timestamp for the time that the file was created.

timeLastUpdated
timeLastUpdated: string;

A timestamp for the time that the file was last modified.

timesDownloaded
timesDownloaded: number;

The number of times the file has been downloaded.

Remarks

Vonage API's will return information using snake_case. This represents the pure response before the client will transform the keys into camelCase.

Defined in

lib/types/Responses/mediaItemResponse.ts:8


MediaParameters

type MediaParameters: object;

Represents parameters for querying media items.

Type declaration

endTime?
optional endTime: string;

Retrieve results created on or before this timestamp.

order?
optional order: "ascending" | "descending";

The order of search results. Must be one of 'ascending' or 'descending'.

pageIndex?
optional pageIndex: number;

Which page to retrieve in pagination.

pageSize?
optional pageSize: number;

How many items at most per page.

startTime?
optional startTime: string;

Retrieve results created on or after this timestamp.

Defined in

lib/types/mediaParameters.ts:4

Clone this wiki locally