Live Streaming / Overview and Authentication

Overview

This page is concerned with providing you with information to set up live streaming.

We provide this API for you to subscribe to events related to your trading strategy. Using this API, you don't have to call our API over and over again. Instead, our backend will send a message to your code when something happens that you consider important for your strategy.

The Live Streaming API can be reached via:

https://realtime.lemon.markets/v1/

Please use a Paper Trading API key to access this API for the time being. See Authentication for more information about the pending introduction of market data keys.

Sample Code

Off the Shelf Examples

We will guide you through the API using small code snippets in JavaScript. If you prefer to just download the code and run with it, go ahead:

If you like to see an example added to this section, contact us on Slack or send an email to support@lemon.markets.

Stream Authorization

In order to access the live stream, you'll have to call the authorization endpoint of the Live Streaming API.

The authorization endpoint will provide you with all the information needed to set up a connection to Ably, our streaming partner.

POST /auth

Use the following URL to request an authentication token for Ably:

https://realtime.lemon.markets/v1/auth

Request

Specify your request as follows to retrieve an authentication token for the streaming SDK:

Header Parameters

Authorization
string
required

Set your Authorization header in the format Bearer {'YOUR-API-KEY'}
(see the example in the code snippet on the right)

Response

Response Parameters

token
string

Use this value to authenticate against the Ably streaming service.

expires_at
number

Your token will be valid until this point in time (specified as milliseconds since the unix epoch).

user_id
string

Your user ID, used to subscribe to events as well as receive the events.

POST/auth
1import requests
2import json
3
4paper_trading_key = 'YOUR-PAPER-TRADING-KEY'
5request = requests.post("https://realtime.lemon.markets/v1/auth",
6          headers={"Authorization": f"Bearer {paper_trading_key}"})
7print(request.json())
Response
1{
2   "expires_at" : 1655856000084,
3   "token" : "_aarfg.Aq8KZTQlsv9n2RtDp9BKf4ZrXLvJW5JDn-bsX3hsLNcjrGaaIc",
4   "user_id" : "usr_qyJDQss5546j0bXjtWtLlRC3B4CNBdmg9V"
5}