Git Product home page Git Product logo

api_doc_en's People

Contributors

bitforexapi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

api_doc_en's Issues

Node JS SignData Invalid for API placeOrder

Hello, Im trying to make a trading API for Bitforex but I am running into signData invalid problem, I see this thread https://github.com/bitforexapi/API_Doc_en/issues/10 had a similar problem and a poster recommended re-ordering the parameters, I tried alphabetizing and encodingURI like https://github.com/bitforexapi/API_Doc_en/issues/5 thread recommends and still get the same error, does anyone have ideas? Below is my code

const Crypto = require('crypto') // Standard JavaScript cryptography library const request = require('request') // "Request" HTTP req library const config = require('./config') const bitforex = https://api.bitforex.com`;
const api = "API";
const apiSecretUnencoded = "API_Secret";
let apiSecret = encodeURI(apiSecretUnencoded)
let price = 0;
let amount = 0;
let tradeType = 1; // tradeType 1 is buy , tradeType 2 is sell
let symbol = "coin-usdt-eth";

let nonce = Date.now();
let apiPath = /api/v1/trade/placeOrder?amount=${amount}&accessKey=${api}&nonce=${nonce}&price=${price}&symbol=${symbol}&tradeType=${tradeType}&signData=
const message = ${bitforex}${apiPath};
console.log("apiPath: "+ apiPath);

const signData = Crypto.createHmac('sha256', apiSecret).digest('hex');// The authentication signature is hashed using the private key
let fullData = ${bitforex}${apiPath}${signData};
console.log("signdata: " + signData);
console.log("");
console.log(${fullData});
const body = {}
const options = {
url: fullData,
headers: {
'content-type': 'application/json',
},
json: true
}

request.post(options, (error, response, body) => {
console.log(body); // Logs the response body
})`

Error Response1011

    access_key = setting_data['access_key']
    secret_key = setting_data['secret_key']

    method = "POST"
    param = {
        'accessKey' : access_key,
        'amount' : 0.03,
        'nonce' : datetime.now().timestamp(),
        'price' : 0.01,
        'state' : 0,
        'symbol': 'coin-usd-btc',
        'tradeType' : 1
    }
    
    url_query = createURLQuery(Const.BITFOREX_ENDPOINT_PLACE_ORDER_PATH, param)
    
    sign_data = createSignData(secret_key, url_query)
    param["signData"] = sign_data
    data = json.dumps(param).encode("UTF-8")
    order_infos_req = urllib.request.Request(Const.BITFOREX_PLACE_ORDER_URL, data, method=method)
    order_infos_res = urllib.request.urlopen(order_infos_req)

def createURLQuery(path, param):
    url_query = path + "?"
    for key, value in sorted(param.items()):
        url_query += key + "=" + str(value) + "&"
    
    return url_query[:-1]
    
    
def createSignData(secret_key, content):
    print(content)
    return hmac.new(secret_key.encode("UTF-8"), content.encode('UTF-8'), hashlib.sha256).hexdigest()

↓placeOrder request's responce
{
"code": "1011",
"success": false,
"time": 1562501191642,
"message": "NeedParam accessKey and signData"
}

↓order_infos_req.data
b'{"accessKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "amount": 0.03, "nonce": 1562501190.60496, "price": 0.01, "state": 0, "symbol": "coin-usd-btc", "tradeType": 1, "signData": "d197ae200e7fea43c895b6a091f3a320b31956869809411ffd470e08c4984bdf"}'

Why is Error1011 returned even though both accessKey and signData are included?

API for archived trading data

Make API or other opportunity to download archived trading data. This is very necessary for the development of bots and analytics.

How can I get the API access key.

Hi there,

I'm a mobile developer, especially iOS application.
I'd like to use the api, but this api requests an access key.
So, how can I get the access key?

Thanks

Get all active orders endpoint

Hi! Could you provide api for getting info about all unfilled orders like on most other exchanges? It's need to obtain all orders by each pair, without providing 'orderIds' param

Perpetual Contract

Hi,

Is there an API for the perpetual contracts (market data & trading) or when is it planned?

API call limits

I would like to know if there are any API call limits?

There is an error "1015 | Request too often" so I guess there may be API call limits.

SignData Invalid - Javascript placeOrder

Hi,

I am trying to use the endpoint - https://api.bitforex.com/api/v1/trade/placeOrder
And I do not know what I am doing wrong. I keep getting the following error:

{ code: '1016',
  success: false,
  time: 1554439494501,
  message: 'SignData Invalid' }

But everything looks right, I even double checked my code to ensure the SignData hash is correct based on the example that was given in the API docs.

Anyone got any ideas?

Here's the code:

var crypto = require('crypto')
var axios = require('axios');
var querystring = require('querystring');

var accessKey = 'xxx'
var secretKey = 'secretxxx'

var amount = "1"
var nonce = (new Date).getTime().toString();
var price = "0.00015393"
var symbol = "coin-eth-bf"
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(encodeURI(message));
var signData = hash.digest('hex');

var url_a= 'https://api.bitforex.com/api/v1/trade/placeOrder';

const data = {
    accessKey: accessKey,
    amount: amount,
    nonce: nonce,
    price: price,
    symbol: symbol,
    signData: signData,
    tradeType:tradeType
 };


const options = {
  method: 'POST',
  headers: { 'content-type': 'application/x-www-form-urlencoded' },
  data: encodeURI(querystring.stringify(data)),
  url: url_a
};
axios(options).then(function (response) {
    console.log(response.data);
    })
    .catch(function (error) {
    console.log(error);
    });


Muliti order "SignData Invalid" message.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.