bitfinexcom / bitfinex-api-node

BITFINEX NodeJS trading API - Bitcoin, Litecoin, and Ether exchange
https://www.bitfinex.com/
MIT License
462 stars 213 forks source link

REST2 Authed Endpoints ['error', 10100, 'apikey: invalid'] vs REST no error. #80

Closed nedievas closed 7 years ago

nedievas commented 7 years ago

Hello, I'm sorry I am so frequent Issue generator, but I have strange issues and I'd like to figure them out. My code:

'use strict'
const BFX = require('bitfinex-api-node')
const API_KEY = 'somekey'
const API_SECRET = 'somesecret'
const opts = {  version: 2,  transform: true }
const bfx = new BFX(API_KEY, API_SECRET, opts).rest
const bfx_rest = new BFX(API_KEY, API_SECRET, {version: 1}).rest

//REST AUTHENTICATED ENDPOINT
bfx_rest.active_orders(function (err, body){
  if (err) return console.log(err)
  console.log('active', body);
})

//REST2 AUTHENTICATED ENDPOINT
bfx.makeAuthRequest('/auth/r/orders', function (err, body) {
  if (err) return console.log(err)
  console.log(body)
})

Output:

[nedievas@nedievas zenbot]$ node rtest.js
null [ 'error', 10100, 'apikey: invalid' ]
REST [ { id: 3007395328,
    cid: 20184473749,
    cid_date: '2017-07-09',
    gid: null,
    symbol: 'xrpusd',
    exchange: null,
    price: '0.29',
    avg_execution_price: '0.0',
    side: 'sell',
    type: 'exchange limit',
    timestamp: '1499578585.0',
    is_live: true,
    is_cancelled: false,
    is_hidden: false,
    oco_order: null,
    was_forced: false,
    original_amount: '1190.0',
    remaining_amount: '1190.0',
    executed_amount: '0.0',
    src: 'web' },
  { id: 3058462591,
    cid: 61242974575,
    cid_date: '2017-07-14',
    gid: null,
    symbol: 'btcusd',
    exchange: null,
    price: '2300.0',
    avg_execution_price: '0.0',
    side: 'sell',
    type: 'exchange limit',
    timestamp: '1500051643.0',
    is_live: true,
    is_cancelled: false,
    is_hidden: false,
    oco_order: null,
    was_forced: false,
    original_amount: '0.28',
    remaining_amount: '0.28',
    executed_amount: '0.0',
    src: 'web' } ]
^C

Thank you.

robertkowalski commented 7 years ago

did you use the api key somewhere else already? have you tried creatign a new one?

i'm on sick leave right now, broke my arm, so i can just answer sporadically...

On Mon, Jul 17, 2017 at 7:26 AM, nedievas notifications@github.com wrote:

Hello, I'm sorry I am so frequent Issue generator, but I have strange issues and I'd like to figure them out. My code:

'use strict' const BFX = require('bitfinex-api-node') const API_KEY = 'somekey' const API_SECRET = 'somesecret' const opts = { version: 2, transform: true } const bfx = new BFX(API_KEY, API_SECRET, opts).rest const bfx_rest = new BFX(API_KEY, API_SECRET, {version: 1}).rest

//REST AUTHENTICATED ENDPOINT bfx_rest.active_orders(function (err, body){ if (err) return console.log(err) console.log('active', body); })

//REST2 AUTHENTICATED ENDPOINT bfx.makeAuthRequest('/auth/r/orders', function (err, body) { if (err) return console.log(err) console.log(body) })

Output:

