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

# SpacesClient

> Methods for X API v2 Spaces endpoints.

Access **Spaces** endpoints via `client.Spaces` (`SpacesClient`).

## Methods

| Method | Endpoint | Behavior | Summary |
| :- | :- | :- | :- |
| [`GetBuyersAsync`](#getbuyersasync) | `GET /2/spaces/{id}/buyers` | Paginated | Get Space Ticket Buyers |
| [`GetByCreatorIdsAsync`](#getbycreatoridsasync) | `GET /2/spaces/by/creator_ids` | Standard | Get Spaces by Creator IDs |
| [`GetByIdAsync`](#getbyidasync) | `GET /2/spaces/{id}` | Standard | Get Space by ID |
| [`GetByIdsAsync`](#getbyidsasync) | `GET /2/spaces` | Standard | Get Spaces by IDs |
| [`GetPostsAsync`](#getpostsasync) | `GET /2/spaces/{id}/tweets` | Paginated | Get Space Posts |
| [`SearchAsync`](#searchasync) | `GET /2/spaces/search` | Standard | Search Spaces |

## `GetBuyersAsync`

GET `/2/spaces/{id}/buyers` Paginated

**Get Space Ticket Buyers**

Retrieves a list of Users who purchased tickets to a specific Space by its ID.

```csharp theme={null}
using System;
using Xdk;

using var client = new XClient(new XClientOptions
{
    AccessToken = Environment.GetEnvironmentVariable("X_ACCESS_TOKEN"),
});

await foreach (var page in client.Spaces.GetBuyersPages("1YqKDqWLPPlGV"))
{
    Console.WriteLine(page);
}
```

### Parameters

**id** `string` *required*

`id` (path parameter).

**Optional parameters (SpacesClient.GetBuyersOptions — 5)**

**options.MaxResults** `int`

`max_results` (query parameter).

**options.PaginationToken** `string`

A base32hex-encoded pagination token.

**options.UserFields** `List\<string\>`

A comma separated list of User fields to display.

**options.Expansions** `List\<string\>`

A comma separated list of fields to expand.

**options.PostFields** `List\<string\>`

A comma separated list of Post fields to display.

**Returns:** `Task<GetSpacesBuyersResponse>` (use `GetBuyersPages(...)` for `IAsyncEnumerable` page iteration)

***

## `GetByCreatorIdsAsync`

GET `/2/spaces/by/creator_ids`

**Get Spaces by Creator IDs**

Retrieves details of Spaces created by specified User IDs.

```csharp theme={null}
using System;
using System.Collections.Generic;
using Xdk;

using var client = new XClient(new XClientOptions
{
    BearerToken = Environment.GetEnvironmentVariable("X_BEARER_TOKEN"),
});

var response = await client.Spaces.GetByCreatorIdsAsync(new List<string> { "2244994945" });
Console.WriteLine(response);
```

### Parameters

**userIds** `List\<string\>` *required*

`user_ids` (query parameter).

**Optional parameters (SpacesClient.GetByCreatorIdsOptions — 4)**

**options.SpaceFields** `List\<string\>`

A comma separated list of Space fields to display.

**options.Expansions** `List\<string\>`

A comma separated list of fields to expand.

**options.UserFields** `List\<string\>`

A comma separated list of User fields to display.

**options.TopicFields** `List\<string\>`

A comma separated list of Topic fields to display.

**Returns:** `Task<GetSpacesByCreatorIdsResponse>`

***

## `GetByIdAsync`

GET `/2/spaces/{id}`

**Get Space by ID**

Retrieves details of a specific Space by its ID.

```csharp theme={null}
using System;
using Xdk;

using var client = new XClient(new XClientOptions
{
    BearerToken = Environment.GetEnvironmentVariable("X_BEARER_TOKEN"),
});

var response = await client.Spaces.GetByIdAsync("1YqKDqWLPPlGV");
Console.WriteLine(response);
```

### Parameters

**id** `string` *required*

`id` (path parameter).

**Optional parameters (SpacesClient.GetByIdOptions — 4)**

**options.SpaceFields** `List\<string\>`

A comma separated list of Space fields to display.

**options.Expansions** `List\<string\>`

A comma separated list of fields to expand.

**options.UserFields** `List\<string\>`

A comma separated list of User fields to display.

**options.TopicFields** `List\<string\>`

A comma separated list of Topic fields to display.

**Returns:** `Task<GetSpacesByIdResponse>`

***

## `GetByIdsAsync`

GET `/2/spaces`

**Get Spaces by IDs**

Retrieves details of multiple Spaces by their IDs.

```csharp theme={null}
using System;
using System.Collections.Generic;
using Xdk;

using var client = new XClient(new XClientOptions
{
    BearerToken = Environment.GetEnvironmentVariable("X_BEARER_TOKEN"),
});

var response = await client.Spaces.GetByIdsAsync(new List<string> { "1YqKDqWLPPlGV" });
Console.WriteLine(response);
```

### Parameters

**ids** `List\<string\>` *required*

`ids` (query parameter).

**Optional parameters (SpacesClient.GetByIdsOptions — 4)**

**options.SpaceFields** `List\<string\>`

A comma separated list of Space fields to display.

**options.Expansions** `List\<string\>`

A comma separated list of fields to expand.

**options.UserFields** `List\<string\>`

A comma separated list of User fields to display.

**options.TopicFields** `List\<string\>`

A comma separated list of Topic fields to display.

**Returns:** `Task<GetSpacesByIdsResponse>`

***

## `GetPostsAsync`

GET `/2/spaces/{id}/tweets` Paginated

**Get Space Posts**

Retrieves a list of Posts shared in a specific Space by its ID.

```csharp theme={null}
using System;
using Xdk;

using var client = new XClient(new XClientOptions
{
    BearerToken = Environment.GetEnvironmentVariable("X_BEARER_TOKEN"),
});

await foreach (var page in client.Spaces.GetPostsPages("1YqKDqWLPPlGV"))
{
    Console.WriteLine(page);
}
```

### Parameters

**id** `string` *required*

`id` (path parameter).

**Optional parameters (SpacesClient.GetPostsOptions — 8)**

**options.MaxResults** `int`

`max_results` (query parameter).

**options.PaginationToken** `string`

A base32hex-encoded pagination token.

**options.PostFields** `List\<string\>`

A comma separated list of Post fields to display.

**options.Expansions** `List\<string\>`

A comma separated list of fields to expand.

**options.UserFields** `List\<string\>`

A comma separated list of User fields to display.

**options.MediaFields** `List\<string\>`

A comma separated list of Media fields to display.

**options.PollFields** `List\<string\>`

A comma separated list of Poll fields to display.

**options.PlaceFields** `List\<string\>`

A comma separated list of Place fields to display.

**Returns:** `Task<GetSpacesPostsResponse>` (use `GetPostsPages(...)` for `IAsyncEnumerable` page iteration)

***

## `SearchAsync`

GET `/2/spaces/search`

**Search Spaces**

Retrieves a list of Spaces matching the specified search query.

```csharp theme={null}
using System;
using Xdk;

using var client = new XClient(new XClientOptions
{
    BearerToken = Environment.GetEnvironmentVariable("X_BEARER_TOKEN"),
});

var response = await client.Spaces.SearchAsync("from:XDevelopers");
Console.WriteLine(response);
```

### Parameters

**query** `string` *required*

`query` (query parameter).

**Optional parameters (SpacesClient.SearchOptions — 6)**

**options.State** `string`

`state` (query parameter).

**options.MaxResults** `int`

`max_results` (query parameter).

**options.SpaceFields** `List\<string\>`

A comma separated list of Space fields to display.

**options.Expansions** `List\<string\>`

A comma separated list of fields to expand.

**options.UserFields** `List\<string\>`

A comma separated list of User fields to display.

**options.TopicFields** `List\<string\>`

A comma separated list of Topic fields to display.

**Returns:** `Task<SearchSpacesResponse>`

***
