> ## 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.

Client for media operations

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)

## Constructors

### constructor

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

Creates a new media client instance

#### Parameters

| Name     | Type                                                  | Description                    |
| :------- | :---------------------------------------------------- | :----------------------------- |
| `client` | [`Client`](/xdks/typescript/reference/classes/Client) | The main X API client instance |

#### Returns

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

#### Defined in

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

## Methods

### getByKey

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

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

#### Parameters

| Name       | Type                                                            | Description         |
| :--------- | :-------------------------------------------------------------- | :------------------ |
| `mediaKey` | `string`                                                        | A single Media Key. |
| `options`  | `GetByKeyOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } | -                   |

#### Returns

`Promise`\<`Response`>

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

#### Defined in

[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)>

#### Parameters

| Name       | Type              |
| :--------- | :---------------- |
| `mediaKey` | `string`          |
| `options?` | `GetByKeyOptions` |

#### Returns

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

#### Defined in

[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.

#### Parameters

| Name      | Type                                                                   | Description                                     |
| :-------- | :--------------------------------------------------------------------- | :---------------------------------------------- |
| `mediaId` | `string`                                                               | Media id for the requested media upload status. |
| `options` | `GetUploadStatusOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } | -                                               |

#### Returns

`Promise`\<`Response`>

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

#### Defined in

[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)>

#### Parameters

| Name       | Type                     |
| :--------- | :----------------------- |
| `mediaId`  | `string`                 |
| `options?` | `GetUploadStatusOptions` |

#### Returns

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

#### Defined in

[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.

#### Parameters

| Name      | Type                                                          |
| :-------- | :------------------------------------------------------------ |
| `options` | `UploadOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } |

#### Returns

`Promise`\<`Response`>

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

#### Defined in

[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)>

#### Parameters

| Name       | Type            |
| :--------- | :-------------- |
| `options?` | `UploadOptions` |

#### Returns

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

#### Defined in

[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.

#### Parameters

| Name          | Type                                                                | Description                                                                       |
| :------------ | :------------------------------------------------------------------ | :-------------------------------------------------------------------------------- |
| `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. The UTC timestamp representing the end of the time range.   |
| `startTime`   | `string`                                                            | YYYY-MM-DDTHH:mm:ssZ. The UTC timestamp representing the start of the time range. |
| `granularity` | `string`                                                            | The granularity for the search counts results.                                    |
| `options`     | `GetAnalyticsOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } | -                                                                                 |

#### Returns

`Promise`\<`Response`>

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

#### Defined in

[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)>

#### Parameters

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

#### Returns

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

#### Defined in

[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.

#### Parameters

| Name      | Type                                                                | Description                                                         |
| :-------- | :------------------------------------------------------------------ | :------------------------------------------------------------------ |
| `id`      | `string`                                                            | The media identifier for the media to perform the append operation. |
| `options` | `AppendUploadOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } | -                                                                   |

#### Returns

`Promise`\<`Response`>

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

#### Defined in

[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)>

#### Parameters

| Name       | Type                  |
| :--------- | :-------------------- |
| `id`       | `string`              |
| `options?` | `AppendUploadOptions` |

#### Returns

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

#### Defined in

[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.

#### Parameters

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

#### Returns

`Promise`\<`Response`>

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

#### Defined in

[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)>

#### Parameters

| Name        | Type               |
| :---------- | :----------------- |
| `mediaKeys` | `any`\[]           |
| `options?`  | `GetByKeysOptions` |

#### Returns

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

#### Defined in

[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.

#### Parameters

| Name      | Type                                                                  |
| :-------- | :-------------------------------------------------------------------- |
| `options` | `CreateMetadataOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } |

#### Returns

`Promise`\<`Response`>

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

#### Defined in

[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)>

#### Parameters

| Name       | Type                    |
| :--------- | :---------------------- |
| `options?` | `CreateMetadataOptions` |

#### Returns

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

#### Defined in

[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.

#### Parameters

| Name                         | Type     | Description                                     |
| :--------------------------- | :------- | :---------------------------------------------- |
| `id`                         | `string` | The media id of the targeted media to finalize. |
| `options`                    | `Object` | -                                               |
| `options.requestOptions`     | `Object` | -                                               |
| `options.requestOptions.raw` | `true`   | -                                               |

#### Returns

`Promise`\<`Response`>

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

#### Defined in

[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)>

#### Parameters

| Name | Type     |
| :--- | :------- |
| `id` | `string` |

#### Returns

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

#### Defined in

[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.

#### Parameters

| Name      | Type                                                                    |
| :-------- | :---------------------------------------------------------------------- |
| `options` | `InitializeUploadOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } |

#### Returns

`Promise`\<`Response`>

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

#### Defined in

[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)>

#### Parameters

| Name       | Type                      |
| :--------- | :------------------------ |
| `options?` | `InitializeUploadOptions` |

#### Returns

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

#### Defined in

[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.

#### Parameters

| Name      | Type                                                                   |
| :-------- | :--------------------------------------------------------------------- |
| `options` | `CreateSubtitlesOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } |

#### Returns

`Promise`\<`Response`>

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

#### Defined in

[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)>

#### Parameters

| Name       | Type                     |
| :--------- | :----------------------- |
| `options?` | `CreateSubtitlesOptions` |

#### Returns

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

#### Defined in

[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.

#### Parameters

| Name      | Type                                                                   |
| :-------- | :--------------------------------------------------------------------- |
| `options` | `DeleteSubtitlesOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } |

#### Returns

`Promise`\<`Response`>

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

#### Defined in

[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)>

#### Parameters

| Name       | Type                     |
| :--------- | :----------------------- |
| `options?` | `DeleteSubtitlesOptions` |

#### Returns

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

#### Defined in

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