How to access your lemon.markets Trading API Account with one API call


blog photo
Published by Marius Sprenger on December 16, 2021
Product


We at lemon.markets provide the infrastructure so everyone can build their own brokerage experience at the stock market. In this blog post, we show you how to easily access your trading account information with one simple API call. Additionally, we dive a little deeper into our /account endpoint. Let us begin!

Signing up

The first step to accessing your account is to make sure that you actually have one. So, sign up on our dashboard and verify your account through the email that we send you after registration. You can then sign into the dashboard, where we already provide you with your first API Key. 

Finding your way around our API

Using that API Key, you can go ahead and start testing our API. You can find everything you need to know in our documentation. We created several endpoints concerned with everything related to your account. Using these endpoints, you can find information about your name (in case you forgot), your current balance, how much cash you have left to invest, the IBAN of your brokerage account and many many more things.

To retrieve information about your account, place a GET request against the following request URL:

1https://paper-trading.lemon.markets/v1/account/

You can do so by grabbing the API Key from your dashboard and placing it into the following Python code snippet (find a JavaScript example in our documentation).

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

Placing this request will result in a response similar to this one:

1{
2  "time": "2021-11-22T15:37:56.520+00:00",
3  "status": "ok",
4  "results": {
5    "created_at": "2021-10-12T10:29:49.769+00:00",
6    "account_id": "acc_pyNQNll99hQbXMCS0dRzHyKQCRKYHpy3zg",
7    "firstname": "Michael",
8    "lastname": "Burry",
9    "email": "m_burry@tradingapi.com",
10    "phone": "+491637876521",
11    "address": "Ritterstraße 2A 10969 Berlin",
12    "billing_address": "Ritterstraße 2A 10969 Berlin",
13    "billing_email": "m_burry@tradingapi.com",
14    "billing_name": "Michael Burry",
15    "billing_vat": "DE999999999",
16    "mode": "money",
17    "deposit_id": "K2057263187",
18    "client_id": "2057263",
19    "account_number": "2057263187",
20    "iban_brokerage": "DE12345678902057263",
21    "iban_origin": "DE123456789012345",
22    "bank_name_origin": "Test Bank",
23    "balance": 100000000,
24    "cash_to_invest": 80000000,
25    "cash_to_withdraw": 20000000,
26    "trading_plan": "basic",
27    "data_plan": "basic",
28    "tax_allowance": 8010000,
29    "tax_allowance_start": "2021-01-01",
30    "tax_allowance_end": "2021-01-01"
31  }
32}

As you can see, you get a lot of information on everything related to your account, like when it was created, what your current balance is, on which trading & data plan you are on and the IBAN of your brokerage account. Make sure to check out our documentation for in-depth information on all endpoint response parameters.

Withdrawing money

As you can see in the endpoint response above, you also have a response element called cash_to_withdraw. This is your current balance minus the current sum of your buy orders. Based on that number, you can very easily withdraw money into your reference account via:

1https://trading.lemon.markets/v1/account/

(Note that we are currently still working on releasing the real money feature, so it might take some more time until you can use this endpoint 🙂)

Use the following code snippet (with your own API Key ofc) to withdraw money into your reference account.

1import requests
2import json
3request = requests.post("https://paper-trading.lemon.markets/v1/account/withdraw/",
4          data=json.dumps({
5               amount: 5000000,
6               pin: 1234
7            }), headers={"Authorization": "Bearer YOUR-API-KEY"})
8print(request.json())

Define the amount you want to withdraw in your request body, along with your individual 4-digit PIN that you set during your onboarding process. After a successful API request, the specified amount is automatically withdrawn.

Seeing some documents

Lastly, you have the chance to very easily access all important documents related to your account via the following URL:

1https://paper-trading.lemon.markets/v1/account/documents

Use the following code snippet, extended by your own API Key, to retrieve a list of documents:

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

This will provide you with a list similar to this one:

1{
2  "time": "2021-11-22T15:41:04.028+00:00"
3  "status": "ok",
4  "results": [
5    {
6      "id": "doc_pyNjNcc77ht3T3lH8dJa5fD8jhj2JHJ1xX",
7      "name": "account_opening.pdf",
8      "created_at": "2021-10-19T14:58:52.813Z",
9      "category": "kyc",
10      "public_url": "http://testpublicurl.de/",
11      "link": "'https://trading.lemon.markets/v1/account/documents/doc_pyNjNcc77ht3T3lH8dJa5fD8jhj2JHJ1xX",
12      "viewed_first_at": "2021-10-19T14:58:52.813Z",
13      "viewed_last_at": "2021-10-19T14:58:52.813Z"
14    }
15  ]
16}

In there, you find all documents, along with a download link. By clicking the link, you are redirected to a .pdf version of the file.

Alright, that was all there is to say about thelemon.markets account endpoints and what you can do with them. Make sure tosign up to our trading API to build your own brokerage experience at the stock market. Also, join ourSlack community, where we discuss all things trading and lemon.markets with more than 400 developers.

Looking forward to seeing you there 🍋 🚀

Marius from lemon.markets

You might also be interested in

Exploring the lemon.markets instruments endpoint

blog photo

The /instruments endpoint can be used to search the 8250+ stocks and ETFs we currently offer on lemon.markets. You can customise your search with as much detail as you’d like by specifying the exchange, currency, type and other characteristics. Continue reading if you’d like to learn more.

Manage your trading portfolio with the lemon.markets brokerage API

blog photo

Placing your first order with the lemon.markets Trading API

blog photo

With the lemon.markets API, placing an order is only one API call. But kind of information do you need to include in your request? In this blog post we walk you through how to successfully place an order and how to activate it with the trading API, such that it is placed and filled on the exchange of your choice. Keep reading to learn more.

Dive Deeper

Find more resources to get started easily

Check out our documentation to find out more about our API structure, different endpoints and specific use cases.

Engage

Join lemon.markets community

Join our Slack channel to actively participate in our community, ask questions to other users and stay up to date at all times.

Contribute

Interested in building lemon.markets with us?

We are always looking for great additions to our team that help us build a brokerage infrastructure for the 21st century.

Need any help?
Ask a question in our CommunityAsk a question in our CommunityGet started with our DocumentationGet started with our DocumentationGet inspired on our BlogGet inspired on our Blog
For Developers
SlackGithubBlog
© lemon.markets 2021Privacy PolicyImprint
All systems normal