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


blog photo
Marius SprengerDecember 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!

Title Card for "How to access your lemon.markets Trading API Account with one API call"

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

blog photo

Blog 38 - The market maker explained

Market Makers are crucial to provide liquidity to stock exchanges. In this blog post, we talk about what Market Makers do and why they are useful.

blog photo

5 (+1) YouTube channels for FinTech enthusiasts 

YouTube is a great way to learn about new things, including financial education or coding. Therefore, in this article we’d like to introduce you to 5 YouTube channels to level up your trading literacy.

blog photo

A short introduction to derivatives

In this article, we'd like to introduce you derivatives - they come up in finance and leave a lot of people scratching their heads, though it's totally worth it! Curious about hearing what's the difference between investing and trading, the coherence between finance and weather & why the Greeks even appear here? We'll discuss who’s using them, what they are and how they can be valued in the following.

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
© lemon.markets 2021Privacy PolicyImprint
All systems normal

As a tied agent under § 3 Sec. 2 WplG on the account and under the liability of DonauCapital Wertpapier GmbH, Passauer Str. 5, 94161 Ruderting (short: DonauCapital), lemon.markets GmbH offers you the receipt and transmission of orders for clients (§ 2 Sec. 2 Nr. 3 WpIG) of financial instruments according to § 3 Sec. 5 WpIG as well as brokerage of accounts.