> ## Documentation Index
> Fetch the complete documentation index at: https://docs.x.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MediaClient

> Reference for the MediaClient class in the X API TypeScript SDK. Methods, parameters, and return types for the X API v2 media endpoints.

Cliente para operaciones de media

This client provides methods for interacting with the media endpoints
of the X API. It handles authentication, request formatting, and response
parsing for all media related operations.

zeUpload]\(/xdks/typescript/reference/classes/MediaClient#finalizeupload)

* [initializeUpload](/xdks/typescript/reference/classes/MediaClient#initializeupload)
* [createSubtitles](/xdks/typescript/reference/classes/MediaClient#createsubtitles)
* [deleteSubtitles](/xdks/typescript/reference/classes/MediaClient#deletesubtitles)

## Constructores

### constructor

• **new MediaClient**(`client`): [`MediaClient`](/xdks/typescript/reference/classes/MediaClient)

Creates a new media client instance

#### Parámetros

| Nombre   | Tipo                                                  | Descripción                    |
| :------- | :---------------------------------------------------- | :----------------------------- |
| `client` | [`Client`](/xdks/typescript/reference/classes/Client) | The main X API client instance |

#### Devuelve

[`MediaClient`](/xdks/typescript/reference/classes/MediaClient)

#### Definido en

[media/client.ts:250](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/media/client.ts#L250)

## Métodos

### getByKey

▸ **getByKey**(`mediaKey`, `options`): `Promise`\<`Response`>

Get Media by media key
Retrieves details of a specific Media file by its media key.

#### Parámetros

| Nombre     | Tipo                                                            | Descripción         |
| :--------- | :-------------------------------------------------------------- | :------------------ |
| `mediaKey` | `string`                                                        | A single Media Key. |
| `options`  | `GetByKeyOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } | -                   |

#### Devuelve

`Promise`\<`Response`>

Promise resolving to the API response, or raw Response if requestOptions.raw is true

#### Definido en

[media/client.ts:295](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/media/client.ts#L295)

▸ **getByKey**(`mediaKey`, `options?`): `Promise`\<[`Get2MediaMediaKeyResponse`](/xdks/typescript/reference/interfaces/Schemas.Get2MediaMediaKeyResponse)>

#### Parámetros

| Nombre     | Tipo              |
| :--------- | :---------------- |
| `mediaKey` | `string`          |
| `options?` | `GetByKeyOptions` |

#### Devuelve

`Promise`\<[`Get2MediaMediaKeyResponse`](/xdks/typescript/reference/interfaces/Schemas.Get2MediaMediaKeyResponse)>

#### Definido en

[media/client.ts:308](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/media/client.ts#L308)

***

### getUploadStatus

▸ **getUploadStatus**(`mediaId`, `options`): `Promise`\<`Response`>

Get Media upload status
Retrieves the status of a Media upload by its ID.

#### Parámetros

| Nombre    | Tipo                                                                   | Descripción                                     |
| :-------- | :--------------------------------------------------------------------- | :---------------------------------------------- |
| `mediaId` | `string`                                                               | Media id for the requested media upload status. |
| `options` | `GetUploadStatusOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } | -                                               |

#### Devuelve

`Promise`\<`Response`>

Promise resolving to the API response, or raw Response if requestOptions.raw is true

#### Definido en

[media/client.ts:442](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/media/client.ts#L442)

▸ **getUploadStatus**(`mediaId`, `options?`): `Promise`\<[`MediaUploadResponse`](/xdks/typescript/reference/interfaces/Schemas.MediaUploadResponse)>

#### Parámetros

| Nombre     | Tipo                     |
| :--------- | :----------------------- |
| `mediaId`  | `string`                 |
| `options?` | `GetUploadStatusOptions` |

#### Devuelve

`Promise`\<[`MediaUploadResponse`](/xdks/typescript/reference/interfaces/Schemas.MediaUploadResponse)>

#### Definido en

[media/client.ts:455](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/media/client.ts#L455)

***

### upload

▸ **upload**(`options`): `Promise`\<`Response`>

Upload media
Uploads a media file for use in posts or other content.

#### Parámetros

| Nombre    | Tipo                                                          |
| :-------- | :------------------------------------------------------------ |
| `options` | `UploadOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } |

#### Devuelve

`Promise`\<`Response`>

Promise resolving to the API response, or raw Response if requestOptions.raw is true

#### Definido en

[media/client.ts:582](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/media/client.ts#L582)

▸ **upload**(`options?`): `Promise`\<[`MediaUploadResponse`](/xdks/typescript/reference/interfaces/Schemas.MediaUploadResponse)>

#### Parámetros

| Nombre     | Tipo            |
| :--------- | :-------------- |
| `options?` | `UploadOptions` |

#### Devuelve

`Promise`\<[`MediaUploadResponse`](/xdks/typescript/reference/interfaces/Schemas.MediaUploadResponse)>

#### Definido en

[media/client.ts:591](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/media/client.ts#L591)

***

### getAnalytics

▸ **getAnalytics**(`mediaKeys`, `endTime`, `startTime`, `granularity`, `options`): `Promise`\<`Response`>

Get Media analytics
Retrieves analytics data for media.

#### Parámetros

| Nombre        | Tipo                                                                | Descripción                                                                                |
| :------------ | :------------------------------------------------------------------ | :----------------------------------------------------------------------------------------- |
| `mediaKeys`   | `any`\[]                                                            | A comma separated list of Media Keys. Up to 100 are allowed in a single request.           |
| `endTime`     | `string`                                                            | YYYY-MM-DDTHH:mm:ssZ. La marca de tiempo UTC que representa el final del rango de tiempo.  |
| `startTime`   | `string`                                                            | YYYY-MM-DDTHH:mm:ssZ. La marca de tiempo UTC que representa el inicio del rango de tiempo. |
| `granularity` | `string`                                                            | La granularidad para los resultados de conteos de búsqueda.                                |
| `options`     | `GetAnalyticsOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } | -                                                                                          |

#### Devuelve

`Promise`\<`Response`>

Promise resolving to the API response, or raw Response if requestOptions.raw is true

#### Definido en

[media/client.ts:699](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/media/client.ts#L699)

▸ **getAnalytics**(`mediaKeys`, `endTime`, `startTime`, `granularity`, `options?`): `Promise`\<[`MediaAnalytics`](/xdks/typescript/reference/interfaces/Schemas.MediaAnalytics)>

#### Parámetros

| Nombre        | Tipo                  |
| :------------ | :-------------------- |
| `mediaKeys`   | `any`\[]              |
| `endTime`     | `string`              |
| `startTime`   | `string`              |
| `granularity` | `string`              |
| `options?`    | `GetAnalyticsOptions` |

#### Devuelve

`Promise`\<[`MediaAnalytics`](/xdks/typescript/reference/interfaces/Schemas.MediaAnalytics)>

#### Definido en

[media/client.ts:724](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/media/client.ts#L724)

***

### appendUpload

▸ **appendUpload**(`id`, `options`): `Promise`\<`Response`>

Append Media upload
Appends data to a Media upload request.

#### Parámetros

| Nombre    | Tipo                                                                | Descripción                                                         |
| :-------- | :------------------------------------------------------------------ | :------------------------------------------------------------------ |
| `id`      | `string`                                                            | The media identifier for the media to perform the append operation. |
| `options` | `AppendUploadOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } | -                                                                   |

#### Devuelve

`Promise`\<`Response`>

Promise resolving to the API response, or raw Response if requestOptions.raw is true

#### Definido en

[media/client.ts:918](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/media/client.ts#L918)

▸ **appendUpload**(`id`, `options?`): `Promise`\<[`MediaUploadAppendResponse`](/xdks/typescript/reference/interfaces/Schemas.MediaUploadAppendResponse)>

#### Parámetros

| Nombre     | Tipo                  |
| :--------- | :-------------------- |
| `id`       | `string`              |
| `options?` | `AppendUploadOptions` |

#### Devuelve

`Promise`\<[`MediaUploadAppendResponse`](/xdks/typescript/reference/interfaces/Schemas.MediaUploadAppendResponse)>

#### Definido en

[media/client.ts:931](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/media/client.ts#L931)

***

### getByKeys

▸ **getByKeys**(`mediaKeys`, `options`): `Promise`\<`Response`>

Get Media by media keys
Retrieves details of Media files by their media keys.

#### Parámetros

| Nombre      | Tipo                                                             | Descripción                                                                      |
| :---------- | :--------------------------------------------------------------- | :------------------------------------------------------------------------------- |
| `mediaKeys` | `any`\[]                                                         | A comma separated list of Media Keys. Up to 100 are allowed in a single request. |
| `options`   | `GetByKeysOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } | -                                                                                |

#### Devuelve

`Promise`\<`Response`>

Promise resolving to the API response, or raw Response if requestOptions.raw is true

#### Definido en

[media/client.ts:1039](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/media/client.ts#L1039)

▸ **getByKeys**(`mediaKeys`, `options?`): `Promise`\<[`Get2MediaResponse`](/xdks/typescript/reference/interfaces/Schemas.Get2MediaResponse)>

#### Parámetros

| Nombre      | Tipo               |
| :---------- | :----------------- |
| `mediaKeys` | `any`\[]           |
| `options?`  | `GetByKeysOptions` |

#### Devuelve

`Promise`\<[`Get2MediaResponse`](/xdks/typescript/reference/interfaces/Schemas.Get2MediaResponse)>

#### Definido en

[media/client.ts:1052](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/media/client.ts#L1052)

***

### createMetadata

▸ **createMetadata**(`options`): `Promise`\<`Response`>

Create Media metadata
Creates metadata for a Media file.

#### Parámetros

| Nombre    | Tipo                                                                  |
| :-------- | :-------------------------------------------------------------------- |
| `options` | `CreateMetadataOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } |

#### Devuelve

`Promise`\<`Response`>

Promise resolving to the API response, or raw Response if requestOptions.raw is true

#### Definido en

[media/client.ts:1191](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/media/client.ts#L1191)

▸ **createMetadata**(`options?`): `Promise`\<[`MetadataCreateResponse`](/xdks/typescript/reference/interfaces/Schemas.MetadataCreateResponse)>

#### Parámetros

| Nombre     | Tipo                    |
| :--------- | :---------------------- |
| `options?` | `CreateMetadataOptions` |

#### Devuelve

`Promise`\<[`MetadataCreateResponse`](/xdks/typescript/reference/interfaces/Schemas.MetadataCreateResponse)>

#### Definido en

[media/client.ts:1200](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/media/client.ts#L1200)

***

### finalizeUpload

▸ **finalizeUpload**(`id`, `options`): `Promise`\<`Response`>

Finalize Media upload
Finalizes a Media upload request.

#### Parámetros

| Nombre                       | Tipo     | Descripción                                     |
| :--------------------------- | :------- | :---------------------------------------------- |
| `id`                         | `string` | The media id of the targeted media to finalize. |
| `options`                    | `Object` | -                                               |
| `options.requestOptions`     | `Object` | -                                               |
| `options.requestOptions.raw` | `true`   | -                                               |

#### Devuelve

`Promise`\<`Response`>

Promise resolving to the API response, or raw Response if requestOptions.raw is true

#### Definido en

[media/client.ts:1296](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/media/client.ts#L1296)

▸ **finalizeUpload**(`id`): `Promise`\<[`MediaUploadResponse`](/xdks/typescript/reference/interfaces/Schemas.MediaUploadResponse)>

#### Parámetros

| Nombre | Tipo     |
| :----- | :------- |
| `id`   | `string` |

#### Devuelve

`Promise`\<[`MediaUploadResponse`](/xdks/typescript/reference/interfaces/Schemas.MediaUploadResponse)>

#### Definido en

[media/client.ts:1309](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/media/client.ts#L1309)

***

### initializeUpload

▸ **initializeUpload**(`options`): `Promise`\<`Response`>

Initialize media upload
Initializes a media upload.

#### Parámetros

| Nombre    | Tipo                                                                    |
| :-------- | :---------------------------------------------------------------------- |
| `options` | `InitializeUploadOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } |

#### Devuelve

`Promise`\<`Response`>

Promise resolving to the API response, or raw Response if requestOptions.raw is true

#### Definido en

[media/client.ts:1396](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/media/client.ts#L1396)

▸ **initializeUpload**(`options?`): `Promise`\<[`MediaUploadResponse`](/xdks/typescript/reference/interfaces/Schemas.MediaUploadResponse)>

#### Parámetros

| Nombre     | Tipo                      |
| :--------- | :------------------------ |
| `options?` | `InitializeUploadOptions` |

#### Devuelve

`Promise`\<[`MediaUploadResponse`](/xdks/typescript/reference/interfaces/Schemas.MediaUploadResponse)>

#### Definido en

[media/client.ts:1405](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/media/client.ts#L1405)

***

### createSubtitles

▸ **createSubtitles**(`options`): `Promise`\<`Response`>

Create Media subtitles
Creates subtitles for a specific Media file.

#### Parámetros

| Nombre    | Tipo                                                                   |
| :-------- | :--------------------------------------------------------------------- |
| `options` | `CreateSubtitlesOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } |

#### Devuelve

`Promise`\<`Response`>

Promise resolving to the API response, or raw Response if requestOptions.raw is true

#### Definido en

[media/client.ts:1497](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/media/client.ts#L1497)

▸ **createSubtitles**(`options?`): `Promise`\<[`SubtitlesCreateResponse`](/xdks/typescript/reference/interfaces/Schemas.SubtitlesCreateResponse)>

#### Parámetros

| Nombre     | Tipo                     |
| :--------- | :----------------------- |
| `options?` | `CreateSubtitlesOptions` |

#### Devuelve

`Promise`\<[`SubtitlesCreateResponse`](/xdks/typescript/reference/interfaces/Schemas.SubtitlesCreateResponse)>

#### Definido en

[media/client.ts:1506](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/media/client.ts#L1506)

***

### deleteSubtitles

▸ **deleteSubtitles**(`options`): `Promise`\<`Response`>

Delete Media subtitles
Deletes subtitles for a specific Media file.

#### Parámetros

| Nombre    | Tipo                                                                   |
| :-------- | :--------------------------------------------------------------------- |
| `options` | `DeleteSubtitlesOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } |

#### Devuelve

`Promise`\<`Response`>

Promise resolving to the API response, or raw Response if requestOptions.raw is true

#### Definido en

[media/client.ts:1598](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/media/client.ts#L1598)

▸ **deleteSubtitles**(`options?`): `Promise`\<[`SubtitlesDeleteResponse`](/xdks/typescript/reference/interfaces/Schemas.SubtitlesDeleteResponse)>

#### Parámetros

| Nombre     | Tipo                     |
| :--------- | :----------------------- |
| `options?` | `DeleteSubtitlesOptions` |

#### Devuelve

`Promise`\<[`SubtitlesDeleteResponse`](/xdks/typescript/reference/interfaces/Schemas.SubtitlesDeleteResponse)>

#### Definido en

[media/client.ts:1607](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/media/client.ts#L1607)
