Amharic: am | German: de | Malayalam: ml | Slovak: sk |
Arabic: ar | Greek: el | Maldivian: dv | Slovenian: sl |
Armenian: hy | Gujarati: gu | Marathi: mr | Sorani Kurdish: ckb |
Basque: eu | Haitian Creole: ht | Nepali: ne | Spanish: es |
Bengali: bn | Hebrew: iw | Norwegian: no | Swedish: sv |
Bosnian: bs | Hindi: hi | Oriya: or | Tagalog: tl |
Bulgarian: bg | Latinized Hindi: hi-Latn | Panjabi: pa | Tamil: ta |
Burmese: my | Hungarian: hu | Pashto: ps | Telugu: te |
Croatian: hr | Icelandic: is | Persian: fa | Thai: th |
Catalan: ca | Indonesian: in | Polish: pl | Tibetan: bo |
Czech: cs | Italian: it | Portuguese: pt | Traditional Chinese: zh-TW |
Danish: da | Japanese: ja | Romanian: ro | Turkish: tr |
Dutch: nl | Kannada: kn | Russian: ru | Ukrainian: uk |
English: en | Khmer: km | Serbian: sr | Urdu: ur |
Estonian: et | Korean: ko | Simplified Chinese: zh-CN | Uyghur: ug |
Finnish: fi | Lao: lo | Sindhi: sd | Vietnamese: vi |
French: fr | Latvian: lv | Sinhala: si | Welsh: cy |
Georgian: ka | Lithuanian: lt |
Auth Type | Supported APIs | Description |
OAuth | * Track API Stream | Requests must be authorized according to the OAuth specification . |
Basic auth | * PowerTrack API * Decahose stream | Requests must use of HTTP Basic Authentication, constructed from a valid email address and password combination. |
Status | Text | Description |
200 | Success | Self evident. |
401 | Unauthorized | HTTP authentication failed due to either: * Invalid basic auth credentials, or an invalid OAuth request. * Out-of-sync timestamp in your OAuth request (the response body will indicate this). * Too many incorrect passwords entered or other login rate limiting. |
403 | Forbidden | The connecting account is not permitted to access this endpoint. |
404 | Unknown | There is nothing at this URL, which means the resource does not exist. |
406 | Not Acceptable | At least one request parameter is invalid. For example, the filter endpoint returns this status if: * The track keyword is too long or too short. * An invalid bounding box is specified. * Neither the track nor follow parameter are specified. * The follow user ID is not valid. |
413 | Too Long | A parameter list is too long. For example, the filter endpoint returns this status if: * More track values are sent than the user is allowed to use. * More bounding boxes are sent than the user is allowed to use. * More follow user IDs are sent than the user is allowed to follow. |
416 | Range Unacceptable | For example, an endpoint returns this status if: * A count parameter is specified but the user does not have access to use the count parameter. * A count parameter is specified which is outside of the maximum/minimum allowable values. |
420 | Rate Limited | The client has connected too frequently. For example, an endpoint returns this status if: * A client makes too many login attempts in a short period of time. * Too many copies of an application attempt to authenticate with the same credentials. |
503 | Service Unavailable | A streaming server is temporarily overloaded. Attempt to make another connection, keeping in mind the connection attempt rate limiting and possible DNS caching in your client. |
Name | Type | Description |
---|---|---|
startTime | date (ISO 8601) | YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339). Date in UTC signifying the start time to recover from. |
endTime | date (ISO 8601) | YYYY-MM-DDTHH:mm:ssZ (ISO 8601/RFC 3339). Date in UTC signifying the end time to recover to. |
https://gnip-stream.x.com
URL. HTTP streaming connections are requested with HTTP headers that indicate a ‘keep-alive’ connection. More information on realtime streaming is available here.
Given the potential of high volumes of X data delivered in a stream, it is highly recommended that incoming data is processed in an asynchronous fashion. What this means is that your code that ‘hosts’ the client side of the stream simply inserts incoming Posts into a (FIFO) queue, or similar memory structure, and then you have a separate process/thread that consumes Posts from that queue and does more of the ‘heavy lifting’ of parsing and preparing the data for storage. With this design, you can implement a process that will bend but not break in case incoming data volumes change dramatically.
How can multiple customers, projects, and campaigns be managed in a single stream?
The vast majority of realtime PowerTrack users manage multiple customers, projects, and campaigns within a single realtime stream by using PowerTrack rule ‘tags’. Rule tags have no special meaning, they are simply treated as opaque strings carried along with the rule. They will be included in the “matching rules” metadata in activities returned.
Tags provide an easy way to create logical groupings of PowerTrack rules. For example, you may generate a unique ID for a specific rule as its tag and allow your application to reference that ID within activities it processes to associate a result with specific customers, campaigns, categories, or other related groups.
How many connections to a given PowerTrack stream can I have at one time?
PowerTrack streams support multiple connections to a single endpoint. Having multiple connections enables customers to build redundant data consumer clients, ideally on different networks. While PowerTrack streams default to a single connection, many customers prefer to have two connections per PowerTrack stream to ensure continuous delivery. If multiple connections are made to a single endpoint, and/or multiple streams exist with common rules, a given Post will be received multiple times. Note that for accounting purposes, the Post will be counted once.
Please talk to your Account Manager for more information.
How ‘realtime’ are the results? Is there any delay/elaboration time between the publication of a Post on X and their release on the PowerTrack stream?
Posts that match your ruleset will be delivered to your stream within seconds of being published on the platform. There are variables, such as network connectivity and how your consuming application reads data off the stream; but all things being equal, you should receive Posts within seconds of them being published.
Please note that the URL enrichment does cause an increased latency, due to the unwinding of each URL in the Post.
Generally speaking, you should expect Volume streams (e.g. Firehose and Decahose) to be faster than PowerTrack, and PowerTrack to be fast than statuses/filter.
Is it possible to update several rules in one go?
Yes, you can add or delete several rules with one request.
However, note that the add and delete steps are separate and you will need two requests: one request to add one or several rule(s) and another request to delete one or several rule(s).
The upper limit number of rules that can either be added or be deleted in one go is a JSON body that is 5MB or less in size. Depending on the length of your rule values and tags, the upper number will be in the lower thousands.
Why isn’t my rule appearing on the stream right away?
Most rule additions take effect almost immediately. However, depending on factors such as network connectivity and rule size/complexity, it may take up to 5 minutes before you start receiving matching Posts.
What if some Posts are missing: I was expecting them to be returned by the stream, but they weren’t?
You can follow the next few steps to understand why some Posts might not have been delivered:
This stream has been disconnected because your client was unable to keep up with us.
This stream has been disconnected for operational reasons.
This kind of error occurs when your stream is not keeping up with the speed at which we are delivering data and your app isn’t consuming the data from the stream fast enough.
We allow delivery to get behind for a period of time, and we have a temporary staging buffer amount for each stream on our side; but if you don’t catch up, we initiate a disconnect to allow you to reconnect at the current point in time. Please note that this may lead to data loss (for data that is within the buffer at the time of the full buffer disconnect).
These can occur around large spikes in data. Generally, we recommend using a buffer process for consuming data quickly that is separate from the processing process.
You can find out more about optimizing your app to prevent disconnects like this in our articles on connection and on consuming streaming data here.
Add or delete rules from your stream | PowerTrack Rules API |
Connect to your PowerTrack stream | PowerTrack API` |
Recover Posts lost during an outage | Replay API |
Method | Description |
---|---|
GET /track/:stream | Connect to the data stream |
Request Method | HTTP GET |
Connection Type | Keep-Alive This should be specified in the header of the request. |
URL | Found on the stream’s API Help page of your console dashboard, and resembles the following structure: https://gnip-stream.x.com/stream/powertrack/accounts//publishers/twitter/.json |
Compression | Gzip. To connect to the stream using Gzip compression, simply send an Accept-Encoding header in the connection request. The header should look like the following: Accept-Encoding: gzip |
Character Encoding | UTF-8 |
Response Format | JSON. The header of your request should specify JSON format for the response. |
Rate Limit | 60 requests per minute. |
Read Timeout | Set a read timeout on your client, and ensure that it is set to a value beyond 30 seconds. |
Support for Tweet edits | All Tweet objects will include Tweet edit metadata describing the Tweet’s edit history. See the “Edit Tweets” fundamentals page for more details. |
Status | Text | Description |
---|---|---|
200 | Success | The connection was successfully opened, and new activities will be sent through as they arrive. |
401 | Unauthorized | HTTP authentication failed due to invalid credentials. Log in to console.gnip.com with your credentials to ensure you are using them correctly with your request. |
406 | Not Acceptable | Generally, this occurs where your client fails to properly include the headers to accept gzip encoding from the stream, but can occur in other circumstances as well. Will contain a JSON message similar to “This connection requires compression. To enable compression, send an ‘Accept-Encoding: gzip’ header in your request and be ready to uncompress the stream as it is read on the client end.” |
429 | Rate Limited | Your app has exceeded the limit on connection requests. |
503 | Service Unavailable | X server issue. Reconnect using an exponential backoff pattern. If no notice about this issue has been posted on the X API Status Page, contact support or emergency if unable to connect after 10 minutes. |
Method | Description |
---|---|
GET /replay/:stream_type | Connect to the replay stream. For realtime PowerTrack, the Stream Type is ‘powertrack’. For Volume Streams, Stream Types include ‘sample10’ (i.e. decahose), ‘firehose’, ‘mentions’, and ‘compliance’. |
Request Method | HTTP GET |
Connection Type | Keep-Alive This should be specified in the header of the request. |
URL | Found on the stream’s API Help page of your dashboard, the URL is built with Stream Type, Account Name and Stream Label tokens. For realtime PowerTrack, the Stream Type is ‘powertrack’. For Volume Streams, Stream Types include ‘sample10’ (i.e. decahose), ‘firehose’, ‘mentions’, and ‘compliance’. Replay URLs have the following pattern: https://gnip-stream.gnip.com/replay//accounts//publishers/twitter/.json For example, the Replay URL for realtime PowerTrack has the following pattern: https://gnip-stream.gnip.com/replay/powertrack/accounts//publishers/twitter/.json For example, the Replay URL for Decahose has the following pattern: https://gnip-stream.gnip.com/replay/sample10/accounts//publishers/twitter/.json |
Compression | Gzip. To connect to the stream using Gzip compression, simply send an Accept-Encoding header in the connection request. The header should look like the following: Accept-Encoding: gzip |
Character Encoding | UTF-8 |
Response Format | JSON. The header of your request should specify JSON format for the response. |
Rate Limit | 5 requests per 5 minutes. |
fromDate | The oldest (starting) UTC timestamp from which the activities will be provided, must be in ‘YYYYMMDDHHMM’ format. Timestamp is in minute granularity and is inclusive (i.e. 12:00 includes the 00 minute). Valid times must be within the last 5 days, UTC time, and no more recent than 31 minutes before the current point in time. It’s recommended that the fromDate and toDate should be within ~2 hours. |
toDate | The latest (ending) UTC timestamp to which the activities will be provided, must be in ‘YYYYMMDDHHMM’ format. Timestamp is in minute granularity and is exclusive (i.e. 12:30 does not include the 30th minute of the hour). Valid times must be within the last 5 days, UTC time, and no more recent than 30 minutes before the current point in time. It’s recommended that the fromDate and toDate should be within ~2 hours. |
Read Timeout | Set a read timeout on your client, and ensure that it is set to a value beyond 30 seconds. |
Support for Tweet edits | Since all Replay requests are for Tweets posted at least 30 minutes ago, all Tweets returned by Replay will reflect their final edit state. All Tweet objects will include metadata that describes its edit history. See the “Edit Tweets” fundamentals page for more details. |
Status | Text | Description |
---|---|---|
200 | Success | The connection was successfully opened, and new activities will be sent through until the end of the requested time period is reached, and a “Replay Request Completed” message is sent. |
401 | Unauthorized | HTTP authentication failed due to invalid credentials. Log in to console.gnip.com with your credentials to ensure you are using them correctly with your request. |
406 | Not Acceptable | Generally, this occurs where your client either fails to properly include the headers to accept gzip encoding from the stream, or specifies an unacceptable fromDate or toDate. Will contain a JSON message indicating the issue — e.g. “This connection requires compression. To enable compression, send an ‘Accept-Encoding: gzip’ header in your request and be ready to uncompress the stream as it is read on the client end.” or “Invalid date for query parameter ‘toDate’. Can’t ask for tweets from within the past 30 minutes.” |
429 | Rate Limited | Your app has exceeded the limit on connection requests. |
503 | Service Unavailable | X server issue. Reconnect using an exponential backoff pattern. If no notice about this issue has been posted on the X API Status Page, contact support. |
Method | Description |
---|---|
POST /rules | Add rules to the stream |
GET /rules | Retrieve all rules currently in place on the stream |
GET /rules/:rule_id | Retrieve an existing rule on the stream by rule ID |
POST /rules _method=get | Retrieve multiple rules on the stream by rule IDs |
POST /rules _method=delete | Delete rules from the stream |
POST /validation | Validate PowerTrack rule syntax |
Request Method | HTTP POST |
Content Type | ”application/json”. The request should specify this as the “Content-type”. |
URL | Found on the Console - Products API Help tab, and uses the following structure: https://data-api.x.com/rules/powertrack/accounts/{gnip_account_name}/publishers/twitter/{stream_label}.json |
Character Encoding | UTF-8 |
Request Body Format | JSON |
Request Body Size Limit | 5 MB |
Rate Limit | 60 requests per minute, aggregated across all requests to /rules endpoint for the specific stream’s API (POST and GET). Rule addition requests will be processed serially and will be rejected if you have more than one rule request happening at the same time. |
Status | Text | Description |
---|---|---|
201 | Created | The rule or rules were successfully added to your PowerTrack ruleset. |
400 | Bad Request | Generally relates to poorly formatted JSON, and includes an “Invalid JSON” message in the response. |
401 | Unauthorized | HTTP authentication failed due to invalid credentials. Log in to console.gnip.com with your credentials to ensure you are using them correctly with your request. |
422 | Unprocessable Entity | Generally occurs due to an invalid rule, based on the PowerTrack rule restrictions. Requests fail or succeed as a batch. For these errors, each invalid rule and the reason for rejection is included in a JSON message in the response. Catch the associated exception to expose this message. |
429 | Rate Limited | Your app has exceeded the limit on requests to add, delete, or list rules for this stream. |
503 | Service Unavailable | X server issue. Reconnect using an exponential backoff pattern. If no notice about this issue has been posted on the X API Status Page contact support or contact emergency if still unable to connect after 10 minutes. |
Request Method | HTTP GET |
URL | Found on the Console - Products API Help tab, and uses the following structure: https://data-api.x.com/rules/powertrack/accounts/:account_name/publishers/twitter/:stream_label.json |
Rate Limit | 60 requests per minute, aggregated across all requests to /rules endpoint for the specific stream’s API (POST and GET). |
Status | Text | Description |
---|---|---|
200 | OK | The request was successful, and the current ruleset is returned in JSON format. |
400 | Bad Request | Generally relates to poorly formatted JSON, and includes an “Invalid JSON” message in the response. |
401 | Unauthorized | HTTP authentication failed due to invalid credentials. Log in to console.gnip.com with your credentials to ensure you are using them correctly with your request. |
429 | Rate Limited | Your app has exceeded the limit on requests to add, delete, or list rules for this stream. |
503 | Service Unavailable | X server issue. Reconnect using an exponential backoff pattern. If no notice about this issue has been posted on the X API Status Page contact support. |
Request Method | HTTP GET |
URL | Found on the Console - Products API Help tab, and uses the following structure: https://data-api.x.com/rules/powertrack/accounts/:account_name/publishers/twitter/:stream_label/rules/:rule_id.json |
Rate Limit | 60 requests per minute, aggregated across all requests to /rules endpoint for the specific stream’s API (POST and GET). |
Status | Text | Description |
---|---|---|
200 | OK | The request was successful, and the current rule is returned in JSON format. |
400 | Bad Request | Generally relates to poorly formatted JSON, and includes an “Invalid JSON” message in the response. |
401 | Unauthorized | HTTP authentication failed due to invalid credentials. Log in to console.gnip.com with your credentials to ensure you are using them correctly with your request. |
429 | Rate Limited | Your app has exceeded the limit on requests to add, delete, or list rules for this stream. |
503 | Service Unavailable | X server issue. Reconnect using an exponential backoff pattern. If no notice about this issue has been posted on the X API Status Page contact support. |
Request Method | HTTP POST |
URL | Found on the API Help page, and uses the following structure: https://data-api.x.com/rules/powertrack/accounts/{gnip_account_name}/publishers/twitter/{stream_label}.json?_method=get |
Character Encoding | UTF-8 |
Request Body Format | JSON |
Request Body Size Limit | 5 MB |
Rate Limit | 60 requests per minute, aggregated across all requests to /rules endpoint for the specific stream’s API (POST and GET). |
Compression | Gzip compression is supported, but not required for these requests. |
Status | Text | Description |
---|---|---|
200 | OK | The request was successful, and the current ruleset is returned in JSON format. |
400 | Bad Request | Generally relates to poorly formatted JSON, and includes an “Invalid JSON” message in the response. |
401 | Unauthorized | HTTP authentication failed due to invalid credentials. Log in to console.gnip.com with your credentials to ensure you are using them correctly with your request. |
429 | Rate Limited | Your app has exceeded the limit on requests to add, delete, or list rules for this stream. |
503 | Service Unavailable | X server issue. Reconnect using an exponential backoff pattern. If no notice about this issue has been posted on the X API Status Page contact support. |
Request Method | HTTP POST |
Authentication | Basic Authentication. Your login credentials must be included in the header of the request. |
Content Type | ”application/json”. The request should specify this as the “Content-type”. |
URL | Found on the API Help page, and uses the following structure: https://data-api.x.com/rules/powertrack/accounts/{gnip_account_name}/publishers/twitter/{stream_label}.json?_method=delete |
Character Encoding | UTF-8 |
Request Body Format | JSON |
Request Body Size Limit | 5 MB |
Rate Limit | 60 requests per minute, aggregated across all requests to /rules endpoint for the specific stream’s API (POST and GET). |
Status | Text | Description |
---|---|---|
200 | OK | Indicates that the rule data supplied with the request consisted of valid JSON. However, note that if no rules are found in the ruleset for the PowerTrack stream based on a case-sensitive search, no rules will be deleted. |
400 | Bad Request | Generally relates to poorly formatted JSON, and includes an “Invalid JSON” message in the response. |
401 | Unauthorized | HTTP authentication failed due to invalid credentials. Log in to console.gnip.com with your credentials to ensure you are using them correctly with your request. |
429 | Rate Limited | Your app has exceeded the limit on requests to add, delete, or list rules for this stream. |
503 | Service Unavailable | X server issue. Reconnect using an exponential backoff pattern. If no notice about this issue has been posted on the X API Status Page, contact support. |
#XData
already exists. {“summary”:{“created”:0,“not_created”:1},“detail”:[{“rule”:{“value”:“#XData”,“tag”:“tagtextB”,“id”:961664522481119232,“id_str”:“961664522481119232”},“created”:false,“message”:“A rule with this value already exists”} System: {“value”:“#XData”,“tag”:“tagtextA”,“id”:961664522481119232,“id_str”:“961664522481119232”}
FAILED ATTEMPT TO DELETE BY TAG
Action: POST method=delete rule {“tag”:“tagtextA”} **Rules cannot be deleted by tag. {“summary”:{“deleted”:0,“not_deleted”:1},“detail”:[{“rule”:{“value”:"",“tag”:null},“deleted”:false,“message”:“Rule does not exist”}],“sent”:“2018-02-08T18:42:37.004Z”} System: {“value”:“#XData”,“tag”:“tagtextA”,“id”:961664522481119232,“id_str”:“961664522481119232”}
DELETE BY ID
Action: POST method=delete rule {“rule_ids”:[961664522481119232]} {“summary”:{“deleted”:1,“not_deleted”:0},“detail”:[],“sent”:“2018-02-08T18:53:54.185Z”}
DELETE BY VALUE
Action: POST method=delete rule {“value”:“#XData”} {“summary”:{“deleted”:1,“not_deleted”:0},“detail”:[],“sent”:“2018-02-08T18:53:54.185Z”}
RECREATE RULE- NOW WITH NEW ID
Action: POST rule {“value”:“#XData”,“tag”:“tagtextB”} {“summary”:{“created”:1,“not_created”:0},“detail”:[{“rule”:{“value”:“#XData”,“tag”:“tagtextB”,“id”:961675641140609025,“id_str”:“961675641140609025”},“created”:true}],“sent”:“2018-02-08T18:58:34.586Z”} System: {“value”:“#XData”,“tag”:“tagtextB”,“id”:961675641140609025,“id_str”:“961675641140609025”}
Request Method | HTTP POST |
URL | Found on the API Help page in console, and uses the following structure: https://data-api.x.com/rules/powertrack/accounts/:account_name/publishers/twitter/:stream_label/validation.json |
Character Encoding | UTF-8 |
Request Body Format | JSON |
Request Body Size Limit | 5 MB |
Rate Limit | 60 requests per minute, aggregated across all requests to /rules endpoint for the specific stream’s API (POST and GET). |
Status | Text | Description |
---|---|---|
200 | OK | The request was successful, and the rule validation result is returned. |
400 | Bad Request | Generally relates to poorly formatted JSON, and includes an “Invalid JSON” message in the response. |
401 | Unauthorized | HTTP authentication failed due to invalid credentials. Log in to console.gnip.com with your credentials to ensure you are using them correctly with your request. |
429 | Rate Limited | Your app has exceeded the limit on requests to add, delete, or list rules for this stream. |
503 | Service Unavailable | X server issue. Reconnect using an exponential backoff pattern. If no notice about this issue has been posted on the X API Status Page, contact support. |