Telegram Community: t.me/MobiDAX_group
MobiDAX_LinkedIn_banner-1

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.

ANSWER:
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.

Screenshot-2020-11-01-at-12.36.23

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.

Screenshot-2020-11-02-at-09.58.03

3. Get the signature

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

Screenshot-2020-11-02-at-10.01.01

4. Use it to send an API request

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

curl -X GET
https://www.app.local/api/v2/peatio/admin/blockchains
-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://www.app.local/api/v2/ranger/private/?stream=global.tickers&stream=l1cexusdc.trades&stream=l1cexusdc.update&stream=order&stream=trade'

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

Screenshot-2020-11-02-at-10.17.28
Screenshot-2020-11-02-at-10.17.41

-END OF TUTORIAL-

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: t.me/mobidax_group

Website https://mobidax.io
Twitter: https://twitter.com/mobiDAX
Facebook: https://www.facebook.com/MobiDAX
LinkedIn: https://www.linkedin.com/company/mobidax

MobiDAX_LinkedIn_banner-3

cryptocurrency #cryptocurrencyexchange #cryptocurrencytrading #cryptocurrencysoftware #cryptocurrencyexchangesoftware #blockchain #blockchainsoftware #opensource #opensourcesoftware #bitcoin #ethereum #erc20 #digitalassets #tokens #eos #tron #dash #pivx #masternode #dash #monero #cryptonode #peatio #barong #opendax #kyc #liquidity #marketing #regulations #cryptoexchangeregulations #fiatgateways #wallet #cryptocurrencywallet #flutter #graphql #hummingbot #docker #terraform #referral