background preloader

Public stream

Facebook Twitter

Exceed 5,000 following in Streaming API. Streaming API: Only one standing connection per account? Please explain oAuth & IP limit. Public streams. POST statuses/filter. Returns public statuses that match one or more filter predicates. Multiple parameters may be specified which allows most clients to use a single connection to the Streaming API. Both GET and POST requests are supported, but GET requests with too many parameters may cause the request to be rejected for excessive URL length. Use a POST request to avoid long URLs. The track, follow, and locations fields should be considered to be combined with an OR operator. track=foo&follow=1234 returns Tweets matching "foo" OR created by user 1234.

The default access level allows up to 400 track keywords, 5,000 follow userids and 25 0.1-360 degree location boxes. If you need elevated access to the Streaming API, you should explore our partner providers of Twitter data here. Resource URL Parameters *Note: At least one predicate parameter (follow, locations, or track) must be specified. follow see note* Streaming API request parameters. Use the following request parameters to define what data is returned by the Streaming API endpoints: delimited This parameter may be used on all streaming endpoints, unless explicitly noted. Setting this to the string length indicates that statuses should be delimited in the stream, so that clients know how many bytes to read before the end of the status message. Statuses are represented by a length, in bytes, a newline, and the status text that is exactly length bytes.

Note that “keep-alive” newlines may be inserted before each length. As an example, consider this response to a request to The 1953 indicates how many bytes to read off of the stream to get the rest of the Tweet (including \r\n). Stall_warnings Setting this parameter to the string true will cause periodic messages to be delivered if the client is in danger of being disconnected. Such warning messages will look like: filter_level language follow Available on POST statuses/filter. Connecting to a streaming endpoint. Overview Establishing a connection to the streaming APIs means making a very long lived HTTP request, and parsing the response incrementally. Conceptually, you can think of it as downloading an infinitely long file over HTTP.

Authentication The following authentication methods are supported by the Streaming APIs: Note: Basic auth support was removed from public streaming endpoints on June 11, 2013. Connecting To connect to the Streaming API, form a HTTP request and consume the resulting stream for as long as is practical. The method to form an HTTP request and parse the response will be different for every language or framework, so consult the documentation for the HTTP library you are using.

Some HTTP client libraries only return the response body after the connection has been closed by the server. Disconnections Twitter will close a streaming connection for the following reasons: A client establishes too many connections with the same credentials. Stalls Reconnecting Connection churn User Agent. Processing streaming data. Parsing responses The body of a streaming API response consists of a series of newline-delimited messages, where "newline" is considered to be \r\n (in hex, 0x0D 0x0A) and "message" is a JSON encoded data structure or a blank line. Note that Tweet content may sometimes contain linefeed \n characters, but will not contain carriage returns \r. Therefore, to make sure you get whole message payloads, break out each message on \r\n boundaries, as \n may occur in the middle of a message. Alternatively, use the delimited parameter explained under delimited messages. See streaming message types for information about the message formats you will receive from the streaming API.

JSON data The individual messages streamed by this API are JSON encoded. Missing counts In very rare cases the Streaming API may elect to deliver an incomplete Tweet field instead of waiting for data which is taking a long time to fetch. Transfer-Encoding: chunked Delimited messages Falling behind Scaling Message ordering.