Method | Description |
---|---|
GET /stream | Connect to the data stream. |
GET /stream/v2 | Connect to the same stream with better sequence recovery. |
All requests to Firehose stream APIs must use HTTP Basic Authentication, constructed from the username and password combination used to log into this site.
Establishes a persistent connection to the Firehose stream. Everything is the same as /stream with the addition of one field.
Request Params | The last sequence id received can be specified, the stream will attempt to continue from that point unless too many messages have been sent since that sequence.
https://firehose.stocktwits.com/stream?last_sequence_id=123456 |
Data Format Addition | The last sequence id is passed since messages can be streamed in an order different then their message ids due to different speeds of processing.
"firehose_seq" : 123456 |
Establishes a persistent connection to the Firehose stream, through which the realtime data will be delivered.
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, using the following structure:
https://firehose.stocktwits.com/stream |
Params | The last message received can be specified, the stream will attempt to continue from that point (if the message was sent in the past 15 minutes).
https://firehose.stocktwits.com/stream?last_message_id=5555558 |
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 |
Read Timeout | Set a read timeout on your client, and ensure that it is set to a value beyond 30 seconds. |
The following responses may be returned by the API for these requests. Most error codes are returned with a string with additional details in the body. For non-200 responses, clients should attempt to reconnect.
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. Verify that your login combination matches this sites. |
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 | stocktwits server issue. Reconnect using an exponential backoff pattern. If no notice about this issue has been posted on this site under status, email support@stocktwits.com. |
The following example request is accomplished using cURL on the command line.
curl --no-buffer -uusername "https://firehose.stocktwits.com/stream"
verb |
All messages are currently labeled in this way "verb" : "post" |
||||||||||||||||||||||||||||||
id |
A unique ID for the activity. "id" : "tag:firehose.stocktwits.com:note/21637714" |
||||||||||||||||||||||||||||||
body |
The activity's text. "body" : "$AAPL is going down" |
||||||||||||||||||||||||||||||
link |
A link to the post. "link" : "http://stocktwits.com/userName/message/10047145" |
||||||||||||||||||||||||||||||
inReplyTo |
If the current activity is a reply, this is an object containing information about the parent activity and will contain a unique IRI for the activity being replied to. NULL or "inReplyTo" : { "objectType" : "note", "id" : "tag:firehose.stocktwits.com:note/21637177" } |
||||||||||||||||||||||||||||||
sharedNote |
If the current activity is a share, this is an object containing information about the parent message and will contain a unique IRI for the message being replied to. NULL or "sharedNote" : { "objectType" : "note", "id" : "tag:firehose.stocktwits.com:note/21637177" } |
||||||||||||||||||||||||||||||
actor |
An object representing the StockTwits user who posted the activity.
"actor" : { "objectType" : "person", "displayName" : "name", "preferredUsername" : "userName", "followersCount" : 0, "followingCount" : 0, "followingStocksCount" : 0, "id" : "person:stocktwits:183087", "image" : "http://avatars.stocktwits.com/path-to-users-avatar.png", "link" : "http://stocktwits.com/userName", "links" : [{ "href" : "http://userName.com/users/personal-site", "rel" : "me" }], "statusesCount" : 200, "summary" : null, "tradingStrategy" : { "approach" : "Technical", "assetsFrequentlyTraded" : [ "Forex" ], "experience" : "Novice", "holdingPeriod" : "Day Trader" }, "classification" : [ "suggested" ] } |
||||||||||||||||||||||||||||||
object |
A JSON object representing the note being posted.
"object" : { "id" : "note:stocktwits:10047145", "link" : "http://stocktwits.com/myselfbtc/message/10047145", "objectType" : "note", "postedTime" : "2012-10-17T19:13:50Z", "summary" : "$BCOIN and macd is going down ..... http://stks.co/iDEB", "updatedTime" : "2012-10-17T19:13:50Z" } |
||||||||||||||||||||||||||||||
entities |
The entities object from the StockTwits data format. It can contain charts, sentiment, stock symbols, and videos associated with the activity.
"entities" : { "chart" : { "thumb": "http://charts.stocktwits.com/production/small_31307994.png", "large": "http://charts.stocktwits.com/production/large_31307994.png", "original": "http://charts.stocktwits.com/production/original_31307994.png", "url": "http://stks.co/g1Ye8" }, "sentiment" : { "basic" : "Bearish" }, "stocks" : [ { "displayName":"Deere & Company", "stocktwits_id":4940, "symbol":"DE", "exchange":"NYSE", "industry":"Farm & Construction Machinery", "sector":"Industrial Goods", "trending":false } ], "video" : null } |
{ "verb":"post", "id":"tag:firehose.stocktwits.com:note/21637714", "body":"Contains the body message", "actor":{ "id":"person:stocktwits:275917", "objectType":"person", "displayName":"name", "preferredUsername":"userName", "followersCount":10, "followingCount":5, "followingStocksCount":5, "statusesCount":300, "summary":"user bio or NULL if not present", "links":[ { "href":"URL to personal website or NULL if not present", "rel":"me" } ], "link":"http://stocktwits.com/userName", "image":"http://avatars.stocktwits.com/path-to-users-avatar.png", "tradingStrategy":{ "assetsFrequentlyTraded":[ "Equities" ], "approach":"Momentum", "holdingPeriod":"Swing Trader", "experience":"Novice" }, "classification":[ ] }, "object":{ "id":"note:stocktwits:21637714", "objectType":"note", "postedTime":"2014-04-01T20:50:50Z", "updatedTime":"2014-04-01T20:50:50Z", "summary":"Contains the body message", "link":"http://stocktwits.com/userName/message/21637714" }, "provider":{ "displayName":"StockTwits", "link":"http://stocktwits.com" }, "link":"http://stocktwits.com/userName/message/21637714", "entities":{ "symbols":[ { "displayName":"Deere & Company", "stocktwits_id":4940, "symbol":"DE", "exchange":"NYSE", "industry":"Farm & Construction Machinery", "sector":"Industrial Goods", "trending":false } ], "sentiment": {"basic": "Bullish"}, "chart": { "thumb": "http://charts.stocktwits.com/production/small_31307994.png", "large": "http://charts.stocktwits.com/production/large_31307994.png", "original": "http://charts.stocktwits.com/production/original_31307994.png", "url": "http://stks.co/g1Ye8" }, "video":null }, "inReplyTo":{ "objectType":"note", "id":"tag:firehose.stocktwits.com:note/21637177" } }