coinswitch-v2
Browser and Node.js Coinswitch.co API v2 client
Easily exchange crypto coins with few lines of code.
Install
npm install --save coinswitch-v2
Usage
const { CoinSwitchDynamic } = require('coinswitch-v2')
;(async () => {
const cs = new CoinSwitchDynamic({
apiKey: '<YOUR API KEY>',
userIP: '<YOUR IP>'
})
const coins = await cs.getCoins()
console.log(coins)
const rate = await cs.getExchangeRate({
depositCoin: 'btc',
destinationCoin: 'eth',
depositCoinAmount: 0.03
})
console.log(rate)
const order = await cs.createOrder({
depositCoin: 'btc',
destinationCoin: 'eth',
depositCoinAmount: 0.03,
destinationAddress: {
address: '0xcc1bf6b0625bc23895a47f4991fdb7862e34a563'
},
refundAddress: {
address: '0xcc1bf6b0625bc23895a47f4991fdb7862e34a563'
}
})
console.log(order)
})()
NB: Addresses must be specified as a JS Object like {address: "...", tag: "..."}
API KEY
Get your api-key from the coinswitch API page.
Example
For more examples look into the __tests__
folder on GitHub.
Test
npm test
License
MIT