bitfinexcom / bfx-api-node-rest

MIT License
12 stars 31 forks source link

Feature/url v1 opt #77

Closed vigan-abd closed 3 years ago

vigan-abd commented 3 years ago

Description:

This PR fixes the issues in api/v1 calls that are done through RESTv2 with url https://api-pub.bitfinex.com. A simple case when this occurs is callinge symbolDetails action which returns forbidden in case of api-pub subdomain:

To solve this issue we added an additional option in RESTv2 constructor named urlV1 which would be used when calling the underlying RESTv1 property. This property is optional so it will be compatible with previous versions since it falls back to url option.

Usage example:

const { RESTv2 } = require('bfx-api-node-rest')
const rest = new RESTv2({
  transform: true,
  url: 'https://api-pub.bitfinex.com',
  urlV1: 'https://api.bitfinex.com'
})

const run = async () => {
  const symbols = await rest.symbolDetails()

  console.log('recv %d symbols', symbols.length)
  console.log('first five: %s', JSON.stringify(symbols.slice(0, 5), null, 2))
}

run().catch(e => debug('error: %s', e.stack))

Breaking changes:

New features:

Fixes:

PR status:

vigan-abd commented 3 years ago

Decided to migrate api/v1 to api/v2 calls