RESTful API

You are referring to the Legacy version of KyberSwap docs.

For the most updated information, please refer to:

INTRODUCTION

The RESTful API provide a way for users to be able to programmatically interact with the KyberNetwork contract without in depth understanding of blockchain and smart contracts. Please note that some of these endpoints have certain limitations as follows:

  1. The /buy_rate and /sell_rate endpoints are restricted to ETH <-> token queries only while the trade_data endpoint allows token <-> token trades.

  2. The fields active, custom_proxy and original_token will only appear if certain conditions are met. Otherwise, they will not show up in the API response.

  3. The only_official_reserve parameter has been deprecated.

INDEX

<AUTOGENERATED_TABLE_OF_CONTENTS>

REFERENCE

Endpoints

/buy_rate

(GET) Returns the latest BUY conversion rate in ETH. For example, if you want to know how much ETH is needed to buy 1 DAI, you can use this function.

Arguments:

Response:

Example

Get buy rates for 300 KNC and 10.1 OMG.

> curl "https://api.kyber.network/buy_rate?id=0xdd974D5C2e2928deA5F71b9825b8b646686BD200&qty=300&id=0xd26114cd6EE289AccF82350c8d8487fedB8A0C07&qty=10.1"
{
  "error":false,
  "data":[
    {
      "src_id":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
      "dst_id":"0xdd974D5C2e2928deA5F71b9825b8b646686BD200",
      "src_qty":[
        0.5671077504725898
      ],
      "dst_qty":[
        300
      ]
    },
    {
      "src_id":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
      "dst_id":"0xd26114cd6EE289AccF82350c8d8487fedB8A0C07",
      "src_qty":[
        0.18035714285714283
      ],
      "dst_qty":[
        10.1
      ]
    },
    ...
  ]
}

/change24h

(GET) Returns token to ETH and USD rates and percentage changes against the past day

Arguments:

Response:

Example

> curl "https://api.kyber.network/change24h"
{
  "ETH_KNC":{
    "timestamp":1548065183567,
    "token_name":"Kyber Network",
    "token_symbol":"KNC",
    "token_decimal":18,
    "token_address":"0xdd974d5c2e2928dea5f71b9825b8b646686bd200",
    "rate_eth_now":0.001144689345999999,
    "change_eth_24h":-2.7115507894449724,
    "change_usd_24h":13.883783963625097,
    "rate_usd_now":0.1443257387379925
  },
  "ETH_OMG":{
    "timestamp":1548065183567,
    "token_name":"OmiseGO",
    "token_symbol":"OMG",
    "token_decimal":18,
    "token_address":"0xd26114cd6ee289accf82350c8d8487fedb8a0c07",
    "rate_eth_now":0.0105194607632,
    "change_eth_24h":-2.0145305819746198,
    "change_usd_24h":-10.129,
    "rate_usd_now":0.8
  },
  "ETH_SNX":{
    "timestamp":1573200127195,
    "token_symbol":"SNX",
    "token_name":"Synthetix Network",
    "token_address":"0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f",
    "token_decimal":18,
    "rate_eth_now":0.004682812478752438,
    "change_eth_24h":5.285125197652733,
    "rate_usd_now":0.8631071531728769,
    "change_usd_24h":3.3441675583726584,
    "custom_proxy":true,
    "original_token":"0x42D03f506c2308ECd06aE81D8fA22352BC7A8F2b"
  }
  ...
}

/currencies

(GET) Returns a list of all possible tokens available for trade.

Arguments:

Response:

Note: Ether and tokens that have been deployed permissionlessly do not have the reserves_src and reserves_dest fields.

Example

