> ## Documentation Index
> Fetch the complete documentation index at: https://x-preview-mintlify-24fef6d1.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# CommunitiesClient

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

Client for communities operations

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

## Constructors

### constructor

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

Creates a new communities client instance

#### Parameters

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

#### Returns

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

#### Defined in

[communities/client.ts:102](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/communities/client.ts#L102)

## Methods

### search

▸ **search**(`query`, `options`): `Promise`\<`Response`>

Search Communities
Retrieves a list of Communities matching the specified search query.

#### Parameters

| Name | Type | Description |
| :- | :- | :- |
| `query` | `string` | Query to search communities. |
| `options` | `SearchOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } | - |

#### Returns

`Promise`\<`Response`>

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

#### Defined in

[communities/client.ts:147](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/communities/client.ts#L147)

▸ **search**(`query`, `options?`): `Promise`\<[`Get2CommunitiesSearchResponse`](/xdks/typescript/reference/interfaces/Schemas.Get2CommunitiesSearchResponse)>

#### Parameters

| Name | Type |
| :- | :- |
| `query` | `string` |
| `options?` | `SearchOptions` |

#### Returns

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

#### Defined in

[communities/client.ts:160](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/communities/client.ts#L160)

***

### getById

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

Get Community by ID
Retrieves details of a specific Community by its ID.

#### Parameters

| Name | Type | Description |
| :- | :- | :- |
| `id` | `string` | The ID of the Community. |
| `options` | `GetByIdOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } | - |

#### Returns

`Promise`\<`Response`>

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

#### Defined in

[communities/client.ts:352](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/communities/client.ts#L352)

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

#### Parameters

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

#### Returns

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

#### Defined in

[communities/client.ts:365](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/communities/client.ts#L365)
