NAV
javascript

Introduction

Version: 1.0.0

Welcome to the Changer!

We provide set of APIs including obtaining token exchange quotes, account authentication and registration, performing transactions, checking asset balances, and processing deposits and withdrawals.

Authentication

const jwt = require("jsonwebtoken");

const payload = {
  accessKey: "<access_key>",
  secretKey: "<secret_key>",
  userKey: "<user_key>",
  nonce: "<Random String>",
};
const jwtToken = jwt.sign(payload, "<secret_key>");
console.log(`token : ${jwtToken}`);

The above command returns the string object like this:


  "token": "<token>"

There are two types of api endpoints. They are public and private endpoints. You can always use the public endpoints without our help.
However, you should use API keys to grant access for the private endpoints. Please contact help@changer.io to create them.

Then, you can get a API keys which consists of a access key(access_key) and a secret key(secret_key).

Next, generate a jwt token with your API keys by referring to the example code. The token should be included in Private API requests to the server in the Authorization header, which looks like the following:

Authorization: Bearer <token>

REST Endpoints

Endpoint Description
Production https://api.changer.io

Convert

Get Currencies

const request = require("request");
const options = {
  method: "GET",
  url: "https://api.changer.io/d1/currencies?advanced=true&type=ALL&networks=ALL",
  headers: {
    "Content-Type": "application/json",
  },
};

request(options, function (error: any, response: any) {
  if (error) throw new Error(error);
  console.log(response.body);
});

The above command returns JSON structured in the following format:

{
  "status": "ok",
  "data": [
    {
      "name": "eth",
      "fullName": "Ethereum",
      "icon": "https://d3b3jih2de01vz.cloudfront.net/token_icons/eth_1027.png",
      "address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
      "mainnet": 1,
      "id": "5cdaab544fee8b2a6dd64e7e"
    }
  ],
  "totalCount": 1
}

Description

Retrieves a list of tokens that can be converted within the changer.

HTTP Request

GET /d1/currencies

Parameters

Name Location Description Required Type
advanced query This field indicates whether to return the complete currency list from various networks. For example, If set to true, it will return the list of currencies named ETH from multiple networks. If set to false, it will only return ETH on Ethereum network. Yes boolean
type query It means the category of searching and takes a enum types. (recommended: ALL) Yes boolean
networks query List of networks. If it is set to BNB, we will only return the BNB currency. We could take one of the followings. ALL,NON_EVM,ETHEREUM,BNB,GNOSIS,POLYGON,OPTIMISM,ARBITRUM,AVALANCHE,FANTOM,AURORA,KLAYTN Yes array[string]
start query The starting position of the results to be retrieved. (default: 0) number
length query The number of result items to be displayed per page. (default: 10) number
query query This field is a keyword to search with (i.e. ETH) string

Quote

const request = require("request");
const options = {
  method: "GET",
  url: "https://api.changer.io/d1/convert/quote?fromToken=5cdaab544fee8b2a6dd64e7e&toToken=639a024888d87841dec0ba40&amount=1",
  headers: {
    "Content-Type": "application/json",
  },
};

request(options, function (error: any, response: any) {
  if (error) throw new Error(error);
  console.log(response.body);
});

The above command returns JSON structured in the following format:

{
  "status": "ok",
  "quote": {
    "amount": "22613.723044151304206012",
    "fromToken": "eth",
    "toToken": "cng",
    "priceImpact": "-3.433821080334917842"
  }
}

Description

Retrieve the best exchange quote available through Changer.

HTTP Request

GET /d1/convert/quote

Parameters

Name Location Description Required Type
fromToken query Id of a currency to sell. (i.e. 5cdaab544fee8b2a6dd64e7e) Yes string
toToken query Id of a currency to buy. (i.e. 639a024888d87841dec0ba40) Yes string
amount query amount of a currency to sell. (i.e. 1.00 ETH set as 1) Yes string
slippage query The limit of price slippage you are willing to accept, in percentage, can be set with decimals. For example, '&slippage=0.5' means a slippage of 0.5% is acceptable. Low values increase the chances of transaction failure, while high values increase the chances of front-running. Set values in the range from 0 to 50 number

Convert

const request = require("request");
const reqBody = JSON.stringify({
  fromToken: "5cdaab544fee8b2a6dd64e7e",
  toToken: "639a024888d87841dec0ba40",
  amount: 1,
});
const options = {
  method: "POST",
  url: "https://api.changer.io/d1/convert",
  headers: {
    Authorization: "Bearer <token>",
    "Content-Type": "application/json",
  },
  body: reqBody,
};