> curl "https://api.kyber.network/currencies"
{
  "error":false,
  "data":[
    {
      "symbol":"ETH",
      "name":"Ethereum",
      "address":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
      "decimals":18,
      "id":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
    },
    {
      "symbol":"WETH",
      "name":"Wrapped Ether",
      "address":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
      "decimals":18,
      "id":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
      "reserves_src":[
        "0x57f8160e1c59D16C01BbE181fD94db4E56b60495"
      ],
      "reserves_dest":[
        "0x57f8160e1c59D16C01BbE181fD94db4E56b60495"
      ]
    },
    {
      "symbol":"KNC",
      "name":"KyberNetwork",
      "address":"0xdd974d5c2e2928dea5f71b9825b8b646686bd200",
      "decimals":18,
      "id":"0xdd974d5c2e2928dea5f71b9825b8b646686bd200",
      "reserves_src":[
        "0x63825c174ab367968EC60f061753D3bbD36A0D8F",
        "0x21433Dec9Cb634A23c6A4BbcCe08c83f5aC2EC18"
      ],
      "reserves_dest":[
        "0x63825c174ab367968EC60f061753D3bbD36A0D8F",
        "0x21433Dec9Cb634A23c6A4BbcCe08c83f5aC2EC18"
      ]
    },
    {
      "symbol":"TUSD",
      "name":"TrueUSD",
      "address":"0x8dd5fbce2f6a956c3022ba3663759011dd51e73e",
      "decimals":18,
      "id":"0x8dd5fbce2f6a956c3022ba3663759011dd51e73e",
      "reserves_src":[
        "0x5D154c145Db2ca90B8aB5e8Fe3E716AfA4AB7Ff0",
        "0x7a3370075a54B187d7bD5DceBf0ff2B5552d4F7D"
      ],
      "reserves_dest":[
        "0x5D154c145Db2ca90B8aB5e8Fe3E716AfA4AB7Ff0",
        "0x7a3370075a54B187d7bD5DceBf0ff2B5552d4F7D"
      ],
      "custom_proxy":true,
      "original_token":"0x0000000000085d4780B73119b644AE5ecd22b376"
    }
    ...
  ]
}

/expectedRate

(GET) Return the expected rate for a token pair, with behavior similar to getExpectedRate from the proxy contract.

Arguments:

Response:

Example

Get rates for 100 DAI to OMG, with a 0.25% platform fee.

> curl "https://api.kyber.network/expectedRate?source=0x6b175474e89094c44da98b954eedeac495271d0f&dest=0xd26114cd6ee289accf82350c8d8487fedb8a0c07&sourceAmount=100000000000000000000&platformFee=25"
{
  "error": false,
  "expectedRate": "634908750000000033",
  "slippageRate": "615861487500000032",
  "timestamp": 1594182159
}

This means that 1 DAI can be exchanged for 634908750000000033 / 1e18 = 0.63490875 OMG.

/gas_limit

(GET) Return the estimated Gas Limit used for a transaction based on source token amount.

Arguments:

Response:

Example

Get the gas limit for exchanging 10000 DAI to OMG.

> curl "https://api.kyber.network/gas_limit?source=0x6b175474e89094c44da98b954eedeac495271d0f&dest=0xd26114cd6ee289accf82350c8d8487fedb8a0c07&amount=10000"
{
  "data": 880000,
  "error": false
}

/gasLimitConfig

(GET) Returns the gas limit for approving token and swapping between ETH <-> ERC20 token. To calculate the gas limit for swapping between token A <-> token B, take the sum of the gas limit for swapping from token A -> ETH and for swapping from ETH -> Token B. Note that some tokens may require higher gas limits than others e.g. DAI, TUSD, MKR, DGX.

Response:

Example

> curl "https://api.kyber.network/gasLimitConfig"
{
  "error":false,
  "data":[
    {
      "symbol":"ETH",
      "address":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
      "swapGasLimit":0,
      "approveGasLimit":0
    },
    {
      "symbol":"WETH",
      "address":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
      "swapGasLimit":380000,
      "approveGasLimit":120000
    },
    {
      "symbol":"KNC",
      "address":"0xdd974d5c2e2928dea5f71b9825b8b646686bd200",
      "swapGasLimit":380000,
      "approveGasLimit":120000
    },
    {
      "symbol":"DAI",
      "address":"0x6b175474e89094c44da98b954eedeac495271d0f",
      "swapGasLimit":500000,
      "approveGasLimit":120000
    },
    {
      "symbol":"TUSD",
      "address":"0x8dd5fbce2f6a956c3022ba3663759011dd51e73e",
      "swapGasLimit":600000,
      "approveGasLimit":120000,
      "custom_proxy":true,
      "original_token":"0x0000000000085d4780B73119b644AE5ecd22b376"
    }
    ...
  ]
}

/hint

(GET) Returns the encoded hint based on the input parameters.

Arguments:

Response:

Example

Build a KNC to ETH split trade among 2 reserves:

  • Reserve 0xff00004b79626572000000000000000000000000000000000000000000000000: 70%

  • Reserve 0xff53706561726f53000000000000000000000000000000000000000000000000: 30%

> curl "https://api.kyber.network/hint?type=t2e&trade_type=split&token_src=0x7b2810576aa1cce68f2b118cef1f36467c648f92&reserve_id=0xff00004b79626572000000000000000000000000000000000000000000000000,0xff53706561726f53000000000000000000000000000000000000000000000000&split_value=7000,3000"
{
  "data": "0x0000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000002aa12aa56bbfff000000000000000000000000000000000000000000000000000ff1234567a334f7d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000001b580000000000000000000000000000000000000000000000000000000000000bb8"
}

