Authentication & Subscriptions
Realtime API can be accessed through any WebSocket client.
If you send an invalid message format, you will lose connection.
Connection
Connect to the WebSocket using the following URL:
wss://realtime.insightsentry.com/live
Subscribing to Symbols
After connecting, you can subscribe to symbols with your API key by sending a JSON-encoded message:
{
"api_key": "<your apikey>",
"subscriptions": [
{"code": "NASDAQ:AAPL", "type": "series", "interval_type": "minute", 'interval_length': 1},
{"code": "NASDAQ:TSLA", "type": "quote"}
]
}
Note: Please include your API key each time you subscribe to different symbols. To search for a ticker symbol's code, you can use our free tool or our API to retrieve the code.
Request Parameter for 'subscriptions' field
Managing Subscriptions
To subscribe to symbols, send a message with the desired symbols:
{
"api_key": "<your apikey>",
"subscriptions": [
{"code": "NASDAQ:AAPL", "type": "series", "interval_type": "minute", 'interval_length': 1},
{"code": "NASDAQ:TSLA", "type": "quote"}
]
}
Examples
import websocket
import json
def on_message(ws, message):
print(message)
def on_error(ws, error):
print(error)
def on_close(ws):
print("Dicsonnected")
def on_open(ws):
subMsg = json.dumps({
"api_key": "<your apikey>",
"subscriptions": [{"code": "NASDAQ:AAPL", "type": "series", "interval": "minute", "interval_length": 1}, {"code": "NASDAQ:AAPL", "type": "quote"}]
})
ws.send(subMsg)
if __name__ == "__main__":
websocket.enableTrace(True)
ws = websocket.WebSocketApp("wss://realtime.insightsentry.com/live",
on_message=on_message,
on_error=on_error,
on_close=on_close)
ws.on_open = on_open
ws.run_forever()