> ## 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 |
| [`get_rule_counts`](#get_rule_counts) | `GET /2/tweets/search/stream/rules/counts` | Standard | Get Stream Rule Counts |
| [`get_rules`](#get_rules) | `GET /2/tweets/search/stream/rules` | Paginated | Get Stream Rules |
| [`labels_compliance`](#labels_compliance) | `GET /2/tweets/label/stream` | Streaming | Stream Post Labels |
| [`likes_compliance`](#likes_compliance) | `GET /2/likes/compliance/stream` | Streaming | Stream Likes Compliance Data |
| [`likes_firehose`](#likes_firehose) | `GET /2/likes/firehose/stream` | Streaming | Stream All Likes |
| [`likes_sample10`](#likes_sample10) | `GET /2/likes/sample10/stream` | Streaming | Stream Sampled Likes |
| [`posts`](#posts) | `GET /2/tweets/search/stream` | Streaming | Stream Filtered Posts |
| [`posts_compliance`](#posts_compliance) | `GET /2/tweets/compliance/stream` | Streaming | Stream Posts Compliance Data |
| [`posts_firehose`](#posts_firehose) | `GET /2/tweets/firehose/stream` | Streaming | Stream All Posts |
| [`posts_firehose_en`](#posts_firehose_en) | `GET /2/tweets/firehose/stream/lang/en` | Streaming | Stream English Posts |
| [`posts_firehose_ja`](#posts_firehose_ja) | `GET /2/tweets/firehose/stream/lang/ja` | Streaming | Stream Japanese Posts |
| [`posts_firehose_ko`](#posts_firehose_ko) | `GET /2/tweets/firehose/stream/lang/ko` | Streaming | Stream Korean Posts |
| [`posts_firehose_pt`](#posts_firehose_pt) | `GET /2/tweets/firehose/stream/lang/pt` | Streaming | Stream Portuguese Posts |
| [`posts_sample`](#posts_sample) | `GET /2/tweets/sample/stream` | Streaming | Stream Sampled Posts |
| [`posts_sample10`](#posts_sample10) | `GET /2/tweets/sample10/stream` | Streaming | Stream 10% Sampled Posts |
| [`update_rules`](#update_rules) | `POST /2/tweets/search/stream/rules` | Standard | Update Stream Rules |
| [`users_compliance`](#users_compliance) | `GET /2/users/compliance/stream` | Streaming | Stream Users Compliance Data |

## `activity`

GET `/2/activity/stream` Streaming

**Activity Stream**

Stream of X Activities

```ruby theme={null}
require "xdk"

client = Xdk::Client.new(bearer_token: ENV.fetch("X_BEARER_TOKEN"))

client.stream.activity do |event|
  puts event
end
```

### Parameters

**Optional keyword arguments (3)**

**backfill\_minutes** `Integer`

The number of minutes of backfill requested.

**start\_time** `String`

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

**end\_time** `String`

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

**Returns:** `Enumerator<Hash>`

***

## `get_rule_counts`

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.

```ruby theme={null}
require "xdk"

client = Xdk::Client.new(bearer_token: ENV.fetch("X_BEARER_TOKEN"))

response = client.stream.get_rule_counts
puts response
```

### Parameters

**Optional keyword arguments (1)**

**rules\_count\_fields** `String`

`rules_count.fields` (query parameter).

**Returns:** `Hash`

***

## `get_rules`

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.

```ruby theme={null}
require "xdk"

client = Xdk::Client.new(bearer_token: ENV.fetch("X_BEARER_TOKEN"))

client.stream.get_rules.each do |page|
  puts page["data"]
end
```

### Parameters

**Optional keyword arguments (3)**

**ids** `Array\<String\>`

`ids` (query parameter).

**max\_results** `Integer`

`max_results` (query parameter).

**pagination\_token** `String`

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

**Returns:** `Enumerator<Hash>`

***

## `labels_compliance`

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

**Stream Post Labels**

Streams all labeling events applied to Posts.

```ruby theme={null}
require "xdk"

client = Xdk::Client.new(bearer_token: ENV.fetch("X_BEARER_TOKEN"))

client.stream.labels_compliance do |event|
  puts event
end
```

### Parameters

**Optional keyword arguments (3)**

**backfill\_minutes** `Integer`

The number of minutes of backfill requested.

**start\_time** `String`

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

**end\_time** `String`

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

**Returns:** `Enumerator<Hash>`

***

## `likes_compliance`

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

**Stream Likes Compliance Data**

Streams all compliance data related to Likes for Users.

```ruby theme={null}
require "xdk"

client = Xdk::Client.new(bearer_token: ENV.fetch("X_BEARER_TOKEN"))

client.stream.likes_compliance do |event|
  puts event
end
```

### Parameters

**Optional keyword arguments (3)**

**backfill\_minutes** `Integer`

The number of minutes of backfill requested.

**start\_time** `String`

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

**end\_time** `String`

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

**Returns:** `Enumerator<Hash>`

***

## `likes_firehose`

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

**Stream All Likes**

Streams all public Likes in real-time.

```ruby theme={null}
require "xdk"

client = Xdk::Client.new(bearer_token: ENV.fetch("X_BEARER_TOKEN"))

client.stream.likes_firehose(partition: 1) do |event|
  puts event
end
```

### Parameters

**partition** `Integer` *required*

The partition number.

**Optional keyword arguments (8)**

**backfill\_minutes** `Integer`

The number of minutes of backfill requested.

**start\_time** `String`

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

**end\_time** `String`

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

**like\_with\_tweet\_author\_fields** `Array\<String\>`

A comma separated list of LikeWithTweetAuthor fields to display.

**expansions** `Array\<String\>`

A comma separated list of fields to expand.

**media\_fields** `Array\<String\>`

A comma separated list of Media fields to display.

**user\_fields** `Array\<String\>`

A comma separated list of User fields to display.

**tweet\_fields** `Array\<String\>`

A comma separated list of Tweet fields to display.

**Returns:** `Enumerator<Hash>`

***

## `likes_sample10`

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

**Stream Sampled Likes**

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

```ruby theme={null}
require "xdk"

client = Xdk::Client.new(bearer_token: ENV.fetch("X_BEARER_TOKEN"))

client.stream.likes_sample10(partition: 1) do |event|
  puts event
end
```

### Parameters

**partition** `Integer` *required*

The partition number.

**Optional keyword arguments (8)**

**backfill\_minutes** `Integer`

The number of minutes of backfill requested.

**start\_time** `String`

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

**end\_time** `String`

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

**like\_with\_tweet\_author\_fields** `Array\<String\>`

A comma separated list of LikeWithTweetAuthor fields to display.

**expansions** `Array\<String\>`

A comma separated list of fields to expand.

**media\_fields** `Array\<String\>`

A comma separated list of Media fields to display.

**user\_fields** `Array\<String\>`

A comma separated list of User fields to display.

**tweet\_fields** `Array\<String\>`

A comma separated list of Tweet fields to display.

**Returns:** `Enumerator<Hash>`

***

## `posts`

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

**Stream Filtered Posts**

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

```ruby theme={null}
require "xdk"

client = Xdk::Client.new(bearer_token: ENV.fetch("X_BEARER_TOKEN"))

client.stream.posts do |event|
  puts event
end
```

### Parameters

**Optional keyword arguments (9)**

**backfill\_minutes** `Integer`

The number of minutes of backfill requested.

**start\_time** `String`

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

**end\_time** `String`

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

**tweet\_fields** `Array\<String\>`

A comma separated list of Tweet fields to display.

**expansions** `Array\<String\>`

A comma separated list of fields to expand.

**media\_fields** `Array\<String\>`

A comma separated list of Media fields to display.

**poll\_fields** `Array\<String\>`

A comma separated list of Poll fields to display.

**user\_fields** `Array\<String\>`

A comma separated list of User fields to display.

**place\_fields** `Array\<String\>`

A comma separated list of Place fields to display.

**Returns:** `Enumerator<Hash>`

***

## `posts_compliance`

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

**Stream Posts Compliance Data**

Streams all compliance data related to Posts.

```ruby theme={null}
require "xdk"

client = Xdk::Client.new(bearer_token: ENV.fetch("X_BEARER_TOKEN"))

client.stream.posts_compliance(partition: 1) do |event|
  puts event
end
```

### Parameters

**partition** `Integer` *required*

The partition number.

**Optional keyword arguments (3)**

**backfill\_minutes** `Integer`

The number of minutes of backfill requested.

**start\_time** `String`

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

**end\_time** `String`

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

**Returns:** `Enumerator<Hash>`

***

## `posts_firehose`

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

**Stream All Posts**

Streams all public Posts in real-time.

```ruby theme={null}
require "xdk"

client = Xdk::Client.new(bearer_token: ENV.fetch("X_BEARER_TOKEN"))

client.stream.posts_firehose(partition: 1) do |event|
  puts event
end
```

### Parameters

**partition** `Integer` *required*

The partition number.

**Optional keyword arguments (9)**

**backfill\_minutes** `Integer`

The number of minutes of backfill requested.

**tweet\_fields** `Array\<String\>`

A comma separated list of Tweet fields to display.

**expansions** `Array\<String\>`

A comma separated list of fields to expand.

**media\_fields** `Array\<String\>`

A comma separated list of Media fields to display.

**poll\_fields** `Array\<String\>`

A comma separated list of Poll fields to display.

**user\_fields** `Array\<String\>`

A comma separated list of User fields to display.

**place\_fields** `Array\<String\>`

A comma separated list of Place fields to display.

**start\_time** `String`

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

**end\_time** `String`

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

**Returns:** `Enumerator<Hash>`

***

## `posts_firehose_en`

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

**Stream English Posts**

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

```ruby theme={null}
require "xdk"

client = Xdk::Client.new(bearer_token: ENV.fetch("X_BEARER_TOKEN"))

client.stream.posts_firehose_en(partition: 1) do |event|
  puts event
end
```

### Parameters

**partition** `Integer` *required*

The partition number.

**Optional keyword arguments (9)**

**backfill\_minutes** `Integer`

The number of minutes of backfill requested.

**tweet\_fields** `Array\<String\>`

A comma separated list of Tweet fields to display.

**expansions** `Array\<String\>`

A comma separated list of fields to expand.

**media\_fields** `Array\<String\>`

A comma separated list of Media fields to display.

**poll\_fields** `Array\<String\>`

A comma separated list of Poll fields to display.

**user\_fields** `Array\<String\>`

A comma separated list of User fields to display.

**place\_fields** `Array\<String\>`

A comma separated list of Place fields to display.

**start\_time** `String`

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

**end\_time** `String`

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

**Returns:** `Enumerator<Hash>`

***

## `posts_firehose_ja`

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

**Stream Japanese Posts**

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

```ruby theme={null}
require "xdk"

client = Xdk::Client.new(bearer_token: ENV.fetch("X_BEARER_TOKEN"))

client.stream.posts_firehose_ja(partition: 1) do |event|
  puts event
end
```

### Parameters

**partition** `Integer` *required*

The partition number.

**Optional keyword arguments (9)**

**backfill\_minutes** `Integer`

The number of minutes of backfill requested.

**tweet\_fields** `Array\<String\>`

A comma separated list of Tweet fields to display.

**expansions** `Array\<String\>`

A comma separated list of fields to expand.

**media\_fields** `Array\<String\>`

A comma separated list of Media fields to display.

**poll\_fields** `Array\<String\>`

A comma separated list of Poll fields to display.

**user\_fields** `Array\<String\>`

A comma separated list of User fields to display.

**place\_fields** `Array\<String\>`

A comma separated list of Place fields to display.

**start\_time** `String`

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

**end\_time** `String`

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

**Returns:** `Enumerator<Hash>`

***

## `posts_firehose_ko`

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

**Stream Korean Posts**

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

```ruby theme={null}
require "xdk"

client = Xdk::Client.new(bearer_token: ENV.fetch("X_BEARER_TOKEN"))

client.stream.posts_firehose_ko(partition: 1) do |event|
  puts event
end
```

### Parameters

**partition** `Integer` *required*

The partition number.

**Optional keyword arguments (9)**

**backfill\_minutes** `Integer`

The number of minutes of backfill requested.

**tweet\_fields** `Array\<String\>`

A comma separated list of Tweet fields to display.

**expansions** `Array\<String\>`

A comma separated list of fields to expand.

**media\_fields** `Array\<String\>`

A comma separated list of Media fields to display.

**poll\_fields** `Array\<String\>`

A comma separated list of Poll fields to display.

**user\_fields** `Array\<String\>`

A comma separated list of User fields to display.

**place\_fields** `Array\<String\>`

A comma separated list of Place fields to display.

**start\_time** `String`

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

**end\_time** `String`

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

**Returns:** `Enumerator<Hash>`

***

## `posts_firehose_pt`

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

**Stream Portuguese Posts**

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

```ruby theme={null}
require "xdk"

client = Xdk::Client.new(bearer_token: ENV.fetch("X_BEARER_TOKEN"))

client.stream.posts_firehose_pt(partition: 1) do |event|
  puts event
end
```

### Parameters

**partition** `Integer` *required*

The partition number.

**Optional keyword arguments (9)**

**backfill\_minutes** `Integer`

The number of minutes of backfill requested.

**tweet\_fields** `Array\<String\>`

A comma separated list of Tweet fields to display.

**expansions** `Array\<String\>`

A comma separated list of fields to expand.

**media\_fields** `Array\<String\>`

A comma separated list of Media fields to display.

**poll\_fields** `Array\<String\>`

A comma separated list of Poll fields to display.

**user\_fields** `Array\<String\>`

A comma separated list of User fields to display.

**place\_fields** `Array\<String\>`

A comma separated list of Place fields to display.

**start\_time** `String`

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

**end\_time** `String`

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

**Returns:** `Enumerator<Hash>`

***

## `posts_sample`

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

**Stream Sampled Posts**

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

```ruby theme={null}
require "xdk"

client = Xdk::Client.new(bearer_token: ENV.fetch("X_BEARER_TOKEN"))

client.stream.posts_sample do |event|
  puts event
end
```

### Parameters

**Optional keyword arguments (7)**

**backfill\_minutes** `Integer`

The number of minutes of backfill requested.

**tweet\_fields** `Array\<String\>`

A comma separated list of Tweet fields to display.

**expansions** `Array\<String\>`

A comma separated list of fields to expand.

**media\_fields** `Array\<String\>`

A comma separated list of Media fields to display.

**poll\_fields** `Array\<String\>`

A comma separated list of Poll fields to display.

**user\_fields** `Array\<String\>`

A comma separated list of User fields to display.

**place\_fields** `Array\<String\>`

A comma separated list of Place fields to display.

**Returns:** `Enumerator<Hash>`

***

## `posts_sample10`

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

**Stream 10% Sampled Posts**

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

```ruby theme={null}
require "xdk"

client = Xdk::Client.new(bearer_token: ENV.fetch("X_BEARER_TOKEN"))

client.stream.posts_sample10(partition: 1) do |event|
  puts event
end
```

### Parameters

**partition** `Integer` *required*

The partition number.

**Optional keyword arguments (9)**

**backfill\_minutes** `Integer`

The number of minutes of backfill requested.

**tweet\_fields** `Array\<String\>`

A comma separated list of Tweet fields to display.

**expansions** `Array\<String\>`

A comma separated list of fields to expand.

**media\_fields** `Array\<String\>`

A comma separated list of Media fields to display.

**poll\_fields** `Array\<String\>`

A comma separated list of Poll fields to display.

**user\_fields** `Array\<String\>`

A comma separated list of User fields to display.

**place\_fields** `Array\<String\>`

A comma separated list of Place fields to display.

**start\_time** `String`

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

**end\_time** `String`

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

**Returns:** `Enumerator<Hash>`

***

## `update_rules`

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.

```ruby theme={null}
require "xdk"

client = Xdk::Client.new(bearer_token: ENV.fetch("X_BEARER_TOKEN"))

response = client.stream.update_rules(body: { "add" => [{ "value" => "from:XDevelopers" }] })
puts response
```

### Parameters

**body** `Hash` *required*

Request payload.

**Optional keyword arguments (2)**

**dry\_run** `Boolean`

`dry_run` (query parameter).

**delete\_all** `Boolean`

`delete_all` (query parameter).

**Returns:** `Hash`

***

## `users_compliance`

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

**Stream Users Compliance Data**

Streams all compliance data related to Users.

```ruby theme={null}
require "xdk"

client = Xdk::Client.new(bearer_token: ENV.fetch("X_BEARER_TOKEN"))

client.stream.users_compliance(partition: 1) do |event|
  puts event
end
```

### Parameters

**partition** `Integer` *required*

The partition number.

**Optional keyword arguments (3)**

**backfill\_minutes** `Integer`

The number of minutes of backfill requested.

**start\_time** `String`

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

**end\_time** `String`

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

**Returns:** `Enumerator<Hash>`

***
