⭐️ This procedure assumes you have already successfully completed this tutorial: How to connect Bitmex to Google Sheets
Make sure you have installed Apipheny and have already successfully imported Bitmex API data into your Google Sheet and are familiar with such processes before commencing this next stage.
In this tutorial we will show you how to connect your Google Sheet to a Bitmex Testnet account and place a market order in a simulated trading environment.
These steps will show you how to setup and place market orders on Bitmex Testnet. If you successfully complete the steps then it should be relatively easy to transition to a live account on Bitmex.
Login (or register) on the Bitmex Testnet: https://testnet.bitmex.com/
Next, select Information > API Documentation > API Key Management and then create your API Key and Secret. Note both values down for use in later steps.
Open the Bitmex Testnet API documentation page: https://testnet.bitmex.com/api/explorer/
Note that the base URL for Testnet is: https://testnet.bitmex.com/api/v1
To enable us to place at market orders we will use the following endpoint on Testnet: https://testnet.bitmex.com/api/v1/order
Note: make sure the v in the url is lower case
Now go back to your Google Sheet and make sure that the Apipheny add-on is open on the Import tab. With the Import tab open, enter these details into the add-on:
Method: At the top of the Apipheny sidebar, select the HTTP method POST
API URL: Now copy and paste the following URL into Apipheny, where it says API URL Path:
https://testnet.bitmex.com/api/v1/order
Headers: In the Headers section of Apipheny, add 4 rows with the following keys and values:
Header 1 Key: api-key Value: your_api_key (obtained in Step 1)
Header 2 Key: accept Value: application/json
Header 3 Key: api-expires Value: api_expires_value (see below to calculate)
Header 4 Key: api-signature Value: api_signature_value (see below to calculate)
To calculate the api_expires_value, we used https://www.unixtimestamp.com/index.php. You input the date you want to convert and then click the Convert button. Copy the value in milliseconds and input as the value in Header 3. In this case we used a value of 1678360193.
POST Body:
In Apipheny, below the Headers section, you will see a section titled POST Body (when you choose the POST method).
The POST body will contain your order details and it will also need to be incorporated in the api_signature_value calculation of Header 4.
In order to complete an at market Buy order on Testnet, copy and paste the following string in the POST Body:
{"symbol":"XBTUSD","orderType":"market","orderQty":100}
Make sure there are no spaces, and commas and quotation marks are in the right place. In addition, when filling in the POST Body, do it exactly as detailed in the screenshot shown below.
The api_signature_value is a signature of the request you are making. It is calculated as hex(HMAC_SHA256(apiSecret, verb + path + expires + data))
, where:
To calculate the api_signature_value, we used this site: https://www.freeformatter.com/hmac-generator.html#ad-output.
Click the COMPUTE HMAC button to display the result. This is the value for your_api_signature_value. Copy the result to the value for Header 4.
Here’s what it looked like for us:
Here is the output of our HMAC generation:
The Computed HMAC value should be placed in the value for Header 4
OK, nearly there. The screenshot on the next page shows how the Apipheny add-on should be completed. Make sure you carefully replicate this.
The screenshot below shows your Google Sheet ready to place an at market Buy order for $100 via the Apipheny add-on.
Finally, the last step is to click the Run button at the bottom of the Apipheny add-on and then wait for the at market order to be executed and Bitmex Testnet API data to be imported back into your Google Sheet. Here’s what our request looked like when completed:
That’s it! That’s how to connect your Bitmex Testnet account to Google Sheets using the Bitmex Testnet API and the Apipheny add-on and how to place a market Buy order directly from your Google Sheets.
If you have received an invalid signature error – go back and check you have carefully followed the instructions exactly. Simply missing a comma, adding a space, or incorrect punctuation can cause an error.
If these steps have worked for you then you can try further experimentation. For example, a sell order would use -100
as the orderQty
. The good thing about using Apipheny with Testnet is that you can experiment as much as you want in a safe and simulated environment.
Wishing you good luck!
Crypto API tutorials and more:
Crypto API tutorials and more:
Sponsored by Zink Virtual Tip Jar & Rewording.io Paraphrasing Tool
Accept donations on Twitch | Accept donations on Discord | Accept donations on YouTube | Accept donations on Telegram | Accept donations on Twitter | Accept donations on TikTok | Accept donations on Instagram | Accept donations on LinkedIn | Accept donations on Facebook | Accept donations on your Website