/market

(GET) Retrieve in-depth information about price and other information about assets.

Response:

Example

> curl "https://api.kyber.network/market"
{
  "error":false,
  "data":[
    {
      "timestamp":1565676643703,
      "quote_symbol":"ETH",
      "quote_name":"Ethereum",
      "quote_decimals":18,
      "quote_address":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
      "base_symbol":"WETH",
      "base_name":"Wrapped Ether",
      "base_decimals":18,
      "base_address":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
      "past_24h_high":1,
      "past_24h_low":1,
      "usd_24h_volume":55171.31700779925,
      "eth_24h_volume":261.98872813093953,
      "token_24h_volume":261.98872813093953,
      "current_bid":1,
      "current_ask":1,
      "last_traded":1,
      "pair":"ETH_WETH"
    },
    {
      "timestamp":1565676643703,
      "quote_symbol":"ETH",
      "quote_name":"Ethereum",
      "quote_decimals":18,
      "quote_address":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
      "base_symbol":"KNC",
      "base_name":"KyberNetwork",
      "base_decimals":18,
      "base_address":"0xdd974d5c2e2928dea5f71b9825b8b646686bd200",
      "past_24h_high":0.000793293929007035,
      "past_24h_low":0.000783163456436218,
      "usd_24h_volume":5751.223513558892,
      "eth_24h_volume":27.365939751337628,
      "token_24h_volume":34737.279673311226,
      "current_bid":0.000787059792040378,
      "current_ask":0.00079253036315891,
      "last_traded":0.000788978737325427,
      "pair":"ETH_KNC"
    },
    {
      "timestamp":1565676643703,
      "quote_symbol":"ETH",
      "quote_name":"Ethereum",
      "quote_decimals":18,
      "quote_address":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
      "base_symbol":"DAI",
      "base_name":"DAI",
      "base_decimals":18,
      "base_address":"0x6b175474e89094c44da98b954eedeac495271d0f",
      "past_24h_high":0.004764611951928574,
      "past_24h_low":0.004672131147540981,
      "usd_24h_volume":202729.63505611182,
      "eth_24h_volume":963.3434244536832,
      "token_24h_volume":203591.66123820562,
      "current_bid":0.004743332850081698,
      "current_ask":0.004789407404832812,
      "last_traded":0.004789355488531787,
      "pair":"ETH_DAI"
    },
    {
      "timestamp":1573199827192,
      "quote_symbol":"ETH",
      "quote_name":"Ethereum",
      "quote_decimals":18,
      "quote_address":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
      "base_symbol":"TUSD",
      "base_name":"TrueUSD",
      "base_decimals":18,
      "base_address":"0x8dd5fbce2f6a956c3022ba3663759011dd51e73e",
      "past_24h_high":0.005382922417172212,
      "past_24h_low":0.005256588523707966,
      "usd_24h_volume":8437.676524840423,
      "eth_24h_volume":45.33700723026804,
      "token_24h_volume":8400.120592248511,
      "current_bid":0.005366444083242093,
      "current_ask":0.00543261156727895,
      "last_traded":0.005345203077303782,
      "pair":"ETH_TUSD",
      "custom_proxy":true,
      "original_token":"0x0000000000085d4780B73119b644AE5ecd22b376"
    }
    ...
  ]
}

/quote_amount

(GET) Returns the amount of quote token needed to buy / received when selling qty amount of base token. This endpoint will only work for official reserves.

Arguments:

Response:

Examples

  1. Get WETH amount receivable for selling 10 KNC, with 0.08% platform fee. (10 KNC -> ? WETH)

> curl "https://api.kyber.network/quote_amount?base=0xdd974d5c2e2928dea5f71b9825b8b646686bd200&quote=0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2&base_amount=10&type=sell&platformFee=8"
{
  "data":"0.068293",
  "error":false
}
  1. Get WETH amount needed to purchase 10 KNC, with 0.1% platform fee. (? WETH -> 10 KNC)

> curl "https://api.kyber.network/quote_amount?base=0xdd974d5c2e2928dea5f71b9825b8b646686bd200&quote=0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2&base_amount=10&type=buy&platformFee=10"
{
  "data":"0.068949",
  "error":false
}

/all_reserves

(GET) Returns a list of all reserves added to the network.

Response:

Reserve Types

