Overview
Real-time delivery
Receive Posts within seconds of publication
Persistent rules
Add and remove rules without disconnecting
Powerful operators
Match on keywords, hashtags, users, and more
Webhook delivery
Optionally receive Posts via webhooks
How it works
- Create rules — Define filter rules using operators
- Connect to stream — Establish a persistent HTTP connection
- Receive Posts — Get matching Posts in real-time
Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /2/tweets/search/stream | Connect to the stream |
| POST | /2/tweets/search/stream/rules | Add or delete rules |
| GET | /2/tweets/search/stream/rules | List current rules |
Access levels
| Feature | Pay-per-use | Enterprise |
|---|---|---|
| Rules per project | 1,000 | 25,000+ |
| Rule length | 1,024 chars | 2,048 chars |
| Connections | 1 | Multiple |
| All operators | ✓ | ✓ |
Contact for Enterprise
Get higher limits and additional features
Building rules
Rules use the same operators as search queries:Example rules
| Rule | Matches |
|---|---|
#python | Posts with #python hashtag |
from:elonmusk | Posts by @elonmusk |
"breaking news" has:images | Posts with phrase and images |
(@XDevelopers OR @X) -is:retweet | Mentions, excluding retweets |
Build a rule
Learn rule syntax and operators
Connecting to the stream
Establish a persistent HTTP connection to receive Posts:Keep-alive signals
The stream sends blank lines (\r\n) every 20 seconds to maintain the connection. If you don’t receive data or a keep-alive for 20 seconds, reconnect.
Webhook delivery
Instead of maintaining a persistent connection, you can receive Posts via webhooks:Webhook delivery
Set up webhook delivery for filtered stream
Post edits
The stream delivers edited Posts with their edit history. Each edit creates a new Post ID:Edit Posts fundamentals
Learn more about Post edits
Getting started
Prerequisites
- An approved developer account
- A Project and App in the Developer Console
- Your App’s Bearer Token
Quickstart
Connect to the stream in minutes
Build a rule
Learn rule syntax
Operator reference
All available operators
Sample code
Working code examples