request(options, function (error: any, response: any) {
  if (error) throw new Error(error);
  console.log(response.body);
});

The above command returns JSON structured in the following format:

{
  "status": "ok",
  "id": "6486aba4bc9afdd0b5e116e2"
}

Description

Execute the transaction using Changer. You can retrieve the conversion request status by calling the Get Convert History API with the id value from the response data.

HTTP Request

POST /d1/convert

Request Body

Name Location Description Required Type
fromToken query Id of a token to sell. (i.e. 5cdaab544fee8b2a6dd64e7e) Yes string
toToken query Id of a token to buy. (i.e. 639a024888d87841dec0ba40) Yes string
amount query amount of a token to sell. (i.e. 1.00 ETH set as 1) Yes string
slippage query The limit of price slippage you are willing to accept, in percentage, can be set with decimals. For example, '&slippage=0.5' means a slippage of 0.5% is acceptable. Low values increase the chances of transaction failure, while high values increase the chances of front-running. Set values in the range from 0 to 50. Set values in the range from 0 to 50 number

Get Convert Histories

const request = require("request");
const options = {
  method: "GET",
  url: "https://api.changer.io/d1/convert/history",
  headers: {
    Authorization: "Bearer <token>",
    "Content-Type": "application/json",
  },
};

request(options, function (error: any, response: any) {
  if (error) throw new Error(error);
  console.log(response.body);
});

The above command returns JSON structured in the following format:

{
  "status": "ok",
  "totalCount": 1275,
  "convertHistories": [
    {
      "status": "completed",
      "toCurrencyAmount": "0.01",
      "fromCurrencyAmount": "20",
      "toCurrency": {
        "mainnet": 56,
        "name": "eth",
        "id": "631fdf7148dd587369eb71b5"
      },
      "fromCurrency": {
        "mainnet": 137,
        "name": "usdt",
        "id": "631fdfa648dd587369eb73df"
      },
      "createdAt": "2023-05-23T06:02:45.673Z",
      "id": "646c57059c1303822a5e835e"
    }
  ]
}

Description

Retrieve a list of conversion histories.

HTTP Request

GET /d1/convert/history

Parameters

Name Location Description Required Type
start query The starting position of the results to be retrieved. (default: 0) number
length query The number of result items to be displayed per page. (default: 10) number
startDate query The starting date of the desired date range for retrieving results. (i.e. 2023-01-01) string
endDate query The ending date of the desired date range for retrieving results. (i.e. 2023-06-01) string
status query The status of transaction. the status can have three possible values: pending,completed,failed. It is a comma-separated string format. (i.e. status=pending,completed) string

Get Convert History

const request = require("request");
const options = {
  method: "GET",
  url: "https://api.changer.io/d1/convert/history/6481544524bc20d4b541fba5",
  headers: {
    Authorization: "Bearer <token>",
    "Content-Type": "application/json",
  },
};

request(options, function (error: any, response: any) {
  if (error) throw new Error(error);
  console.log(response.body);
});

The above command returns JSON structured in the following format:

{
  "status": "ok",
  "convertHistory": {
    "status": "completed",
    "toCurrencyAmount": "0.01",
    "fromCurrencyAmount": "20",
    "toCurrency": {
      "mainnet": 56,
      "name": "eth",
      "id": "631fdf7148dd587369eb71b5"
    },
    "fromCurrency": {
      "mainnet": 137,
      "name": "usdt",
      "id": "631fdfa648dd587369eb73df"
    },
    "createdAt": "2023-05-23T06:02:45.673Z",
    "id": "646c57059c1303822a5e835e"
  }
}

Description

Retrieve a conversion history by convert history id. The convert history id can be obtained by calling the Convert API

HTTP Request

GET /d1/convert/history/{id}

Balance

Get Asset Balances

const request = require("request");

const options = {
  method: "GET",
  url: "https://api.changer.io/d1/balances",
  headers: {
    Authorization: "Bearer <token>",
    "Content-Type": "application/json",
  },
};

request(options, function (error: any, response: any) {
  if (error) throw new Error(error);
  console.log(response);
});

The above command returns JSON structured in the following format:

{
  "status": "ok",
  "totalCount": 40,
  "balances": [
    {
      "available": "1709.695335879769638368",
      "locked": "670.5771748888974567",
      "account": "5fbdea23d41b4c40cc21243b",
      "currency": {
        "name": "usdt",
        "mainnet": 1,
        "id": "5cdaab544fee8b2a6dd64e7c"
      },
      "id": "5fd10cdec18c5246fc77ba9f"
    }
  ]
}