Refer to this section for more information on reserve types.

  • 1 = Fed Price Reserve (FPR)

  • 2 = Automated Price Reserve (APR)

  • 3 = Bridge Reserve (BRIDGE)

  • 4 = Utility Reserve (UTILITY)

  • 5 = Custom Reserve (CUSTOM)

  • 6 = Orderbook Reserve (ORDERBOOK)

Example

> curl "https://api.kyber.network/all_reserves"
{
  "data": [
    {
      "address": "0x39C30B03799DB870e9C01747f68e24D2b38A30C9",
      "id": "0xff00004b79626572000000000000000000000000000000000000000000000000",
      "type": 1,
      "rebate_wallet": "0xDd102CeDa27a2283dC85028f9bF7d022d8a640d2"
    },
    {
      "address": "0xc4684f4FbfC3db0A24CFFe35821b12e55BeaEF7A",
      "id": "0xaa4b4e4320415052000000000000000000000000000000000000000000000000",
      "type": 2,
      "rebate_wallet": "0x7de9bC2cDfa6B7Ee7088a4f5848A86A26Cd5aFD1"
    },
    ...
  ]
}

/reserves

(GET) Returns a list of reserves that supports a token pair.

Arguments:

Response:

Reserve Types

Refer to this section for more information on reserve types.

  • 1 = Fed Price Reserve (FPR)

  • 2 = Automated Price Reserve (APR)

  • 3 = Bridge Reserve (BRIDGE)

  • 4 = Utility Reserve (UTILITY)

  • 5 = Custom Reserve (CUSTOM)

  • 6 = Orderbook Reserve (ORDERBOOK)

Example

Get list of reserves that support ETH -> KNC trades.

> curl "https://api.kyber.network/reserves?token=0xdd974d5c2e2928dea5f71b9825b8b646686bd200&type=buy"
{
  "data": [
    {
      "address": "0x39C30B03799DB870e9C01747f68e24D2b38A30C9",
      "id": "0xff00004b79626572000000000000000000000000000000000000000000000000",
      "type": 1,
      "rebate_wallet": "0xDd102CeDa27a2283dC85028f9bF7d022d8a640d2"
    },
    {
      "address": "0xc4684f4FbfC3db0A24CFFe35821b12e55BeaEF7A",
      "id": "0xaa4b4e4320415052000000000000000000000000000000000000000000000000",
      "type": 2,
      "rebate_wallet": "0x7de9bC2cDfa6B7Ee7088a4f5848A86A26Cd5aFD1"
    },
    ...
  ]
}

/sell_rate

(GET) Returns the latest SELL conversion rate in ETH. For example, if you want to know how much ETH you will get by selling 1 DAI, you can use this function.

Arguments:

Response:

Example

Get sell rates for 300 and 150 KNC, and 10.1, 20 and 30 OMG.

> curl "https://api.kyber.network/sell_rate?id=0xdd974D5C2e2928deA5F71b9825b8b646686BD200&qty=300&qty=150&id=0xd26114cd6EE289AccF82350c8d8487fedB8A0C07&qty=10.1&qty=20.2&qty=30"
{
  "error":false,
  "data":[
    {
      "src_id":"0xdd974D5C2e2928deA5F71b9825b8b646686BD200",
      "dst_id":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
      "src_qty":[
        300,
        150
      ],
      "dst_qty":[
        0.55963380759,
        0.279816903795
      ]
    },
    {
      "src_id":"0xd26114cd6EE289AccF82350c8d8487fedB8A0C07",
      "dst_id":"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
      "src_qty":[
        10.1,
        20.2,
        30
      ],
      "dst_qty":[
        0.17552908314026,
        0.35105816628052,
        0.521373514278
      ]
    }
  ]
}

/trade_data

(GET) Returns the transaction payload for the user to sign and broadcast in order to trade or convert an asset pair from token A to token B.

Arguments:

Response:

Example

User 0x8fa07f46353a2b17e92645592a94a0fc1ceb783f to swap 0.05 ETH to KNC (minimally receive 5.5 KNC) at medium gas price, with a nonce of 200. 0.025% of the trade will be allocated to 0x0859A7958E254234FdC1d200b941fFdfCAb02fC1.

