@elevenyellow.com/switchain-api-client

4.0.0 • Public • Published

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 })

Dependents (1)

Package Sidebar

Install

npm i @elevenyellow.com/switchain-api-client

Weekly Downloads

2

Version

4.0.0

License

ISC

Unpacked Size

6.65 kB

Total Files

5

Last publish

Collaborators

  • agustind
  • mikemneves
  • fagenorn
  • alexsdao
  • enzo
  • chemuto
  • garbolino
  • dcusan
  • elevenyellow
  • ajamardo
  • cook1e-monster
  • javiercarceller