EVM Swaps
KyberSwap Aggregator EVM APIs
Last updated
Was this helpful?
KyberSwap Aggregator EVM APIs
Last updated
Was this helpful?
Note on integration: clientID
In order to continuously improve the KyberSwap Aggregator, our APIs implement a client identifier field that enables us to understand how the APIs are being utilized. A stricter rate limit will be applied if a clientId is not provided. As a developer integrating with our APIs, please preferably use the same clientID (i.e. company name or your app name) for:
[V1] Get Swap Route
Header: x-client-id
[V1] Post Swap Route For Encoded Data
Header: x-client-id
This will enable us to serve you better as we continuously strive to improve our Aggregator API. For integrators who have previously integrated with our Legacy
API, we highly encourage migrating to the Latest
APIs to ensure access to the latest features as well as improved service quality and efficiency.
Example
[V1] GET
/routes
Header
x-client-id: MyAwesomeApp
[V1] POST
/route/build
Header
x-client-id: MyAwesomeApp
If you're just getting started with the KyberSwap Aggregator, you can refer to our Execute A Swap With The Aggregator API dev guide for information and code samples on how to query and execute swaps at superior rates. Note that there is also a KyberSwap Widget option for integrators who require a simple minimal-code implementation. For existing integrators, please refer to Upgrading To APIv1 for further details on the motivation behind the upgrade as well as the relevant changes to swap flow and parameters.
To support more performant queries and the use of RFQ liquidity sources, KyberSwap highly encourages all integrators to implement the latest API [V1]
version. While both versions of the API remains backwards compatible, only the [V1]
APIs will continue to receive updates and can make use of RFQ liquidity sources, and hence developers are highly encouraged to implement the latest [V1]
APIs to avoid any disruptions as the non-versioned API will eventually be deprecated.
Chain identifiers
The Aggregator APIs require a chain name to be included in the path when calling the APIs:
Ethereum (ChainID: 1) -> ethereum
BSC (ChainID: 56) -> bsc
Arbitrum (ChainID: 42161) -> arbitrum
Polygon PoS (ChainID: 137) -> polygon
Optimism (ChainID: 10) -> optimism
Avalanche (ChainID: 43114) -> avalanche
Base (ChainID: 8453) -> base
zkSync Era (ChainID: 324) -> zksync
Fantom (ChainID: 250) -> fantom
Linea (ChainID: 59144) -> linea
Polygon zkEVM (ChainID: 1101) -> polygon-zkevm
Scroll (ChainID: 534352) -> scroll
Mantle (ChainID: 5000) -> mantle
Blast (ChainID: 81457) -> blast
Sonic (ChainID: 146) -> sonic
Latest
Legacy
Find the best route to swap from tokenIn
to tokenOut
, supporting all liquidity sources including RFQ. Use this API to get a route preview before confirming the swap. The route returned can then be combined with transaction specific params in the POST
API payload to get the encoded data for submission to the KyberSwap router contract. Refer to Supported Exchanges And Networks for the full list of supported networks.
/{chain}/api/v1/routes
Chain name. Full list of supported chains available on Docs.
ethereum
Address of the input token
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
in case of native token
Address of the output token
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
in case of native token
Amount of the input token (in wei)
Determines whether gas costs are included when searching for route
DEX IDs included in the route, separated by comma
DEX IDs excluded from the route, separated by comma
Custom gas price in wei used when searching for the best swap route. Use result from eth_gasPrice otherwise
Fee amount to be collected
if isInBps
= true
, feeAmount
is the percentage of fees that we will take with base unit = 10000, i.e feeAmount
= 10 and isInBps
= true
then fee = 0.1%
if isInBps
= false
, feeAmount
is the amount of token that we will take as fee, i.e feeAmount
= 10 and isInBps
= 'false' then fee = 10 token weis
Indicates whether fee is charged by input token currency_in
or output token currency_out
Default is empty whereby no fee is charged
currency_in
, currency_out
if true, fee is taken in BPS
Address to receive fee (if chargeFeeBy
is not empty)
ClientID of the party calling the API. Provide a value to identify your client and avoid getting rate limited. If an even higher rate limit is needed, contact bd.
Get the swap's calldata to be sent to the KyberSwap router contract. The request body must contain the routeSummary
as exactly returned by [V1] Get Swap Route along with the additional tx related parameters. Please refer to Supported Exchanges And Networks for the full list of supported networks.
/{chain}/api/v1/route/build
Chain name. Full list of supported chains available on Docs.
ethereum
ClientID of the party calling the API. Provide a value to identify your client and avoid getting rate limited. Please use the same ClientID as the source
field in the body.
The summarised routing data as per returned from [V1] Get Swap Route
Address from which the swap input tokens will be transferred from
Address to which the swap output tokens will be sent to
Deadline (in Unix time second) for the transaction to be executed. Default will be +20 minute. Cannot be in the past.
This is the amount of slippage the user can accept for his trade. The unit is bps. The value is in ranges [0, 2000], 10 means 0.1%. If no value is provided, slippageTolerance will be set to 0.
Referral info to include in the swap transaction's ClientData event.
The source of the swap to be recorded on-chain. You should use (and it defaults to be) the same value as the x-client-id
in the header, unless you want to track separate sources.
If true, call eth_gasEstimate to get gas estimation for the transaction. Also helps to detect any potential reverts.
Permit signature for tokenIn to allow swapping without a separate approval transaction beforehand. The permit's spender should be the routerAddress returned in the Get Swap Route API response.
If true, the slippage tolerance can be any value. Please use with caution.
Retrieve the information about a Swap between 2 tokens with encoded data to submit to KyberSwap router contract. RFQ liquidity sources are not supported. Please refer to Supported Exchanges And Networks for the full list of supported networks.
/{chain}/route/encode
Full list of supported chains available on Docs.
Address of the input token
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
in case of native token
Address of the output token
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
in case of native token
Amount of the input token (in wei)
false
/0
= route will be based on the maximum output token returned
true
/1
= route will be based on the lowest gas cost (i.e. the least hops)
This is the amount of slippage the user can accept for his trade. The unit is bip. The value is in ranges [0, 2000], 10 means 0.1%. If no value is provided, slippageTolerance will be set to 0.
if true, fee is taken in BPS
Indicates whether fee is charged by input token currency_in
or output token currency_out
Default is empty whereby no fee is charged
currency_in
, currency_out
Address to receive fee (if chargeFeeBy
is not empty)
Fee amount to be collected
if isInBps
= true
, feeAmount
is the percentage of fees that we will take with base unit = 10000, i.e feeAmount
= 10 and isInBps
= true
then fee = 0.1%
if isInBps
= false
, feeAmount
is the amount of token that we will take as fee, i.e feeAmount
= 10 and isInBps
= 'false' then fee = 10 token weis
Deadline (in Unix time second) for the transaction to be executed. Default will be +20 minute. Cannot be in the past.
1551036863
Address to receive the output token
Json string to include your client id in the source field if header cannot be used
{"source":"EnterYourClientIdHere"}
Your client id
Latest