1.6.0 • Published 2 years ago
bfx-api-mock-srv v1.6.0
Bitfinex API Mock Server
This repo hosts mock servers for the WSv2 and RESTv2 Bitfinex APIs, and is intended for testing the Bitfinex API libraries.
Features
- Provides realistic API responses for WSv2
- Provides configurable responses for RESTv2
- Allows for basic testing of API libraries without a live API connection
Installation
npm i --save bfx-api-mock-srv
Quickstart & Example
const assert = require('assert')
const debug = require('debug')('bfx:api:mock-srv:examples:endpoint-test')
const { MockRESTv2Server } = require('bfx-api-mock-srv')
const { RESTv2 } = require('bfx-api-node-rest')
debug('spawning mock server...')
const srv = new MockRESTv2Server({ listen: true })
const rest = new RESTv2({
apiKey: 'dummy',
apiSecret: 'dummy',
url: 'http://localhost:9999',
})
const fundingOffer = [
41215275, 'fUSD', 1524784806000, 1524784806000, 1000, 1000, 'FRRDELTAVAR',
null, null, 0, 'ACTIVE', null, null, null, 0, 30, 0, 0, null, 0, 0.00207328
]
srv.setResponse('f_offers.fUSD', [fundingOffer])
debug('requesting preset response...')
rest.fundingOffers('fUSD').then(([incomingFundingOffer]) => {
assert.deepStrictEqual(incomingFundingOffer, fundingOffer)
debug('correct response received')
srv.close()
}).catch((e) => {
debug(`error: ${e.message}`)
})
Docs
- See
docs/reference.md
for API documentation - Refer to
examples/
for executable examples
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
1.6.0
2 years ago
1.5.0
2 years ago
1.4.0
2 years ago
1.3.0
2 years ago
1.2.0
4 years ago
1.1.6
4 years ago
1.1.5
4 years ago
1.1.4
4 years ago
1.1.3
4 years ago
1.1.2
4 years ago
1.1.1
4 years ago
1.0.16
5 years ago
1.0.15
5 years ago
1.0.14
5 years ago
1.0.12
5 years ago
1.0.11
5 years ago
1.0.10
5 years ago
1.0.7
5 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.3
5 years ago
1.0.2
5 years ago
1.0.1
6 years ago
1.0.0
6 years ago