​
Welcome to Swapzone.io! Our cryptocurrency exchange aggregator is gathering the instant swap platforms into one interface with the use of service provider’s APIs. To get you started off easily, we have written a unified adapter – all you need to do is copy it for your service and prepare for launch at Swapzone.
If you would like to chat or get more information on partnering with us, you can join our Telegram group or reach out directly at [email protected].
We are constantly expanding the range of services supported for exchanges and currencies supported. Of course, we are always open to future service integrations if the partners share our values.
Integrate your instant exchange service to swapzone.io with the use of our adapter – the Interface
-type JavaScript object. Interface
is a wrapper of the Adapter class that is meant to execute Adapter pattern. It also ensures interaction methods to be universal and data to be normalized. As the following steps are fulfilled, please drop us a message at [email protected]
The structure of Adapter class provided below:
const axios = require('axios');const Interface = require('../interface');/*** Adapter class*/class AdapterName extends Interface {constructor() {super();//the method is derived from Interface to set a unique key//to your adapterthis.registerMemdata({ key: 'adaptername' });this.request = axios.create({baseURL: 'https://yourapiurl.com',});}​async getCurrencies() {const { data } = await this.request.get('get-currencies');const currencies = data.currencies.map(currency => currency.ticker.toLowerCase());return currencies;}​async getLimit({ from, to }) {const { data } = await this.request.get('get-limits', {params: {from,to}});​return {from,to,min: data.limits.min || null,max: data.limits.max || null,};}​async getEstimate({ from, to, amount }) {const sendParams = {from,to,amount,};​const { data } = await this.request.post('get-estimate', sendParams);​return {from: currencyFrom,to: currencyTo,amountFrom: amount,amountTo: data.estimate,};}​async createOrder({ from, to, amount, addressReceive, extraIdTo }) {const sendParams = {from,to,amount,addressReceive,extraIdTo,};​const { data: createdOrder } = await this.request.post('create-order', sendParams);​const order = {status: 'waiting',from,to,orderId: createdOrder.data.orderId,addressReceive,addressDeposit: createdOrder.data.exchangeAddress.address,extraIdDeposit: createdOrder.data.exchangeAddress.tag || '',};​return order;}​async getOrderData(orderId) {const { data: orderData } = await this.request.get(`get-order-data/${orderId}`);​const updateData = {status: orderData.status || 'waiting',amountReceive: orderData.depositCoinAmount,};​return updateData;}}
Method to obtain the currencies available for exchange at your service. As a result, the entries of currencies get returned in the lower register.
Input parameters not defined.
Type | Description |
Array | Entries of currencies returned in the lower register |
Example:
['btc', 'eth', 'xrp', ...]
Method returning min and max exchange limits of deposited currency within an available exchange pair.
Object containing fields:
Name | Type | Description |
from | String | Ticker of the exchanged currency |
to | String | Ticker of the currency to receive after exchange |
Example:
{from : 'btc',to: 'eth'}
Name | Type | Description |
from | String | Ticker of exchanged currency |
to | String | Ticker of the currency to receive after exchange |
min | Number || String || null | Minimal amount of currency to deposit |
max | Number || String || null | Maximum amount to currency to deposit |
Example:
{from : 'btc',to: 'eth'min: 0.001,max: 10}
If an exchange pair is unavailable, the object is returned with an error:
{ error: 'pair is unavailable for exchanges' }
Method returning estimated amount to currency to receive after exchange
Object containing fields:
Name | Type | Description |
from | String | Ticker of the currency to deposit for exchange |
to | String | Ticker of the currency to receive after exchange |
amount | String | Exchange deposit amount |
Example:
{from : 'btc',to: 'eth',amount: '0.01'}
Object containing fields:
Name | Type | Description |
from | String | Ticker of the currency to deposit for exchange |
to | String | Ticker of the currency to receive after exchange |
amountFrom | Number || String | Exchange deposit amount |
amountTo | Number || String | Amount to receive after exchange |
Example:
{from : 'btc',to: 'eth'amountFrom: 0.01,amountTo: 0.4817753}
If an exchange pair is unavailable, the object is returned with an error:
{ error: 'pair is unavailable for exchanges' }
Method to create the exchange transaction order.
Object containing fields:
Name | Type | Description |
from | String | Ticker of the currency to deposit for exchange |
to | String | Ticker of the currency to receive after exchange |
amount | String | Exchange deposit amount |
addressReceive | String | Receiving address |
extraIdTo? | String | Transaction ID (optional) |
Example:
{from : 'btc',to: 'eth',amount: '0.01',addressReceive: '0xeAe68187a1d54524d4b4717DBC08222d8f4A386D'extraIdTo: ''}
Object containing transaction data:
Name | Type | Description |
status | String | Transaction status (default: 'waiting') |
from | String | Ticker of the currency to deposit to exchange |
to | String | Ticker of the currency to receive after exchange |
orderId | String | Transaction ID |
addressReceive | String | Receiving address |
addressDeposit | String | Exchange deposit address |
extraIdDeposit | String | Deposit transaction ID (optional) |
Example:
{status: 'waiting',from : 'btc',to: 'eth',orderId: '0d14b3s12g9'addressReceive: '0xeAe68187a1d54524d4b4717DBC08222d8f4A386D',addressDeposit: '1MNLT2LWQST1VCEc2xc9qF6eqHdW8mGsfQ',extraIdDeposit: ''}
Method returning current transaction status.
Object containing fields:
Name | Type | Description |
orderId | String | Transaction ID |
Object containing transaction data. The fields may vary depending on transaction status:
Name | Type | Description |
status | String | Transaction status |
hashDeposit? | String | Transaction hash (from) |
hashReceive? | String | Transaction hash (to) |
addressReceive? | String | Receiving address |
extraIdReceive? | String | Receiving transaction ID |
amountDeposit? | Number || String | Amount of currency deposited |
amountReceive? | Number || String | Amount of currency received |
Example:
{status: 'waiting',hashDeposit: '',hashReceive: '',addressReceive: '0xeAe68187a1d54524d4b4717DBC08222d8f4A386D',extraIdReceive: '',amountDeposit: 0.01,amountReceive: 0.4817753,}
​