Skip to main content
Powerstream is our fastest, real-time streaming API for accessing public X data. Similar to the legacy GNIP Powetrack 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 near-real time. Currently, Powerstream supports up to 1,000 rules and each rule can be 2048 characters.

Key Features:

  • Real-time data delivery: Get data matching your rules in near-real time.
  • 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 Data-center support: Fetch posts only from the local datacenter to 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.

2. Delete Rules (POST /rules)

Remove rules by ID (recommended) or value.
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 Posts. Use stream=True for line-by-line reading. Implement reconnect logic for robustness.

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. Check out the list of available operators below.

Field-Based Operators

User Operators

Content Operators

Entity Operators

Location Operators

Advanced/Content Operators

Additional Operators

Non-Field Operators

Special Syntax Operators

Logical Operators

Responses

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

Limits & 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.