Skip to main content
Powerstream is our lowest-latency streaming API for accessing public X data in real-time. Unlike other streaming endpoints that prioritize data hydration and delivery (with ~4-5 seconds P99 latency), Powerstream is optimized for speed and delivers data with minimal delay. Similar to the legacy GNIP Powertrack API, it uses rules to filter Posts based on keywords, operators, and metadata. Once a persistent HTTP connection is made to the Powerstream endpoint, you can start receiving matching Posts in real-time. Currently, Powerstream supports up to 1,000 rules and each rule can be 2048 characters.

Key features

  • Real-time data delivery: Lowest latency option for streaming Posts as they’re published.
  • Precise filtering: Filter for exactly the data you are looking for using Boolean queries with operators.
  • Delivery: JSON response over HTTP/1.1 chunked transfer encoding.
  • Local datacenter support: Fetch Posts only from the local datacenter to further reduce latency by avoiding replication lag.
The Powerstream API is a premium offering available under select Enterprise plans.If you’re interested in accessing Powerstream or learning more about our Enterprise offerings, please reach out to our Sales team by submitting the Enterprise Request Form. We’ll be happy to discuss how Powerstream can support your needs.

Quick start

This section showcases how to quickly get started with the PowerStream endpoints using Python with the requests library. Install it via pip install requests. All examples use OAuth 2.0 Bearer Token authentication. Replace YOUR_BEARER_TOKEN with your actual token (store it securely, e.g., via os.getenv('BEARER_TOKEN')). We’ll cover each endpoint with code snippets. Assume these imports at the top:

Setup

1. Create rules (POST /rules)

Add rules to filter your stream.
Example

2. Delete rules (POST /rules)

Remove rules by ID (recommended) or value.
Example
Tip: To delete all rules, first GET them, extract IDs, then delete in bulk.

3. Get rules (GET /rules)

Fetch all active rules.

4. PowerStream (GET /stream)

Connect to the stream for real-time, low-latency Posts. Use stream=True for line-by-line reading. Implement reconnect logic for robustness.
Example

Local datacenter support

For latency optimization, Powerstream provides an option to fetch only posts that originated or were created in the local datacenter where a connection is established. This avoids replication lag, resulting in faster delivery compared to posts from other datacenters. To enable this, append the query parameter ?localDcOnly=true to the stream endpoint (e.g., /2/powerstream?localDcOnly=true). The datacenter you are connected to will be indicated both in the initial data payload of the stream and as an HTTP header in the response. To use in code:
If the localDcOnly parameter is enabled, when the stream first connects, it will include the following response headers indicating which local datacenter is being used:
In addition to this, it will also send an initial payload specifying the datacenter:
Tip: To optimize latency, set up connections from different geographic locations (e.g., one near Atlanta on the US East Coast and another near Portland on the US West Coast), enabling localDcOnly=true for each. This provides faster access to posts from each respective datacenter. Aggregate the streams on your end to combine cross-datacenter data.

Operators

In order to set rules for filtering, you can use keywords and operators.

Powerstream operators

Complete list of available operators

Responses

The payload of the Powerstream API is the same format as the legacy GNIP Powertrack API. A sample json response looks like:
Example response

Edited posts

Each edit of a post creates a new post with a new ID, and Powerstream delivers every version that matches your rules. Posts that carry edit data include these fields at the top level of the post object: A post is an edit when edit_history.initial_tweet_id is different from its id_str. For example, the second version of an edited post looks like this:
Edited post (excerpt)
The first version of the same post has "initial_tweet_id": "1234567890123456789", the same as its own id_str. Reposts and quoted posts include their own edit fields inside retweeted_status and quoted_status. Some fields can be missing on individual posts; posts without edit data, such as posts created before editing was available, don’t include them. To receive only the first version of each post, add -is:edit to your rules. See Filtering out edited posts. For more on how editing works, see Edit Posts.

Limits and best practices

  • Rate Limits: 50 requests/24h for rule management; no limit on streams (but connection limits apply).
  • Reconnection: Exponential backoff on disconnects.
  • Monitoring: Use Connection: keep-alive headers.

Streaming fundamentals

Consuming streaming data

Best practices for streaming clients

Handling disconnections

Reconnect gracefully

High volume capacity

Handle high throughput

Recovery and redundancy

Build resilient applications