An easy way to test out the lemon.markets API is by using Postman, a platform that allows you to make API calls right within your browser or desktop app. This way, before you get to building your brokerage product, youâll know exactly whatâs possible. Weâve set up a lemon.markets Postman workspace that can be used to familiarise yourself with the endpoints that we offer in our Market Data and Trading APIs. Youâll see just how simple it is to, for example, place a trade with lemon.markets (hint: itâs just one API call).
Why Postman? đŻ
Postman is an easy-to-use application that allows you to test out an API without having to manually set up a testing environment. Itâs as simple as filling in a request URL, providing the proper authorisation and inputting the relevant query/request body parameters. Luckily for you, weâve already set up a lemon.markets Postman workspace with all requests included, all you need to do is fork it, fill in your API key and start sending requests.
Using Postman đ¨
The lemon.markets Postman workspace can be found here. For personal use, you need to import the workspace into your own Postman account. Letâs see how thatâs done!
Forking the workspace đ´
Weâre assuming you already have a Postman account, but if you donât, you can easily set one up, here. Because the workspace is public, you need to fork it into your own workspace to be able to send requests.
Youâll be prompted to give the fork a name and select a workspace to copy it into. You can choose to create a separate lemon.markets workspace, or simply copy it into the default âMy Workspaceâ.
To make requests, youâll need to set up several environment variables â weâve also set up a template for this (which you can also fork in the same way).
Configuring the environment đł
To set-up your environment, youâll want to fill in your lemon.markets API key (this can be found on your dashboard). Because your workspace is only accessible to you, it doesnât matter whether you fill it in under âInitial Valueâ or âCurrent Valueâ, but as a best practice, you should always fill in sensitive information under âCurrent Valueâ. This prevents the information from being synced with the Postman workspace (especially important if youâre working in a (semi-)public workspace).
If you already know which Space youâd like to operate in, you can also fill in the ID here. But, if you still need to create a Space or donât know its ID, weâll show you how you can use the Trading API workspace to access this information.
Make sure you save any changes (upper right-hand corner) and set the environment active, you can do this by hovering over its name and clicking the check-mark, which should become grey upon success.
If youâve properly set up your API key and environment, the environment should appear in the upper right-hand corner (as can be seen in the screenshot below). Additionally, if you navigate to the authorisation tab for either Collection, hovering over {{API-KEY}}
should display the key youâve filled in.
Making your first request â
Letâs begin by getting a list of our Spaces. Navigate to the âSpaceâ folder in the Trading API collection. Here, you have the option to retrieve a list of Spaces or a single Space, but also to create, delete and alter a Space (these are all the functionalities that our /spaces/ endpoint offers).
The API response can be found in the console below after clicking the blue âSendâ button. In the screenshot, my Space âPostman Spaceâ created on 24 November 2021 can be seen (scrolling shows my other Spaces).
You can also specify query parameters in your request. In this case, you can choose to filter by Paper Money and Real Money Spaces, all you need to do is toggle the âtypeâ key, fill in a value and run the request again. More on that in the next section. đ
Other important considerations đ¤
To get the most of the lemon.markets workspace, we recommend you read the following tips:
Some endpoints, for example the /ohlc/ endpoint in our Historical Market Data API, have mandatory query parameters. For all query parameters that are required, weâve configured the workspace to automatically toggle that parameter (indicated by the checked box). But, whether it is optional or required can also be found in the key-value description. In addition, some requests also require path variables as input â these are listed below any query parameters (they can also be recognised in the request URL by a â:â). If specified, these are always required.
Other endpoints require a request body, youâll recognise this by the green dots next to the headers underneath the request URL. For example, for the /orders/ endpoint in our Trading API, youâll notice the green dot next to âBodyâ, this means that we need to fill in information here. Notice that thereâs a lot of required variables here! Iâve filled in some example values below.
All other requests follow a similar format â some require you to fill in both âParamsâ and âBodyâ variables. Keep an eye out for those green dots!
Youâre ready to explore on your own! How about you try placing and activating a trade? And then having a look at your portfolio? Have a look at our documentation to see whatâs possible.
Over to you! đ¤
We want to know how we can make this collection better! If thereâs any improvements that come to mind, do not hesitate to reach out to us through Twitter, Instagram or Slack. And remember, if you havenât signed up to lemon.markets yet, do that now to kickstart your automated trading journey.
Joanne from lemon.marketsđ
Top comments (0)