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

# HttpClient

> Reference for the HttpClient class in the X API TypeScript SDK. Universal HTTP client for Node.js and browsers used to send requests to the X API.

Universal HTTP client that works in both Node.js and browser environments

## Constructors

### constructor

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

#### Returns

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

#### Defined in

[http-client.ts:43](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/http-client.ts#L43)

## Methods

### createHeaders

▸ **createHeaders**(`init?`): `Headers`

Create a new Headers instance

#### Parameters

| Name    | Type                                       |
| :------ | :----------------------------------------- |
| `init?` | `Record`\<`string`, `string`> \| `Headers` |

#### Returns

`Headers`

#### Defined in

[http-client.ts:99](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/http-client.ts#L99)

***

### request

▸ **request**(`url`, `options?`): `Promise`\<[`HttpResponse`](/xdks/typescript/reference/interfaces/HttpResponse)>

Make an HTTP request

#### Parameters

| Name      | Type                                                                                         |
| :-------- | :------------------------------------------------------------------------------------------- |
| `url`     | `string`                                                                                     |
| `options` | [`HttpClientRequestOptions`](/xdks/typescript/reference/interfaces/HttpClientRequestOptions) |

#### Returns

`Promise`\<[`HttpResponse`](/xdks/typescript/reference/interfaces/HttpResponse)>

#### Defined in

[http-client.ts:106](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/http-client.ts#L106)

***

### get

▸ **get**(`url`, `headers?`): `Promise`\<[`HttpResponse`](/xdks/typescript/reference/interfaces/HttpResponse)>

Make a GET request

#### Parameters

| Name       | Type                          |
| :--------- | :---------------------------- |
| `url`      | `string`                      |
| `headers?` | `Record`\<`string`, `string`> |

#### Returns

`Promise`\<[`HttpResponse`](/xdks/typescript/reference/interfaces/HttpResponse)>

#### Defined in

[http-client.ts:141](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/http-client.ts#L141)

***

### post

▸ **post**(`url`, `body?`, `headers?`): `Promise`\<[`HttpResponse`](/xdks/typescript/reference/interfaces/HttpResponse)>

Make a POST request

#### Parameters

| Name       | Type                          |
| :--------- | :---------------------------- |
| `url`      | `string`                      |
| `body?`    | `string`                      |
| `headers?` | `Record`\<`string`, `string`> |

#### Returns

`Promise`\<[`HttpResponse`](/xdks/typescript/reference/interfaces/HttpResponse)>

#### Defined in

[http-client.ts:151](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/http-client.ts#L151)

***

### put

▸ **put**(`url`, `body?`, `headers?`): `Promise`\<[`HttpResponse`](/xdks/typescript/reference/interfaces/HttpResponse)>

Make a PUT request

#### Parameters

| Name       | Type                          |
| :--------- | :---------------------------- |
| `url`      | `string`                      |
| `body?`    | `string`                      |
| `headers?` | `Record`\<`string`, `string`> |

#### Returns

`Promise`\<[`HttpResponse`](/xdks/typescript/reference/interfaces/HttpResponse)>

#### Defined in

[http-client.ts:162](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/http-client.ts#L162)

***

### delete

▸ **delete**(`url`, `headers?`): `Promise`\<[`HttpResponse`](/xdks/typescript/reference/interfaces/HttpResponse)>

Make a DELETE request

#### Parameters

| Name       | Type                          |
| :--------- | :---------------------------- |
| `url`      | `string`                      |
| `headers?` | `Record`\<`string`, `string`> |

#### Returns

`Promise`\<[`HttpResponse`](/xdks/typescript/reference/interfaces/HttpResponse)>

#### Defined in

[http-client.ts:173](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/http-client.ts#L173)

***

### patch

▸ **patch**(`url`, `body?`, `headers?`): `Promise`\<[`HttpResponse`](/xdks/typescript/reference/interfaces/HttpResponse)>

Make a PATCH request

#### Parameters

| Name       | Type                          |
| :--------- | :---------------------------- |
| `url`      | `string`                      |
| `body?`    | `string`                      |
| `headers?` | `Record`\<`string`, `string`> |

#### Returns

`Promise`\<[`HttpResponse`](/xdks/typescript/reference/interfaces/HttpResponse)>

#### Defined in

[http-client.ts:183](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/http-client.ts#L183)
