how to place a bitforex api buy order

0

I have read the documentation for BitForex on placing a buy order here: https://github.com/bitforexapi/API_Doc_en/wiki/Order

Then after understanding that, I read the API Call Description documentation: https://github.com/bitforexapi/API_Doc_en/wiki/API-Call-Description

Here is what I have in my code:

var crypto = require('crypto')
var axios = require('axios');
var accessKey = 'xxx';
var secretKey = 'xxx';

var nonce = Date.now().toString();

var amount = "1"
var price = "0.00015393"
var symbol = "coin-eth-bf"

// tradeType 1 is buy , tradeType 2 is sell
var tradeType = "1"
var message = `/api/v1/trade/placeOrder?accessKey=${accessKey}&amount=${amount}&nonce=${nonce}price=${price}&symbol=${symbol}&tradeType=${tradeType}`;

var hash = crypto.createHmac('sha256', secretKey).update(message);
var signData = hash.digest('hex');
axios.post(`https://api.bitforex.com/api/v1/trade/placeOrder?accessKey=${accessKey}&amount=${amount}&nonce=${nonce}price=${price}&symbol=${symbol}&tradeType=${tradeType}`)
    .then(function (response) {
    console.log(response.data);
    })
    .catch(function (error) {
    console.log(error);
    });

I keep getting an error:

{ code: '1011',
  success: false,
  time: xxx,
  message: 'NeedParam accessKey and signData' }

I am currently at a loss to why I keep receive this error. I am passing both the accessKey and signData in. The part that is fuzzy to me is the signData.

  1. Am I creating the signData properly based on the documentation?
  2. Also, am does order matter for the parameters that are being passed
  3. in? Anything else I may potentially be doing wrong?

adbarads

Posted 2019-04-04T04:16:35.710

Reputation: 101

Answers

0

I don't believe you can"t use the $() syntax to concatanate strings in node.

var message = `https://api.bitforex.com/api/v1/trade/placeOrder?accessKey=   ${accessKey} <--  &amount=  ${amount} <-- &nonce=${nonce} and beyond[...]`

you can simply do message = "/api/blahblah" + accessKey

You obviously did this multiple times. If the issue is something different I will return to the question but this seems simple.

Mike Danger Borghi

Posted 2019-04-04T04:16:35.710

Reputation: 1

unfortunately, that is not it. ES6 syntax allows template literals. If you console log message, you'll see it is a proper string, I created following the documentation.

My main concern is, is what I'm doing correct based on the documentation. – adbarads 2019-04-04T14:46:16.913