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

# StreamClient

> Methods for X API v2 Stream endpoints.

Access **Stream** endpoints via `client.stream()` (`StreamClient`).

## Methods

| Method | Endpoint | Behavior | Summary |
| :- | :- | :- | :- |
| [`activity`](#activity) | `GET /2/activity/stream` | Streaming | Activity Stream |
| [`getRuleCounts`](#getrulecounts) | `GET /2/tweets/search/stream/rules/counts` | Standard | Get Stream Rule Counts |
| [`getRules`](#getrules) | `GET /2/tweets/search/stream/rules` | Paginated | Get Stream Rules |
| [`labelsCompliance`](#labelscompliance) | `GET /2/tweets/label/stream` | Streaming | Stream Post Labels |
| [`likesCompliance`](#likescompliance) | `GET /2/likes/compliance/stream` | Streaming | Stream Likes Compliance Data |
| [`likesFirehose`](#likesfirehose) | `GET /2/likes/firehose/stream` | Streaming | Stream All Likes |
| [`likesSample10`](#likessample10) | `GET /2/likes/sample10/stream` | Streaming | Stream Sampled Likes |
| [`posts`](#posts) | `GET /2/tweets/search/stream` | Streaming | Stream Filtered Posts |
| [`postsCompliance`](#postscompliance) | `GET /2/tweets/compliance/stream` | Streaming | Stream Posts Compliance Data |
| [`postsFirehose`](#postsfirehose) | `GET /2/tweets/firehose/stream` | Streaming | Stream All Posts |
| [`postsFirehoseEn`](#postsfirehoseen) | `GET /2/tweets/firehose/stream/lang/en` | Streaming | Stream English Posts |
| [`postsFirehoseJa`](#postsfirehoseja) | `GET /2/tweets/firehose/stream/lang/ja` | Streaming | Stream Japanese Posts |
| [`postsFirehoseKo`](#postsfirehoseko) | `GET /2/tweets/firehose/stream/lang/ko` | Streaming | Stream Korean Posts |
| [`postsFirehosePt`](#postsfirehosept) | `GET /2/tweets/firehose/stream/lang/pt` | Streaming | Stream Portuguese Posts |
| [`postsSample`](#postssample) | `GET /2/tweets/sample/stream` | Streaming | Stream Sampled Posts |
| [`postsSample10`](#postssample10) | `GET /2/tweets/sample10/stream` | Streaming | Stream 10% Sampled Posts |
| [`updateRules`](#updaterules) | `POST /2/tweets/search/stream/rules` | Standard | Update Stream Rules |
| [`usersCompliance`](#userscompliance) | `GET /2/users/compliance/stream` | Streaming | Stream Users Compliance Data |

## `activity`

GET `/2/activity/stream` Streaming

**Activity Stream**

Stream of X Activities

```java theme={null}
import com.x.xdk.XClient;

XClient client = XClient.builder()
    .bearerToken(System.getenv("X_BEARER_TOKEN"))
    .build();

try (var stream = client.stream().activity()) {
    for (var event : stream) {
        System.out.println(event);
    }
}
```

### Parameters

**Optional parameters (StreamClient.ActivityOptions — 3)**

**options.backfillMinutes** `Integer`

The number of minutes of backfill requested.

**options.startTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The earliest UTC timestamp from which the activities will be provided.

**options.endTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The latest UTC timestamp from which the activities will be provided.

**Returns:** `EventStream<Schemas.ActivityStreamResponse>`

***

## `getRuleCounts`

GET `/2/tweets/search/stream/rules/counts`

**Get Stream Rule Counts**

Retrieves the count of rules in the active rule set for the filtered stream.

```java theme={null}
import com.x.xdk.XClient;

XClient client = XClient.builder()
    .bearerToken(System.getenv("X_BEARER_TOKEN"))
    .build();

var response = client.stream().getRuleCounts();
System.out.println(response);
```

### Parameters

**Optional parameters (StreamClient.GetRuleCountsOptions — 1)**

**options.rulesCountFields** `String`

`rules_count.fields` (query parameter).

**Returns:** `Schemas.GetRuleCountsResponse`

***

## `getRules`

GET `/2/tweets/search/stream/rules` Paginated

**Get Stream Rules**

Returns the active filtered-stream rules for the authenticated app. Provide `ids` to fetch specific rules; omit it to list all rules.

```java theme={null}
import com.x.xdk.XClient;

XClient client = XClient.builder()
    .bearerToken(System.getenv("X_BEARER_TOKEN"))
    .build();

for (var page : client.stream().getRulesPages()) {
    System.out.println(page);
}
```

### Parameters

**Optional parameters (StreamClient.GetRulesOptions — 3)**

**options.ids** `List\<String\>`

`ids` (query parameter).

**options.maxResults** `Integer`

`max_results` (query parameter).

**options.paginationToken** `String`

A base32hex-encoded pagination token that decodes to 8 bytes.

**Returns:** `Schemas.GetRulesResponse` (use `getRulesPages(...)` for automatic `Paginator<...>` iteration)

***

## `labelsCompliance`

GET `/2/tweets/label/stream` Streaming

**Stream Post Labels**

Streams all labeling events applied to Posts.

```java theme={null}
import com.x.xdk.XClient;

XClient client = XClient.builder()
    .bearerToken(System.getenv("X_BEARER_TOKEN"))
    .build();

try (var stream = client.stream().labelsCompliance()) {
    for (var event : stream) {
        System.out.println(event);
    }
}
```

### Parameters

**Optional parameters (StreamClient.LabelsComplianceOptions — 3)**

**options.backfillMinutes** `Integer`

The number of minutes of backfill requested.

**options.startTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The earliest UTC timestamp from which the Post labels will be provided.

**options.endTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The latest UTC timestamp from which the Post labels will be provided.

**Returns:** `EventStream<JsonNode>`

***

## `likesCompliance`

GET `/2/likes/compliance/stream` Streaming

**Stream Likes Compliance Data**

Streams all compliance data related to Likes for Users.

```java theme={null}
import com.x.xdk.XClient;

XClient client = XClient.builder()
    .bearerToken(System.getenv("X_BEARER_TOKEN"))
    .build();

try (var stream = client.stream().likesCompliance()) {
    for (var event : stream) {
        System.out.println(event);
    }
}
```

### Parameters

**Optional parameters (StreamClient.LikesComplianceOptions — 3)**

**options.backfillMinutes** `Integer`

The number of minutes of backfill requested.

**options.startTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The earliest UTC timestamp from which the Likes Compliance events will be provided.

**options.endTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The latest UTC timestamp from which the Likes Compliance events will be provided.

**Returns:** `EventStream<JsonNode>`

***

## `likesFirehose`

GET `/2/likes/firehose/stream` Streaming

**Stream All Likes**

Streams all public Likes in real-time.

```java theme={null}
import com.x.xdk.XClient;

XClient client = XClient.builder()
    .bearerToken(System.getenv("X_BEARER_TOKEN"))
    .build();

try (var stream = client.stream().likesFirehose(1)) {
    for (var event : stream) {
        System.out.println(event);
    }
}
```

### Parameters

**partition** `Integer` *required*

The partition number.

**Optional parameters (StreamClient.LikesFirehoseOptions — 8)**

**options.backfillMinutes** `Integer`

The number of minutes of backfill requested.

**options.startTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The earliest UTC timestamp to which the Likes will be provided.

**options.endTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The latest UTC timestamp to which the Posts will be provided.

**options.likeWithTweetAuthorFields** `List\<String\>`

A comma separated list of LikeWithTweetAuthor fields to display.

**options.expansions** `List\<String\>`

A comma separated list of fields to expand.

**options.mediaFields** `List\<String\>`

A comma separated list of Media fields to display.

**options.userFields** `List\<String\>`

A comma separated list of User fields to display.

**options.tweetFields** `List\<String\>`

A comma separated list of Tweet fields to display.

**Returns:** `EventStream<Schemas.StreamLikesFirehoseResponse>`

***

## `likesSample10`

GET `/2/likes/sample10/stream` Streaming

**Stream Sampled Likes**

Streams a 10% sample of public Likes in real-time.

```java theme={null}
import com.x.xdk.XClient;

XClient client = XClient.builder()
    .bearerToken(System.getenv("X_BEARER_TOKEN"))
    .build();

try (var stream = client.stream().likesSample10(1)) {
    for (var event : stream) {
        System.out.println(event);
    }
}
```

### Parameters

**partition** `Integer` *required*

The partition number.

**Optional parameters (StreamClient.LikesSample10Options — 8)**

**options.backfillMinutes** `Integer`

The number of minutes of backfill requested.

**options.startTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The earliest UTC timestamp to which the Likes will be provided.

**options.endTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The latest UTC timestamp to which the Posts will be provided.

**options.likeWithTweetAuthorFields** `List\<String\>`

A comma separated list of LikeWithTweetAuthor fields to display.

**options.expansions** `List\<String\>`

A comma separated list of fields to expand.

**options.mediaFields** `List\<String\>`

A comma separated list of Media fields to display.

**options.userFields** `List\<String\>`

A comma separated list of User fields to display.

**options.tweetFields** `List\<String\>`

A comma separated list of Tweet fields to display.

**Returns:** `EventStream<Schemas.StreamLikesSample10Response>`

***

## `posts`

GET `/2/tweets/search/stream` Streaming

**Stream Filtered Posts**

Streams Posts in real-time matching the active rule set.

```java theme={null}
import com.x.xdk.XClient;

XClient client = XClient.builder()
    .bearerToken(System.getenv("X_BEARER_TOKEN"))
    .build();

try (var stream = client.stream().posts()) {
    for (var event : stream) {
        System.out.println(event);
    }
}
```

### Parameters

**Optional parameters (StreamClient.PostsOptions — 9)**

**options.backfillMinutes** `Integer`

The number of minutes of backfill requested.

**options.startTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The earliest UTC timestamp to which the Posts will be provided.

**options.endTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The latest UTC timestamp to which the Posts will be provided.

**options.tweetFields** `List\<String\>`

A comma separated list of Tweet fields to display.

**options.expansions** `List\<String\>`

A comma separated list of fields to expand.

**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.userFields** `List\<String\>`

A comma separated list of User fields to display.

**options.placeFields** `List\<String\>`

A comma separated list of Place fields to display.

**Returns:** `EventStream<Schemas.StreamPostsResponse>`

***

## `postsCompliance`

GET `/2/tweets/compliance/stream` Streaming

**Stream Posts Compliance Data**

Streams all compliance data related to Posts.

```java theme={null}
import com.x.xdk.XClient;

XClient client = XClient.builder()
    .bearerToken(System.getenv("X_BEARER_TOKEN"))
    .build();

try (var stream = client.stream().postsCompliance(1)) {
    for (var event : stream) {
        System.out.println(event);
    }
}
```

### Parameters

**partition** `Integer` *required*

The partition number.

**Optional parameters (StreamClient.PostsComplianceOptions — 3)**

**options.backfillMinutes** `Integer`

The number of minutes of backfill requested.

**options.startTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The earliest UTC timestamp from which the Post Compliance events will be provided.

**options.endTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The latest UTC timestamp from which the Post Compliance events will be provided.

**Returns:** `EventStream<JsonNode>`

***

## `postsFirehose`

GET `/2/tweets/firehose/stream` Streaming

**Stream All Posts**

Streams all public Posts in real-time.

```java theme={null}
import com.x.xdk.XClient;

XClient client = XClient.builder()
    .bearerToken(System.getenv("X_BEARER_TOKEN"))
    .build();

try (var stream = client.stream().postsFirehose(1)) {
    for (var event : stream) {
        System.out.println(event);
    }
}
```

### Parameters

**partition** `Integer` *required*

The partition number.

**Optional parameters (StreamClient.PostsFirehoseOptions — 9)**

**options.backfillMinutes** `Integer`

The number of minutes of backfill requested.

**options.tweetFields** `List\<String\>`

A comma separated list of Tweet fields to display.

**options.expansions** `List\<String\>`

A comma separated list of fields to expand.

**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.userFields** `List\<String\>`

A comma separated list of User fields to display.

**options.placeFields** `List\<String\>`

A comma separated list of Place fields to display.

**options.startTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The earliest UTC timestamp to which the Posts will be provided.

**options.endTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The latest UTC timestamp to which the Posts will be provided.

**Returns:** `EventStream<Schemas.StreamPostsFirehoseResponse>`

***

## `postsFirehoseEn`

GET `/2/tweets/firehose/stream/lang/en` Streaming

**Stream English Posts**

Streams all public English-language Posts in real-time.

```java theme={null}
import com.x.xdk.XClient;

XClient client = XClient.builder()
    .bearerToken(System.getenv("X_BEARER_TOKEN"))
    .build();

try (var stream = client.stream().postsFirehoseEn(1)) {
    for (var event : stream) {
        System.out.println(event);
    }
}
```

### Parameters

**partition** `Integer` *required*

The partition number.

**Optional parameters (StreamClient.PostsFirehoseEnOptions — 9)**

**options.backfillMinutes** `Integer`

The number of minutes of backfill requested.

**options.tweetFields** `List\<String\>`

A comma separated list of Tweet fields to display.

**options.expansions** `List\<String\>`

A comma separated list of fields to expand.

**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.userFields** `List\<String\>`

A comma separated list of User fields to display.

**options.placeFields** `List\<String\>`

A comma separated list of Place fields to display.

**options.startTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The earliest UTC timestamp to which the Posts will be provided.

**options.endTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The latest UTC timestamp to which the Posts will be provided.

**Returns:** `EventStream<Schemas.StreamPostsFirehoseEnResponse>`

***

## `postsFirehoseJa`

GET `/2/tweets/firehose/stream/lang/ja` Streaming

**Stream Japanese Posts**

Streams all public Japanese-language Posts in real-time.

```java theme={null}
import com.x.xdk.XClient;

XClient client = XClient.builder()
    .bearerToken(System.getenv("X_BEARER_TOKEN"))
    .build();

try (var stream = client.stream().postsFirehoseJa(1)) {
    for (var event : stream) {
        System.out.println(event);
    }
}
```

### Parameters

**partition** `Integer` *required*

The partition number.

**Optional parameters (StreamClient.PostsFirehoseJaOptions — 9)**

**options.backfillMinutes** `Integer`

The number of minutes of backfill requested.

**options.tweetFields** `List\<String\>`

A comma separated list of Tweet fields to display.

**options.expansions** `List\<String\>`

A comma separated list of fields to expand.

**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.userFields** `List\<String\>`

A comma separated list of User fields to display.

**options.placeFields** `List\<String\>`

A comma separated list of Place fields to display.

**options.startTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The earliest UTC timestamp to which the Posts will be provided.

**options.endTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The latest UTC timestamp to which the Posts will be provided.

**Returns:** `EventStream<Schemas.StreamPostsFirehoseJaResponse>`

***

## `postsFirehoseKo`

GET `/2/tweets/firehose/stream/lang/ko` Streaming

**Stream Korean Posts**

Streams all public Korean-language Posts in real-time.

```java theme={null}
import com.x.xdk.XClient;

XClient client = XClient.builder()
    .bearerToken(System.getenv("X_BEARER_TOKEN"))
    .build();

try (var stream = client.stream().postsFirehoseKo(1)) {
    for (var event : stream) {
        System.out.println(event);
    }
}
```

### Parameters

**partition** `Integer` *required*

The partition number.

**Optional parameters (StreamClient.PostsFirehoseKoOptions — 9)**

**options.backfillMinutes** `Integer`

The number of minutes of backfill requested.

**options.tweetFields** `List\<String\>`

A comma separated list of Tweet fields to display.

**options.expansions** `List\<String\>`

A comma separated list of fields to expand.

**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.userFields** `List\<String\>`

A comma separated list of User fields to display.

**options.placeFields** `List\<String\>`

A comma separated list of Place fields to display.

**options.startTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The earliest UTC timestamp to which the Posts will be provided.

**options.endTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The latest UTC timestamp to which the Posts will be provided.

**Returns:** `EventStream<Schemas.StreamPostsFirehoseKoResponse>`

***

## `postsFirehosePt`

GET `/2/tweets/firehose/stream/lang/pt` Streaming

**Stream Portuguese Posts**

Streams all public Portuguese-language Posts in real-time.

```java theme={null}
import com.x.xdk.XClient;

XClient client = XClient.builder()
    .bearerToken(System.getenv("X_BEARER_TOKEN"))
    .build();

try (var stream = client.stream().postsFirehosePt(1)) {
    for (var event : stream) {
        System.out.println(event);
    }
}
```

### Parameters

**partition** `Integer` *required*

The partition number.

**Optional parameters (StreamClient.PostsFirehosePtOptions — 9)**

**options.backfillMinutes** `Integer`

The number of minutes of backfill requested.

**options.tweetFields** `List\<String\>`

A comma separated list of Tweet fields to display.

**options.expansions** `List\<String\>`

A comma separated list of fields to expand.

**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.userFields** `List\<String\>`

A comma separated list of User fields to display.

**options.placeFields** `List\<String\>`

A comma separated list of Place fields to display.

**options.startTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The earliest UTC timestamp to which the Posts will be provided.

**options.endTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The latest UTC timestamp to which the Posts will be provided.

**Returns:** `EventStream<Schemas.StreamPostsFirehosePtResponse>`

***

## `postsSample`

GET `/2/tweets/sample/stream` Streaming

**Stream Sampled Posts**

Streams a 1% sample of public Posts in real-time.

```java theme={null}
import com.x.xdk.XClient;

XClient client = XClient.builder()
    .bearerToken(System.getenv("X_BEARER_TOKEN"))
    .build();

try (var stream = client.stream().postsSample()) {
    for (var event : stream) {
        System.out.println(event);
    }
}
```

### Parameters

**Optional parameters (StreamClient.PostsSampleOptions — 7)**

**options.backfillMinutes** `Integer`

The number of minutes of backfill requested.

**options.tweetFields** `List\<String\>`

A comma separated list of Tweet fields to display.

**options.expansions** `List\<String\>`

A comma separated list of fields to expand.

**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.userFields** `List\<String\>`

A comma separated list of User fields to display.

**options.placeFields** `List\<String\>`

A comma separated list of Place fields to display.

**Returns:** `EventStream<Schemas.StreamPostsSampleResponse>`

***

## `postsSample10`

GET `/2/tweets/sample10/stream` Streaming

**Stream 10% Sampled Posts**

Streams a 10% sample of public Posts in real-time.

```java theme={null}
import com.x.xdk.XClient;

XClient client = XClient.builder()
    .bearerToken(System.getenv("X_BEARER_TOKEN"))
    .build();

try (var stream = client.stream().postsSample10(1)) {
    for (var event : stream) {
        System.out.println(event);
    }
}
```

### Parameters

**partition** `Integer` *required*

The partition number.

**Optional parameters (StreamClient.PostsSample10Options — 9)**

**options.backfillMinutes** `Integer`

The number of minutes of backfill requested.

**options.tweetFields** `List\<String\>`

A comma separated list of Tweet fields to display.

**options.expansions** `List\<String\>`

A comma separated list of fields to expand.

**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.userFields** `List\<String\>`

A comma separated list of User fields to display.

**options.placeFields** `List\<String\>`

A comma separated list of Place fields to display.

**options.startTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The earliest UTC timestamp to which the Posts will be provided.

**options.endTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The latest UTC timestamp to which the Posts will be provided.

**Returns:** `EventStream<Schemas.StreamPostsSample10Response>`

***

## `updateRules`

POST `/2/tweets/search/stream/rules`

**Update Stream Rules**

Adds or deletes rules from the active rule set for the filtered stream. Exactly one of `add`, `delete`, or `?delete_all=true` must be specified. Use `?dry_run=true` to validate without committing.

```java theme={null}
import com.x.xdk.Schemas;
import com.x.xdk.XClient;

XClient client = XClient.builder()
    .bearerToken(System.getenv("X_BEARER_TOKEN"))
    .build();

var response = client.stream().updateRules(new Schemas.UpdateRulesRequest());
System.out.println(response);
```

### Parameters

**body** `Schemas.UpdateRulesRequest` *required*

Request payload.

**Optional parameters (StreamClient.UpdateRulesOptions — 2)**

**options.dryRun** `Boolean`

`dry_run` (query parameter).

**options.deleteAll** `Boolean`

`delete_all` (query parameter).

**Returns:** `Schemas.UpdateRulesResponse`

***

## `usersCompliance`

GET `/2/users/compliance/stream` Streaming

**Stream Users Compliance Data**

Streams all compliance data related to Users.

```java theme={null}
import com.x.xdk.XClient;

XClient client = XClient.builder()
    .bearerToken(System.getenv("X_BEARER_TOKEN"))
    .build();

try (var stream = client.stream().usersCompliance(1)) {
    for (var event : stream) {
        System.out.println(event);
    }
}
```

### Parameters

**partition** `Integer` *required*

The partition number.

**Optional parameters (StreamClient.UsersComplianceOptions — 3)**

**options.backfillMinutes** `Integer`

The number of minutes of backfill requested.

**options.startTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The earliest UTC timestamp from which the User Compliance events will be provided.

**options.endTime** `String`

YYYY-MM-DDTHH:mm:ssZ. The latest UTC timestamp from which the User Compliance events will be provided.

**Returns:** `EventStream<JsonNode>`

***
