Overview
TheStreamClient provides access to real-time streaming endpoints including filtered streams, sample streams, and compliance streams. Streaming connections automatically handle reconnection with exponential backoff.
Initialization
Access the stream client through the mainClient instance:
Key Methods
posts_search()
Stream real-time posts matching filter rules with automatic pagination and reconnection.Number of minutes of backfill to retrieve
Tweet fields to include in the response
Expansions to include in the response
Generator yielding posts as they arrive
Example:
posts_sample()
Stream a random sample of public posts in real-time.Number of minutes of backfill to retrieve
Tweet fields to include in the response
Generator yielding random sample posts
Example:
Stream Rules Management
Manage filtering rules for the filtered stream:Compliance Streams
posts_compliance()
Stream compliance events for posts (deletions, withheld content, etc.) Example:users_compliance()
Stream compliance events for users (suspensions, deactivations, etc.)likes_compliance()
Stream compliance events for likes (unlike events, etc.)Firehose Streams
For Enterprise access, firehose streams are available:posts_firehose()- Full firehose of all public postsposts_firehose_ja()- Japanese language firehoseposts_firehose_ko()- Korean language firehoseposts_firehose_pt()- Portuguese language firehoselikes_firehose()- All public like events
Authentication
Streaming endpoints require:- Bearer Token (App-only)
- OAuth 2.0 User Context