@elevenyellow.com/switchain-api-client
v4.0.0
Published
client module to access switchains's api
Downloads
9
Maintainers
Keywords
Readme
Install
npm i @elevenyellow.com/switchain-api-client
Docs
https://apidoc.switchain.com/
Initialize
const { init } = require('switchain-api-client')
const SwitchainApi = init({
apiKey: 'xxxxxxxx-yyyy-zzzz-0000-999999999999',
apiUrl: 'http://localhost:3020/rest/v1/' // optional
})
API
getOffers
Returns
{
info: [ { signature, expiryTs, pair, fromChains, toChains, quote, maxLimit, minLimit, minerFees }, ... ]
}
Example
const { info } = SwitchainApi.getOffers()
getOffer
Params
- pair:
string
(required) - amountFrom:
string
- orderIdSeed:
string
Returns
{
offer: {
signature, expiryTs, pair, quote, maxLimit, minLimit
}
}
Example
const { offer } = SwitchainApi.getOffer({
pair: 'ETH-DAI'
})
postOrder
Params
- pair:
string
- toAddress:
string
- refundAddress:
string
- fromAmount:
string
- signature:
string
Returns
{
order: {
orderId, fromAmount, rate, exchangeAddress, toAddress, refundAddress
}
}
Example
const { offer } = SwitchainApi.postOrder({
toAddress,
refundAddress,
pair,
fromAmount,
signature
})
getOrder
Params
- orderId:
string
Returns
{
status: {
status, fromAmount, rate, exchangeAddress, toAddress, refundAddress, toTx
}
}
Example
const { status } = SwitchainApi.getOrder({ orderId })