Using the lemon.markets Postman workspace 📮
Tags: postman, api, trading, algotrading
Published: 2021-12-21 14:20:20

An easy way to test out the [lemon.markets](https://www.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](https://www.postman.com/lemonmarkets/)** 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](https://www.postman.com/lemonmarkets/workspace/lemon-markets/overview). 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](https://identity.getpostman.com/signup). Because the workspace is public, you need to fork it into your own workspace to be able to send requests.

<figure>
![_Forking the workspace_](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/16mypxtggsifkjuhyylt.png)
<figcaption>To fork our workspace, click the ‘…’ next to the collection of your choice and select ‘Create a fork’.
</figcaption>
</figure>

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).

<figure>
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/llb2dqeae9bkg7zqp695.png)
<figcaption>The environment templates can be found under the conveniently named ‘Environments’ tab on the left hand side.</figcaption>
</figure>

### 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).

<figure>
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8r3agv3alxhs1z9p2pp9.png)
<figcaption>You’ll know you’re in your forked workspace due to the Ψ next to the environment name — notice I’ve called my fork ‘lemon_tutorial’.</figcaption>
</figure>

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](https://medium.com/lemon-markets/introducing-lemon-markets-spaces-890d3c1ea6e) 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.

<figure>
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rrq8afqy4ki2shopmxet.png)
<figcaption>If you can’t see your API key upon hovering, ensure that your environment has been saved and set active (you might need to manually select it in the upper right-hand corner if you have more than one environment).
</figcaption>
</figure>

### 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). 

<figure>
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n8zi0otlrt9kvcw4d13e.png)
<figcaption>If you haven’t filled in a Space ID yet, you can copy one from the desired Space after placing this request and paste it into your environment (remember to save!). You’ll need to place other requests. You can also create a new Space using the POST request that can be found under the same Space header.</figcaption>
</figure>

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**.

<figure>
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/08dhpwzwpj2y56inv7wg.png)
<figcaption>Note that ‘isin’ is the only required query parameter for this endpoint, we also need to specify the path variable ‘x1’ in order to send this request.</figcaption>
</figure>

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.

<figure>
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1dakzjykrhjd94asqj3x.png)
<figcaption>In the above screenshot, you’ll see I placed a buy order for 2 shares of Tesla.
</figcaption>
</figure>

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](https://docs.lemon.markets/) 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](https://twitter.com/lemon_markets), [Instagram](https://www.instagram.com/lemon.markets/) or [Slack](https://join.slack.com/t/lemonmarketscommunity/shared_invite/zt-uld4skdd-NRkts~S249bN8ixc0SMHqA). And remember, if you haven’t signed up to lemon.markets yet, do that [now](https://dashboard.lemon.markets/) to kickstart your automated trading journey.

Joanne from lemon.markets🍋