[nedievas@nedievas zenbot]$ node rtest.js null [ 'error', 10100, 'apikey: invalid' ] REST [ { id: 3007395328, cid: 20184473749, cid_date: '2017-07-09', gid: null, symbol: 'xrpusd', exchange: null, price: '0.29', avg_execution_price: '0.0', side: 'sell', type: 'exchange limit', timestamp: '1499578585.0', is_live: true, is_cancelled: false, is_hidden: false, oco_order: null, was_forced: false, original_amount: '1190.0', remaining_amount: '1190.0', executed_amount: '0.0', src: 'web' }, { id: 3058462591, cid: 61242974575, cid_date: '2017-07-14', gid: null, symbol: 'btcusd', exchange: null, price: '2300.0', avg_execution_price: '0.0', side: 'sell', type: 'exchange limit', timestamp: '1500051643.0', is_live: true, is_cancelled: false, is_hidden: false, oco_order: null, was_forced: false, original_amount: '0.28', remaining_amount: '0.28', executed_amount: '0.0', src: 'web' } ] ^C

Thank you.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bitfinexcom/bitfinex-api-node/issues/80, or mute the thread https://github.com/notifications/unsubscribe-auth/AASMtpx-q498ZUinWUrBYh9PJbclTDYhks5sOvCHgaJpZM4OZj4Q .

nedievas commented 7 years ago

Sure. I created the new key and tested only on this REST2 code. Then checked the same key with REST. REST2 not authed, REST works even with the old keys. I revoked the key and get the same error on REST2 and REST 'Error: 401' ;)

P.S. Please, don't hurry and get well! I'll be on vacation my self for two weeks.

robertkowalski commented 7 years ago

@nedievas https://github.com/bitfinexcom/bitfinex-api-node/pull/88 addresses the issue i believe

nedievas commented 7 years ago

No. Issue stays the same.

lapwat commented 7 years ago

I have got the same error from time to time. If I restart my server 3 times it finally works.

MaxSvargal commented 7 years ago

Websocket API v2 Sometimes on restart node script i see this error. Fixed after 3 restarts.

{ event: 'auth', status: 'FAILED', chanId: 0, code: 10100, msg: 'apikey: invalid' }

robertkowalski commented 7 years ago

hey folks!

good news, we just fixed an error on the server side.

can you double check if you still run into the issue?

thank you!

nedievas commented 7 years ago

@robertkowalski no luck.

robertkowalski commented 7 years ago

@MaxSvargal this issue is about an issue with the REST api client. The websocket issue we had recently was handled in https://github.com/bitfinexcom/bitfinex-api-node/issues/89 and should be fixed.

robertkowalski commented 7 years ago

@nedievas hey, good news, i found the issue. you have to define the second argument:

method signature is:

  makeAuthRequest (path, payload = {}, cb = this.genericCallback) {

payload has a default parameter, however, if you leave it off, it will take the callback as parameters and explode. I'm sending a PR containing a check, to make debugging in the future easier.

thank you for your patience!

whole fixed code:

'use strict'
const BFX = require('bitfinex-api-node')

const API_KEY = 'somekey'
const API_SECRET = 'somesecret'

const opts = {  version: 2, autoOpen: false }
const bfx = new BFX(API_KEY, API_SECRET, opts).rest
const bfx_rest = new BFX(API_KEY, API_SECRET, { version: 1 }).rest

//REST AUTHENTICATED ENDPOINT
bfx_rest.active_orders(function (err, body){
  if (err) return console.log(err)
  console.log('active', body);
})

//REST2 AUTHENTICATED ENDPOINT
bfx.makeAuthRequest('/auth/r/orders', {}, function (err, body) {
  if (err) return console.log(err)
  console.log(body)
})
hhuhhu commented 6 years ago

i've got the same error, on rest version2,

f3rno commented 6 years ago

@hhuhhu are you still seeing it? If so, can you provide more info?

hhuhhu commented 6 years ago

@f3rno it's ok now, thank you

tgmTimsah commented 4 years ago

Bitfinex V2 api for payload:

"/api/v2/auth/w/order/submit1579850962955{\"amount\":\"0.0008\",\"price\":\"8500\",\"symbol\":\"tBTCUSD\",\"type\":\"LIMIT\"}"

I get an error for this load, what is not true , thanks.