June 21, 2022

MobiDAX Q&A: How to access Peatio API using API key

MobiDAX Q&A: How to access Peatio API using API key

QUESTION: Please explain, how can I send an API request using an API key.

This can be quite a struggle when you're trying to develop some add-ons to Peatio/Opendax stack. We understand your pain, so in this article I will explain it all to you.

I will skip the process of creating an API key. If anybody struggles with creating an API key, please reach out to us on Telegram or comment here.

Let's imagine that we already created an API Key and we have the particular kid and secret:

kid: 1a2r2fmc3m2x2ca
secret: 2b1r5fmcfd1am2fdj212ca

Now, in order ot authenticate your request, you need to have kid, nonce and signature.

The content of those tree variables are presented on a Barong code snippet down below.


In the next steps I will show you how you can get those variables and send an authenticated request:

1. Get the nonce

To get the nonce, run the following command:

date +%s

2. Get the data to be signed

To get the data to be signed, you need to concatenate the output of the previous command with the kid that you got after creating the API Key.


3. Get the signature

To get the signature you need to run the openssl hmac command like this:


4. Use it to send an API request

Now to send an API request you need the following headers:

curl -X GET
-H 'x-auth-apikey: 1a2r2fmc3m2x2ca'
-H 'x-auth-nonce: 1604303788'
-H 'x-auth-signature: f3b455de062fa3dc89c966626661434743bfa4b9b243dbec3e080fdab7f54902'
-H 'cache-control: no-cache'
-H 'content-type: application/json'

5. Websocket connection using API key:

In order to test websocket connection with an API key, you need to execute the following command using wscat

wscat -n -H 'x-auth-apikey: cc86c61d9dd1b5a1' -H 'x-auth-nonce: 1602786123856' -H 'x-auth-signature: 53dd7cdc592427d513acc88131c53506c727fc4bd25386f9dcdca597ba2121da' -c 'wss://'

However, in the current infrastructure you will get the following response. So at the current moment websockets are not supported with API Keys.




Hopefully you enjoyed this explanation provides the answer to your question. Join our Telegram Community as we explore this and many more relevant issues and topics:

Andy Smith

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Id nibh tortor id aliquet.

Subscribe to our email newsletter today!