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:
The
/buy_rate
and/sell_rate
endpoints are restricted to ETH <-> token queries only while thetrade_data
endpoint allows token <-> token trades.The fields
active
,custom_proxy
andoriginal_token
will only appear if certain conditions are met. Otherwise, they will not show up in the API response.The
only_official_reserve
parameter has been deprecated.
INDEX
<AUTOGENERATED_TABLE_OF_CONTENTS>
REFERENCE
Endpoints
/buy_rate
/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:
Parameter | Type | Required | Description |
---|---|---|---|
| string | Yes | The |
| float | Yes | A floating point number which will be rounded off to the decimals of the asset specified. The quantity is the amount of units of the asset you want to buy. |
| bool | No | Deprecated |
Response:
Parameter | Type | Description |
---|---|---|
| string | The |
| string | The |
| float[] | Array of floating point numbers which will be rounded off to the decimals of ETH. |
| float[] | Array of floating point numbers which will be rounded off to the decimals of the |
Example
Get buy rates for 300 KNC and 10.1 OMG.
/change24h
/change24h
(GET) Returns token to ETH and USD rates and percentage changes against the past day
Arguments:
Parameter | Type | Required | Description |
---|---|---|---|
| bool | No | Deprecated |
Response:
Parameter | Type | Description |
---|---|---|
| int | Server timestamp in UTC |
| string | Name of the asset |
| string | Symbol of the asset |
| int | Decimals that will be used to round-off the srcQty or dstQty of the asset in other requests |
| string | The asset contract address |
| float | Current asset price against ETH |
| float | Percentage change in ETH against the past 24 hours |
| float | Percentage change in USD against the past 24 hours |
| float | Current asset price in USD |
| bool | Returns true if the address is a proxy address. Note that this field only appears if the token is a proxy token. |
| string | The address of the original token contract. Note that this field only appears if the token is a proxy token. |
Example
/currencies
/currencies
(GET) Returns a list of all possible tokens available for trade.
Arguments:
Parameter | Type | Required | Description |
---|---|---|---|
| bool | No | Accepts |
| int | No | The page index of the response data, starts from |
| bool | No | Deprecated |
Response:
Parameter | Type | Description |
---|---|---|
| string | The symbol of the asset in its native chain. |
| string | Name of the asset in its native chain. |
| int | Decimals that will be used to round-off the srcQty or dstQty of the asset in other requests. |
| string | The address of the asset in its native chain. |
| string | A unique ID used by Kyber Network to identify between different symbols. |
| bool | A boolean value to represent if the token is still active on Kyber. Note that this field only appears when you specify a value for the |
| string[] | Reserve contract addresses supporting Token to Ether trades |
| string[] | Reserve contract addresses supporting Ether to Token trades |
| bool | Returns true if the address is a proxy address. Note that this field only appears if the token is a proxy token. |
| string | The address of the original token contract. Note that this field only appears if the token is a proxy token. |
Note: Ether and tokens that have been deployed permissionlessly do not have the reserves_src
and reserves_dest
fields.
Example
/expectedRate
/expectedRate
(GET) Return the expected rate for a token pair, with behavior similar to getExpectedRate from the proxy contract.
Arguments:
Parameter | Type | Required | Description |
---|---|---|---|
| string | Yes | The source token contract address. |
| string | Yes | The destination token contract address. |
| number | Yes | The amount of source tokens in source token decimals. |
| number | No | The platform fee in BPS. |
Response:
Parameter | Type | Description |
---|---|---|
| string | The conversion rate of the token pair in 10^18. See example for reference. |
| string | Deprecated, will return |
| int | Server timestamp in UTC. |
| bool | Returns |
Example
Get rates for 100 DAI to OMG, with a 0.25% platform fee.
This means that 1 DAI can be exchanged for 634908750000000033 / 1e18
= 0.63490875 OMG.
/gas_limit
/gas_limit
(GET) Return the estimated Gas Limit used for a transaction based on source token amount.
Arguments:
Parameter | Type | Required | Description |
---|---|---|---|
| string | Yes | The source token contract address. |
| string | Yes | The destination token contract address. |
| number | The amount of source tokens. |
Response:
Parameter | Type | Description |
---|---|---|
| string | The estimated gas limit to be used for a transaction based on the parameters. |
| bool | Returns |
Example
Get the gas limit for exchanging 10000 DAI to OMG.
/gasLimitConfig
/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:
Parameter | Type | Description |
---|---|---|
| string | Symbol of the asset |
| string | Contract address of the asset |
| int | Gas limit when swapping between ETH <-> asset |
| int | Gas limit when approving KNP to trade the asset on behalf of the user |
| bool | Returns true if the address is a proxy address. Note that this field only appears if the token is a proxy token. |
| string | The address of the original token contract. Note that this field only appears if the token is a proxy token. |
Example
/hint
/hint
(GET) Returns the encoded hint based on the input parameters.
Arguments:
Parameter | Type | Required | Description |
---|---|---|---|
| string | Yes | Must be |
| string | Dependent on route | source token address |
| string | Dependent on route | destination token address |
| string | Yes | Must be |
| string | Dependent on route | ID(s) of the reserve, comma-separated |
| string | Dependent on route | Respective split for the reserveId, comma-separated |
Response:
Parameter | Type | Description |
---|---|---|
| string | The encoded hint |
Example
Build a KNC to ETH split trade among 2 reserves:
Reserve
0xff00004b79626572000000000000000000000000000000000000000000000000
: 70%Reserve
0xff53706561726f53000000000000000000000000000000000000000000000000
: 30%
/market
/market
(GET) Retrieve in-depth information about price and other information about assets.
Response:
Parameter | Type | Description |
---|---|---|
| int | Server timestamp in UTC. |
| string | Symbol of the asset used for quoting i.e. ETH. |
| string | Name of the asset in its native chain. i.e. Ethereum. |
| int | Decimals that will be used to round-off the srcQty or dstQty of the asset in other requests. |
| string | Contract address of the asset used for quoting. |
| string | Symbol of the asset to be quoted in terms of the |
| string | Name of the asset to be quoted in terms of the |
| int | Decimals of the asset to be quoted. |
| string | Contract address of the asset to be quoted. |
| float | Highest ASK price for the last 24 hours of the pair. |
| float | Highest BID price for the last 24 hours of the pair. |
| float | Volume for the last 24 hours in USD. |
| float | Volume for the last 24 hours in ETH. |
| float | Volume for the last 24 hours in tokens. |
| float | Current (considering some X minute delay) BID price. |
| float | Current (considering some X minute delay) ASK price. |
| float | Last traded price in the exchange. |
| string | Pair name consisting of the quote and base asset symbols. |
| bool | Returns true if the address is a proxy address. Note that this field only appears if the token is a proxy token. |
| string | The address of the original token contract. Note that this field only appears if the token is a proxy token. |
Example
/quote_amount
/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:
Parameter | Type | Required | Description |
---|---|---|---|
| string | Yes | The base token contract address. |
| string | Yes | The quote token contract address. |
| number | The amount of base tokens you would like to buy / sell. | |
| string | Yes | Accepts |
| number | No | Platform fee to be charged, in basis points. Read more about platform fees here. |
Response:
Parameter | Type | Description |
---|---|---|
| bool | Returns |
| string | The amount of |
Examples
Get WETH amount receivable for selling 10 KNC, with 0.08% platform fee. (10 KNC -> ? WETH)
Get WETH amount needed to purchase 10 KNC, with 0.1% platform fee. (? WETH -> 10 KNC)
/all_reserves
/all_reserves
(GET) Returns a list of all reserves added to the network.
Response:
Parameter | Type | Description |
---|---|---|
| string | The address of the asset in its native chain. |
| string | Reserve ID. Refer to this section for more information. |
| integer | Reserve Type. Elaborated in description. |
| string | Reserve rebate wallet address |
| string | Reserve type description |
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
/reserves
/reserves
(GET) Returns a list of reserves that supports a token pair.
Arguments:
Parameter | Type | Required | Description |
---|---|---|---|
| string | Yes | Address of the asset. |
| string | Yes | Accepts |
Response:
Parameter | Type | Description |
---|---|---|
| string | The address of the asset in its native chain. |
| string | Reserve ID. Refer to this section for more information. |
| integer | Reserve Type. Elaborated in description. |
| string | Reserve rebate wallet address |
| string | Reserve type description |
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.
/sell_rate
/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:
Parameter | Type | Required | Description |
---|---|---|---|
| string | Yes | The |
| float | Yes | A floating point number which will be rounded off to the decimals of the asset specified. The quantity is the amount of units of the asset you want to sell. |
| bool | No | Deprecated |
Response:
Example
Get sell rates for 300 and 150 KNC, and 10.1, 20 and 30 OMG.
/trade_data
/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:
Parameter | Type | Required | Description |
---|---|---|---|
| string | Yes | The ETH address that will be executing the swap. |
| string | Yes | The |
| string | Yes | The |
| float | Yes | A floating point number representing the source amount in the conversion which will be rounded off to the decimals of the source token |
| float | Yes | A floating point number representing the source amount in the conversion which will be rounded off to the decimals of the destination token |
| string | Yes | One of the following 3: |
| string | No | Wallet address that to get fees from the trade. Read more about platform fees here. |
| integer | No | Platform fee to be charged, in basis points. Read more about platform fees here. |
| string | No | The trade hint, specifying the trade type, reserve IDs and splits. Read more about building and parsing hints here. |
| integer | No | Users can specify a nonce to override the default account nonce. |
| bool | No | Deprecated. |
Response:
Parameter | Type | Description |
---|---|---|
| string | The ETH address that executed the swap. Must match the |
| string | The contract address of the KyberNetwork smart contract. Verify that it should always be the address resolved from |
| string | Transaction data. This data needs to be signed and broadcasted to the blockchain. |
| string | This will be equal to 0 in hex (0x0) if the user tries to trade from token to ETH (assuming |
| string | Calculated ETHGasStation price according to the user's request. If you need to specify a price value, change this wei hex value. |
| string | The nonce of the account. If multiple conversions are requested at the same time, each request will have the same nonce as the API will return the nonce of the account's last mined transaction. |
| string | The gas limit required for the transaction. This value should not be altered unless for specific reasons. |
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
.
/transfer_data
/transfer_data
(GET) Returns the transaction payload for the user to sign and broadcast in order to transfer an asset to a recipient.
Arguments:
Parameter | Type | Required | Description |
---|---|---|---|
| string | Yes | The Ethereum address of the sender. | | |
| string | No | The contract address of token. If no argument is provided, it will default to ETH. |
| float | Yes | The number of token / ETH you want to send. For example, if you want to send 1.35 ZIL (12 decimals), it would be 1.35. |
| string | Yes | One of the following 3: |
| integer | No | The limit of gas required for your transaction. |
| integer | No | Users can specify a nonce to override the default account nonce. |
Response:
Parameter | Type | Description |
---|---|---|
| string | The Ethereum address that executed the transfer. Must match the |
| string | The contract address of the token or the recipient Ethereum address (if transferring ETH). |
| string | Transaction data. This data needs to be signed and broadcasted to the blockchain. If sending ETH, the value for this parameter should be '0x0'. |
| string | If sending token, the value for this parameter should be '0x0'. Else, it should match the |
| string | Calculated ETHGasStation price according to the user's request. If you want to specify a price value, change this wei hex value. |
| string | The nonce of the account. If multiple conversions are requested at the same time, each request will have the same nonce as the API will return the nonce of the account's last mined transaction. |
| string | The gas limit required for the transaction. This value should not be altered unless for specific reasons. |
Example
Wallet 0x3Cf628d49Ae46b49b210F0521Fbd9F82B461A9E1
to transfer 20.5 KNC to 0x723f12209b9C71f17A7b27FCDF16CA5883b7BBB0
with medium gas price and tx nonce of 123.
/users/:user_address/currencies
/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:
Parameter | Type | Required | Description |
---|---|---|---|
| string | Yes | The ETH address to get information from. |
| int | No | The page index of the response data, starts from |
| bool | No | Deprecated |
Response:
Parameter | Type | Description |
---|---|---|
| string | A unique ID used by Kyber Network to identify between different symbols |
| bool | Whether the user address has approved Kyber Network to spend the asset on their behalf. Applicable only to ERC20 tokens. See ‘allowance’ on the ERC20 standard. |
| int | Number of transactions required until the ID is enabled for trading. When |
Example
Find what tokens the wallet 0x8fA07F46353A2B17E92645592a94a0Fc1CEb783F
has approved for trading.
/users/:user_address/currencies/:currency_id/enable_data
/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:
Parameter | Type | Required | Description |
---|---|---|---|
| string | Yes | The ETH address of the user that will enable the asset. |
| string | Yes | The unique ID of the destination asset. |
| string | Yes | One of the following 3: |
| int | No | You can manually specify a nonce to override the default account nonce. |
| bool | No | Deprecated |
Response:
Parameter | Type | Description |
---|---|---|
| string | The ETH address of the user. Must match the |
| string | The contract address of the token you want to enable trading in Kyber Network. Always verify this for security reasons. |
| string | Transaction data. This data needs to be signed and broadcasted to the blockchain. |
| string | Should always be equal to 0 for this operation. Always verify that the value is 0 for security reasons. |
| string | Calculated ETHGasStation price according to the user's request. If you need to specify a price value, change this wei hex value. |
| string | The nonce of the account. If multiple conversions are requested at the same time, each request will have the same nonce as the API will return the nonce of the account's last mined transaction. |
| string | The gas limit required for the transaction. This value should not be altered unless for specific reasons. |
Example
Get transaction input parameters for user 0xfD65739DA3280dC976DDAf1937D37dA6Db98cb65
to approve KNC for trades at high gas price.
Last updated