> curl "https://api.kyber.network/trade_data?user_address=0x8fa07f46353a2b17e92645592a94a0fc1ceb783f&src_id=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&dst_id=0xdd974D5C2e2928deA5F71b9825b8b646686BD200&src_qty=0.05&min_dst_qty=5.5&gas_price=medium&wallet_id=0x0859A7958E254234FdC1d200b941fFdfCAb02fC1&wallet_fee=25&nonce=200"
{
  "error":false,
  "data":[
    {
      "from":"0x8fa07f46353a2b17e92645592a94a0fc1ceb783f",
      "to":"0x818e6fecd516ecc3849daf6845e3ec868087b755",
      "data":"0xcb3c28c7000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00000000000000000000000000000000000000000000000000044364c5bb0000000000000000000000000000dd974d5c2e2928dea5f71b9825b8b646686bd2000000000000000000000000008fa07f46353a2b17e92645592a94a0fc1ceb783f800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b1ae4d6e2ef5000000000000000000000000000000859a7958e254234fdc1d200b941ffdfcab02fc1",
      "value":"0x44364c5bb0000",
      "gasPrice":"0x39eda2b80",
      "nonce":"0xc8",
      "gasLimit":"0x43d81"
    }
  ]
}

/transfer_data

(GET) Returns the transaction payload for the user to sign and broadcast in order to transfer an asset to a recipient.

Arguments:

Response:

Example

Wallet 0x3Cf628d49Ae46b49b210F0521Fbd9F82B461A9E1 to transfer 20.5 KNC to 0x723f12209b9C71f17A7b27FCDF16CA5883b7BBB0 with medium gas price and tx nonce of 123.

> curl "https://api.kyber.network/transfer_data?from=0x3Cf628d49Ae46b49b210F0521Fbd9F82B461A9E1&to=0x723f12209b9C71f17A7b27FCDF16CA5883b7BBB0&token=0xdd974d5c2e2928dea5f71b9825b8b646686bd200&value=20.5&gas_price=medium&gas_limit=200000&nonce=123"
{
  "error":false,
  "data":[
    {
      "from":"0x3Cf628d49Ae46b49b210F0521Fbd9F82B461A9E1",
      "to":"0xdd974d5c2e2928dea5f71b9825b8b646686bd200",
      "data":"0xa9059cbb000000000000000000000000723f12209b9c71f17a7b27fcdf16ca5883b7bbb000000000000000000000000000000000000000000000000014d1120d7b160000",
      "value":"0x0",
      "gasPrice":"0x147d35700",
      "nonce":"0x7b",
      "gasLimit":"0x30d40"
    }
  ]
}

/users/:user_address/currencies

(GET) Returns a list of token enabled statuses of an Ethereum wallet. It indicates if the wallet can sell a token or not. If not, how many transactions he has to do in order to enable it.

Arguments:

Response:

Example

Find what tokens the wallet 0x8fA07F46353A2B17E92645592a94a0Fc1CEb783F has approved for trading.

> curl "https://api.kyber.network/users/0x8fA07F46353A2B17E92645592a94a0Fc1CEb783F/currencies"
{
  "error":false,
  "data":[
    {
      "id":"0xbf2179859fc6d5bee9bf9158632dc51678a4100e",
      "enabled":true,
      "txs_required":0
    },
    {
      "id":"0x595832f8fc6bf59c85c527fec3740a1b7a361269",
      "enabled":false,
      "txs_required":1
    },
    {
      "id":"0xd26114cd6ee289accf82350c8d8487fedb8a0c07",
      "enabled":true,
      "txs_required":0
    },
    {
      "id":"0x0f5d2fb29fb7d3cfee444a200298f468908cc942",
      "enabled":true,
      "txs_required":0
    },
    ...
  ]
}

/users/:user_address/currencies/:currency_id/enable_data

(GET) Returns all needed information for a user to sign and do a transaction, and to enable a token to be able to be sold.

Arguments:

Response:

Example

Get transaction input parameters for user 0xfD65739DA3280dC976DDAf1937D37dA6Db98cb65 to approve KNC for trades at high gas price.

> curl "https://api.kyber.network/users/0xfD65739DA3280dC976DDAf1937D37dA6Db98cb65/currencies/0xdd974D5C2e2928deA5F71b9825b8b646686BD200/enable_data?gas_price=high"
{
  "error":false,
  "data":[
    {
      "from":"0xfD65739DA3280dC976DDAf1937D37dA6Db98cb65",
      "to":"0xdd974D5C2e2928deA5F71b9825b8b646686BD200",
      "data":"0x095ea7b3000000000000000000000000818e6fecd516ecc3849daf6845e3ec868087b7558000000000000000000000000000000000000000000000000000000000000000",
      "value":"0x0",
      "gasPrice":"0xa02ffee00",
      "nonce":"0x0",
      "gasLimit":"0x11229"
    }
  ]
}

Last updated