In this tutorial, you will learn how to connect the Bitmex REST API to Google Sheets in 5 steps:
To pull data from the Bitmex API to Google Sheets, you’ll have to install and open the Apipheny Google Sheets add-on.
Apipheny is a no-code API integrator for Google Sheets that you can use to make unlimited API requests, connect to unlimited APIs, save API requests, schedule API requests, and more. Click here for more info about Apipheny.
1. Install Apipheny by opening the following link on desktop and then clicking the Install button on the page: https://gsuite.google.com/marketplace/app/apipheny/966163326746
2. After you’ve installed Apipheny, open a Google Sheet and then click on the Add-Ons or Extensions option in the top menu. In the extensions/add-ons menu, you should see Apipheny.
Click Apipheny > Import API to open the Apipheny sidebar in your Google Sheets.
After logging into your Bitmex account, click the API tab and then click the API Key Management option from the menu on the left:
The API Keys page will then be displayed. Complete the Name field, choose Key Permissions from the drop-down list, and then click the Create API Key button:
The API key (ID and Secret) will be displayed on the screen:
Copy and paste your ID and the Secret to safe place because you’ll need them in the next steps.
In this section, we’ll show you how to browse the Bitmex API documentation to find the Bitmex API URL and API endpoint that retrieves the information you need from your Bitmex account.
If you already know your API URL and endpoint, or you want to use the same example URL and endpoint as us, just skip to Step 4.
First, open the Bitmex API documentation page: https://www.bitmex.com/api/explorer/
On this page you’ll find a short description, the base URL, the return types, and all the API endpoints, organized into sections:
All API calls to Bitmex should be made to this base URL:
All endpoints should be appended to this base URL.
An example API section in the Bitmex API documentation is Announcement, which includes two endpoints: /announcement and /announcement/urgent:
The /announcement endpoint uses the following API URL:
Each endpoint’s documentation contains a description of the endpoint’s purpose, the response class, the content type, the available API URL parameters, and the possible response messages:
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:
API URL: In Step 3, we explained how you can find the Bitmex REST API endpoint that you need. Now copy and paste your complete Bitmex API URL into the Apipheny add-on, where it says API URL Path, followed by any parameters required for your query (if applicable).
For this example, we are using the Get /user endpoint, which retrieves your user’s details. This is what the whole URL looks like:
If you’re following the same example as us, you can copy and paste this URL into the “API URL” field in the add-on.
Headers: In the Headers section of Apipheny, add 4 rows with the following keys and values:
Header 1 Key: Api-signature Value: <your_api_signature_value> Header 2 Key: Api-key Value: <your_api_key_value> Header 3 Key: Accept Value: application/json Header 4 Key: api-expires Value: <your_api_expires_value>
The api-signature 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 expires value, we use the https://www.unixtimestamp.com/index.php website. You input the date you want to convert and then click the Convert button. Copy the value in milliseconds to a safe place.
To calculate the signature, we used this site: https://www.freeformatter.com/hmac-generator.html#ad-output.
In the Copy-paste the string here field, we will type the verb, path and expires values, concatenated without any spaces.
In the Secret Key field, we will input the api-secret we previously obtained in Step 2.
Click the COMPUTE HMAC button to display the result. This is the value for <your_api_signature_value>. Copy the result in a safe place, because you’ll need it shortly.
<your_api_key_value> is the value of the api key you previously obtained in Step 2.
<your_api_expires_value> is the value of the expires variable (in milliseconds) that you obtained earlier in this step.
Now that we have all the necessary details, we could write them into the Apipheny add-on like so:
Finally, the last step is to click the Run button at the bottom of the Apipheny add-on and then wait for the Bitmex API data to be imported into your Google Sheet. Here’s what our request looked like when completed:
After making a successful request to the Bitmex API, try querying a different Bitmex API endpoint, or try using one of the more advanced features in the Apipheny add-on, such as: