PowerTrack API migration to X API v2 filtered stream
Use this migration guide to understand the similarities and differences between PowerTrack API and X API v2 filtered stream, and to help migrate a current PowerTrack API integration to v2 filtered stream.- Similarities
- Streaming delivery method
- Integration process
- Persistent stream connection with separate rules management endpoints
- Rule syntax
- Rule operators (with exceptions)
- Rule matching logic
- Support for Post edit history and metadata
- Differences
- Rule length
- Rule volume
- Endpoint URLs
- App and Project requirement for access
- Authentication method
- Request parameters
- Usage tracking
- Multiple streams, redundant conections, backfill and Replay recovery
- Request parameters and response format
- Response JSON data structure
Similarities
Streaming delivery method Both PowerTrack and X API v2 filtered stream use streaming data delivery, which require the client to establish an open connection to an endpoint and keeping a very long lived HTTP request, and parsing the response incrementally from the server in real time. Both PowerTrack and X API v2 filtered stream filter publicly available Posts matching rules that exist on the stream in real time, and use keep-alive signals as new line characters (\r\n) to signal the connection is still active. Both PowerTrack and X API v2 filtered stream endpoint connections deliver data in real time and should be read by the connecting client quickly. Integration process Integrating with filtered stream is similar to integrating with PowerTrack, using the general process below:- Establish a streaming connection.
- Asynchronously send separate requests to add and delete rules from the stream.
- Reconnect to the stream automatically when connection is disconnected.
| Feature | PowerTrack API | X API v2 filtered stream |
| Connection endpoint | GET /stream | GET /2/tweets/search/stream |
| Add rules | POST /rules | POST /2/tweets/search/stream/rules |
| Get rules | GET /rules | GET /2/tweets/search/stream/rules |
| Delete rules | POST /rules_method=delete | POST /2/tweets/search/stream/rules |
| Standalone operators | Conjunction required operators (must be used with at least one standalone operator within a rule) |
|---|---|
| keyword (example: coffee ) emoji (example: 🐶 or \uD83D\uDC36 ) “exact phrase match” (example: “happy birthday” ) from: to: @ retweets_of: # url: | has:links lang: has:mentions has:media has:images has:videos is:retweet is:quote is:verified has:hashtags has:geo sample: -is:nullcast |
| Net new operators available with X API v2 filtered stream |
| conversation_id: - matches on Posts that exist in any reply threads from the specified Post conversation root.Net new operators available with X API v2 filtered stream: context: - matches on Posts that have been annotated with a context of interest. entity: - matches on Posts that have been annotated with an entity of interest. |
| Operators currently only available on PowerTrack API |
| url_title: url_description: followers_count: statuses_count: friends_count: listed_count: “proximity match”~3 contains: has:symbols url_contains: in_reply_to_status_id: retweets_of_status_id: source: bio: bio_name: bio_location: place: place_country: point_radius: bounding_box: is:reply (Available without conjunction) has:links lang: has:mentions has:media has:images has:videos is:retweet is:quote is:verified is:reply has:hashtags has:geo sample: |
Differences
Rule length Rule length is measured the same way (by character count) for both PowerTrack and filtered stream rules, however the maximum length for PowerTrack rules is 2048 characters and the maximum rule length for rules on X API v2 filtered stream varies by access level. Enterprise access - 2048 characters (please contact your designated account manager regarding your specific account) Rule volume The PowerTrack maximum rule volume per stream is defined within the enterprise account contract. X API v2 filtered stream rule volume varies by access level. Enterprise access - 25000+ rules (please contact your designated account manager regarding your specific account) Endpoint URLs- PowerTrack endpoints:
- https://gnip-stream.x.com/stream/powertrack/accounts/{account\_name}/publishers/twitter/{stream\_label}.json
- https://gnip-api.x.com/rules/powertrack/accounts/{account\_name}/publishers/twitter/{stream\_label}.json
- https://gnip-api.x.com/rules/powertrack/accounts/{account\_name}/publishers/twitter/{stream\_label}/validation.json
- X API v2 endpoint:
| Native enriched format | Activity streams format | X API v2 filtered stream format |
| Payload examples | Payload examples | Payload examples |