Description

Retrieve a list of asset balances.

HTTP Request

GET /d1/balances

Deposit

Get Deposit Address

const request = require("request");
const options = {
  method: "GET",
  url: "https://api.changer.io/d1/depositAddr/5cdaab544fee8b2a6dd64e7e",
  headers: {
    Authorization: "Bearer <token>",
    "Content-Type": "application/json",
  },
};

request(options, function (error: any, response: any) {
  if (error) throw new Error(error);
  console.log(response.body);
});

The above command returns JSON structured in the following format:

{
  "status": "ok",
  "depositAddress": {
    "currency": {
      "name": "eth",
      "id": "5cdaab544fee8b2a6dd64e7e"
    },
    "assigned": true,
    "address": "0x3871D319939e09059e845670ecd95f277d116c3F",
    "account": "5fbdea23d41b4c40cc21243b",
    "createdAt": "2023-03-23T04:56:04.560Z",
    "id": "641bdbe429706a57f6284fd6"
  }
}

Description

Retrieve an address to deposit a specific currency.

HTTP Request

GET /d1/depositAddr/{currencyId}

Create Deposit Address

const request = require("request");
const options = {
  method: "POST",
  url: "https://api.changer.io/d1/depositAddr/assign/63dafda78a1c309f1e8092b4",
  headers: {
    Authorization: "Bearer <token>",
    "Content-Type": "application/json",
  },
};

request(options, function (error: any, response: any) {
  if (error) throw new Error(error);
  console.log(response.body);
});

The above command returns JSON structured in the following format:

{
  "status": "ok",
  "depositAddress": {
    "currency": {
      "name": "eth",
      "id": "631fe12848dd587369eb82b1"
    },
    "assigned": true,
    "address": "0x73829F648E2D4CF13E7b47000FA487B500092923",
    "account": "5fbdea23d41b4c40cc21243b",
    "createdAt": "2023-06-07T09:23:59.829Z",
    "id": "64804cafe4cc469950afbf71"
  }
}

Description

Generate a deposit address on Changer for the initial deposit of a specific token.

HTTP Request

POST /d1/depositAddr/assign/{currencyId}

Get Deposit Histories

const request = require("request");
const options = {
  method: "GET",
  url: "https://api.changer.io/d1/deposits",
  headers: {
    Authorization: "Bearer <token>",
    "Content-Type": "application/json",
  },
};

request(options, function (error: any, response: any) {
  if (error) throw new Error(error);
  console.log(response.body);
});

The above command returns JSON structured in the following format:

{
  "status": "ok",
  "totalCount": 19,
  "depositList": [
    {
      "trxId": "0xec6b4d4fdcfc3bc361ec7b1e98719a43b0d2def69f77683aca51e58470ab3663",
      "amount": "112",
      "balance": {
        "locked": "3",
        "available": "3046.450183715670610065120571",
        "id": "6364a7381cfbdfd6e8da0725"
      },
      "currency": {
        "name": "usdc",
        "mainnet": 1,
        "id": "5fa244355d19994dfa9ddd74"
      },
      "account": "5fbdea23d41b4c40cc21243b",
      "status": "success",
      "state": "done",
      "createdAt": "2023-05-12T06:12:39.742Z",
      "updatedAt": "2023-05-12T06:12:42.409Z",
      "id": "645dd8d7000f520c302fa08e"
    }
  ]
}

Description

Retrieve a list of deposit histories.

HTTP Request

GET /d1/deposits

Parameters

Name Location Description Required Type
start query The starting position of the results to be retrieved. (default: 0) number
length query The number of result items to be displayed per page. (default: 10) number
startDate query The starting date of the desired date range for retrieving results. (i.e. 2023-01-01) string
endDate query The ending date of the desired date range for retrieving results. (i.e. 2023-06-01) string
currency query Id of a currency to search with (i.e. 5cdaab544fee8b2a6dd64e7e) string

Withdraw

Withdraw

const request = require("request");
const reqBody = JSON.stringify({
  currency: "5cdaab544fee8b2a6dd64e7e",
  amount: "0.1",
  address: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
});
const options = {
  method: "POST",
  url: "https://api.changer.io/d1/withdraw/request",
  headers: {
    Authorization: "Bearer <token>",
    "Content-Type": "application/json",
  },
  body: reqBody,
};

