Authentication

Authentication

This page gives you an overview of everything related to authenticating your API requests.

Environments

The lemon.markets API provides four different environments for you to work in:

  • Market Data: This is where you can find out which instruments are available for trading. You can also use this environment to find out about current prices and trades for those instruments.
  • Paper Trading: You can then go ahead and use the paper trading environment to let a live version of your code trade with paper money.
  • Live Trading: When you are done with development, you can upgrade to the live trading environment in the app. After you complete the onboarding process you can deposit money into your reference account and apply your strategy to real money.
  • Live Streaming: You can use the Live Streaming API to authenticate and initiate a live streaming session, e.g. to subscribe to the quotes for a set of instruments.

Adding a New API Key

To use the lemon.markets API, you need to authenticate your requests with an API key. To get an API key, sign up on our Dashboard, verify your account and log in afterwards.

In the Dashboard, you have the option to create API keys with a custom expiration date. To add a new API key, click on "Create Key". You can create an API key for the these environments:

  • Market Data (which includes Live Streaming)
  • Paper Trading
  • Live Trading (provided you have upgraded your account)

In the dialog presented, you can then specify the name of you API key and how long you want it to be valid. After you click on “Create Key”, the API key is added to your Dashboard. To use it, click on the copy symbol on the right side of the table.

API Key Creation Process

5 API keys per environment

You can create 5 API keys for paper trading, 5 API keys for market data, and 5 for live trading.

You have the option to delete API Keys to make room for new ones.

Using an API Key

To use an API Key and authenticate your request, copy the API Key from your Dashboard.
Place your API Key in the authorization header of your request in the format

"Authorization": "Bearer YOUR-API-KEY"

See an example below.

Authorization Header

In the example on the right, we are retrieving our account using the /account endpoint. The API Key is placed within the authorization header.

GET/account
1import requests
2import json
3
4request = requests.get("https://paper-trading.lemon.markets/v1/account",
5          headers={"Authorization": "Bearer YOUR-API-KEY"})
6print(request.json())