GET /symbols/stream 

Establishes a persistent connection to the Firehose symbols based stream, through which the realtime data will be delivered.


Request Specifications

Request Method HTTP GET
Accept text/event-stream

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://firestream.stocktwits.com/symbols/stream
Params The last stream item received can be specified, the stream will attempt to continue from that point (if the item was sent in the past 24 hours).

https://firestream.stocktwits.com/stream?seq_id=49562553817515093231064627491680393519832340977378394114
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.

Responses

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."
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.

Example request using curl

The following example request is accomplished using cURL on the command line.

curl --no-buffer -u 'username':'password' -H"Accept: text/event-stream" "https://firestream.stocktwits.com/symbols/stream"

If you are working on Windows, you may need to use double quotes instead of single quotes for the username and password.

curl --no-buffer -u "username":"password" -H"Accept: text/event-stream" "https://firestream.stocktwits.com/symbols/stream"

Example request using python

The following example request is accomplished using a python script with the requests library.

'''
  This script uses the "requests" library to connect to the stream.
  It should be installed using pip before running this script.
'''

import requests
from requests.auth import HTTPBasicAuth

username = "myusername"
password = "mypassword"

# Create a new request, the stream parameter is set to True to keep the connection open
try:
    resp = requests.get("https://firestream.stocktwits.com/symbols/stream", auth=HTTPBasicAuth(username, password), stream=True)
except Exception as e:
    print(f"Error creating request: {e}")
    exit()

# Check for errors on the response a HTTP status code of 200 is expected
if resp.status_code != 200:
    print(f"Error response: {resp.status_code} {resp.reason}")
    exit()

# Read the response body on a loop
try:
    for line in resp.iter_lines():
        if line:  # filter out keep-alive new lines
            print(line.decode())

except Exception as e:
    print(f"Error reading stream: {e}")
    exit()
          

Data Format 

symbol_id

This is the ID of the symbol to which the event occurred:

"symbol_id" : 125625

symbol

This is the symbol to which the event occurred:

"symbol" : "AAPL"

metric

This is metric registered by th event:

  • pageview
  • watchlist_add
  • watchlist_remove
  • message
  • like
"metric" : "pageview"

user_id [Optional]

The user who did the action that produced the event, this might not be present if the action was done by a guest user.

"user_id" : 5548695

created_at

The timestamp when the event occurred.

"created_at" : "2019-08-24T14:15:22Z"

seq_id

Sequence Id used to identify the streams position. Can be used for recovery for up to 24 hours. (Not present in backups)

"seq_id":"49567487888076093524624994048752032346222860024699420674"
{
  "symbol_id": 125625,
  "symbol": "AAPL",
  "metric": "pageview",
  "user_id": 5548695,
  "created_at": "2015-12-24T20:00:01Z",
  "seq_id":"49567487888076093524624994048752032346222860024699420674"
}