request(options, function (error: any, response: any) {
  if (error) throw new Error(error);
  console.log(response.body);
});

The above command returns JSON structured in the following format:

{
  "status": "ok"
}

Description

Create a withdrawal request for the desired wallet address.

HTTP Request

POST /d1/withdraw/request

Parameters

Name Location Description Required Type
currency query Id of a currency to withdraw. (i.e. 5cdaab544fee8b2a6dd64e7e) Yes string
amount query Amount of a currency to withdraw. (i.e. 1.00 ETH set as 1) Yes string
address query Recipient's wallet address. Yes string

Get Withdraw Histories

const request = require("request");
const options = {
  method: "GET",
  url: "https://api.changer.io/d1/withdraw/history",
  headers: {
    Authorization: "Bearer <token>",
    "Content-Type": "application/json",
  },
};

request(options, function (error: any, response: any) {
  if (error) throw new Error(error);
  console.log(response.body);
});

The above command returns JSON structured in the following format:

{
  "status": "ok",
  "totalCount": 13,
  "withdrawList": [
    {
      "address": "0xEBcF976B09157eb5E42990ddb22F6a25D167FE5A",
      "amount": "30",
      "balance": {
        "available": "1709.695335879769638368",
        "locked": "670.5771748888974567",
        "id": "5fd10cdec18c5246fc77ba9f"
      },
      "currency": {
        "name": "usdt",
        "mainnet": 1,
        "id": "5cdaab544fee8b2a6dd64e7c"
      },
      "account": "5fbdea23d41b4c40cc21243b",
      "status": "Requested",
      "state": "wait",
      "createdAt": "2023-01-18T08:37:45.225Z",
      "updatedAt": "2023-01-18T08:37:45.225Z",
      "id": "63c7afd92453bb49bbef2b10"
    }
  ]
}

Description

Retrieve a list of withdrawal histories.

HTTP Request

GET /d1/withdraw/history

Parameters

Name Location Description Required Type
start query The starting position of the results to be retrieved. (default: 0) number
length query The number of result items to be displayed per page. (default: 10) number
startDate query The starting date of the desired date range for retrieving results. (i.e. 2023-01-01) string
endDate query The ending date of the desired date range for retrieving results. (i.e. 2023-06-01) string
currency query Id of a currency to search with (i.e. 5cdaab544fee8b2a6dd64e7e) string
status query The status of withdraw transaction. the status can have two possible values: success,cancel. array[string]

Account

Account

const request = require("request");

const options = {
  method: "POST",
  url: "https://api.changer.io/d1/authAccount",
  headers: {
    Authorization: "Bearer <token>",
    "Content-Type": "application/json",
  },
};

request(options, function (error: any, response: any) {
  if (error) throw new Error(error);
  console.log(response);
});

The above command returns JSON structured in the following format:

{
  "status": "ok",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjU2ODJkYjExNmY3OGMwZDEzNzM1OWhkMCIsImVtYWlsIjoidGVzdEBnbWFpbC5jb20iLCJvdHAiOmZhbHNlLCJreWMiOjIsImhhc0FkZHJlc3MiOmZhbHNlLCJleHBpcmVkIjpmYWxzZX0.szbu4Z4JOnxGX9lu5-eaOKQyy2et5dtki-pcr0R6Rqs"
}

Description

You can create and authenticate accounts to obtain tokens for API use.

HTTP Request

POST /d1/authAccount

Errors

The Changer API uses the following error codes

Http Errors

Error Code Meaning
400 Bad Request -- Your request is invalid.
401 Unauthorized -- Your token is wrong.
405 Method Not Allowed -- You tried to access our server with an invalid method.
406 Not Acceptable -- You requested a format that isn't json.
500 Internal Server Error -- We had a problem with our server. Try again later.
503 Service Unavailable -- We're temporarily offline for maintenance. Please try again later.

Custom Errors

Error Code Meaning
242 Company name not exist.
313 Already exist address.
307 KYC state pending.
308 KYC state rejected.
309 Currency not found.
314 This currency is not depositEnable.
315 Not found currency.
320 Withdraw invalid. Minimum withdraw amount is $20.
332 Blacklisted address in withdrawal.
500 There is no quote.
504 The trade amount is too low.
515 From amount exceed maximum. Maximum from amount is $10,000.
516 FromCurrency cannot be equals to ToCurrency.
520 Cross-chain limit error.
800 Unavailable convert.
801 Insufficient balance for convert.
1000 Undefined error.
1014 Server error.