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
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.
If you're just getting started with the KyberSwap Aggregator, you can refer to our dev guide for information and code samples on how to query and execute swaps at superior rates. Note that there is also a option for integrators who require a simple minimal-code implementation. For existing integrators, please refer to for further details on the motivation behind the upgrade as well as the relevant changes to swap flow and parameters.
For every swap executed by the KyberSwap Aggregator, users will be able to see an estimated output amount based on the current price as well as a minimum received that takes into account the . KyberSwap Aggregator will always strive to execute swaps at the estimated output amount and revert the transaction if the minimum received amount is not achieved.
Note that this surplus is different from fees as it only applies in cases where the executed swap rate is better than the estimated rate at point of transaction confirmation. Please refer to for more information.
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 name. Full list of supported chains available in 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)
DEX IDs included in the route, separated by comma
DEX IDs excluded from the route, separated by comma
Exclude unscalable sources and only use sources that accept scaling input amounts
Determines whether to only return single-path route
Determines whether gas costs are accounted for when searching for best route
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 to 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 to take as fee, i.e feeAmount
= 10 and isInBps
= 'false' then fee = 10 token weis
Indicates that the API client wants to charge fee by input token (currency_in
) or output token (currency_out
).
Default is empty whereby no fee is charged.
if true, fee is taken in bps of the amount in/out, instead of absolute wei value
The API client's wallet 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.
MyAwesomeApp
{"code":0,"message":"successfully","data":{"routeSummary":{"tokenIn":"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619","amountIn":"1000000000000000000","amountInUsd":"1668.95","tokenOut":"0x2791bca1f2de4661ed88a30c99a7a9449aa84174","amountOut":"1666243758","amountOutUsd":"1665.9071767608839","gas":"253000","gasPrice":"181968304449","gasUsd":"0.06491355324609177","extraFee":{"feeAmount":"10","chargeFeeBy":"currency_out","isInBps":true,"feeReceiver":"0x0513c794bC2c65C6f374a86D6ad04425e32Df22e"},"route":[[{"pool":"0x4b543e89351faa242cb0172b2da0cdb52db699b4","tokenIn":"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619","tokenOut":"0x2791bca1f2de4661ed88a30c99a7a9449aa84174","swapAmount":"1000000000000000000","amountOut":"1667911669","exchange":"dodo","poolType":"dodo","poolExtra":{"type":"DPP","dodoV1SellHelper":"0xdfaf9584f5d229a9dbe5978523317820a8897c5a","baseToken":"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619","quoteToken":"0x2791bca1f2de4661ed88a30c99a7a9449aa84174"},"extra":{"amountIn":"1000000000000000000","filledOrders":[{"allowedSenders":"0x0000000000000000000000000000000000000000","feeAmount":"0","feeRecipient":"0x0000000000000000000000000000000000000000","filledMakingAmount":"950000","filledTakingAmount":"1000000000000000000","getMakerAmount":"f4a215c30000000000000000000000000000000000000000000000000000000011e1a3000000000000000000000000000000000000000000000000111e75953102eec1a0","getTakerAmount":"296637bf0000000000000000000000000000000000000000000000000000000011e1a3000000000000000000000000000000000000000000000000111e75953102eec1a0","interaction":"","isFallback":false,"maker":"0xda060fd9ae5b23cebf8abcb2d19fab152a419d61","makerAsset":"0xc2132d05d31c914a87c6611c10748aeb04b58e8f","makerAssetData":"","makerTokenFeePercent":0,"makingAmount":"300000000","orderId":9886,"permit":"","predicate":"961d5b1e000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000227b0c196ea8db17a665ea6824d972a64202e936000000000000000000000000227b0c196ea8db17a665ea6824d972a64202e9360000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000044cf6fc6e3000000000000000000000000da060fd9ae5b23cebf8abcb2d19fab152a419d61000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002463592c2b000000000000000000000000000000000000000000000000000000006453683300000000000000000000000000000000000000000000000000000000","receiver":"0xda060fd9ae5b23cebf8abcb2d19fab152a419d61","salt":"202362243813858115557509104206720377774","signature":"8fb37c9b14d9ccd7709ccc8289860c24580b69f1ab0e905a7d8c20e2ae5e45c570d33324990afb94a445246872545c5eaf9712b164a90ac7f97502d91a7c27001b","takerAsset":"0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270","takerAssetData":"","takingAmount":"315789473684210500000"}],"swapSide":"BUY"}}]],"routeID":"ee24c504-f256-4678-b25a-00480789d5f0","checksum":"10913824719960734178","timestamp":1744129861},"routerAddress":"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5"},"requestId":"fc4002ee-2678-4360-92a4-844b4b896c3f"}
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.
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)
DEX IDs included in the route, separated by comma
Exclude unscalable sources and only use sources that accept scaling input amounts
Determines whether gas costs are accounted for when searching for best route
Custom gas price in wei used when searching for the best swap route. Use result from eth_gasPrice otherwise
This is the amount of slippage the user can accept for his trade. The unit is bps (1/100 of 1%). The value is in ranges [0, 2000], with 10 meaning 0.1%, and 0.1 meaning 0.001%. If no value is provided, slippageTolerance will be set to 0.
Indicates that the API client wants to charge fee by input token (currency_in
) or output token (currency_out
).
Default is empty whereby no fee is charged.
The API client's wallet address to receive fee (if chargeFeeBy
is not empty)
if true, fee is taken in bps of the amount in/out, instead of absolute wei value
Fee amount to be collected
if isInBps
= true
, feeAmount
is the percentage of fees to 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 to take as fee, i.e feeAmount
= 10 and isInBps
= 'false' then fee = 10 token weis
Deadline (in Unix epoch second) for the transaction to be executed by. Default will be +20 minute. Cannot be in the past.
1744196804
Address to receive the output token
Json string to include your client id in the source field if header cannot be used
{"source":"MyAwesomeApp"}
Referral info to include in the swap transaction's ClientData event.
Encoded token's permit calldata to swap without approving. The permit's spender should be the routerAddress returned in the Get Swap Route API response. See /permit
If true, the slippage tolerance can be any value. Please use with caution.
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.
MyAwesomeApp
{"inputAmount":"1000000000000000000","outputAmount":"1667970343","totalGas":250000,"gasPriceGwei":"298.5144176","gasUsd":0.105226332201885,"amountInUsd":1668.59,"amountOutUsd":1667.970343,"receivedUsd":1667.865116667798,"swaps":[[{"pool":"0x45dda9cb7c25131df268515131f647d726f50608","tokenIn":"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619","tokenOut":"0x2791bca1f2de4661ed88a30c99a7a9449aa84174","swapAmount":"999000000000000000","amountOut":"1667970343","exchange":"uniswapv3","poolType":"univ3"}]],"tokens":{"0x2791bca1f2de4661ed88a30c99a7a9449aa84174":{"address":"0x2791bca1f2de4661ed88a30c99a7a9449aa84174","symbol":"USDC","name":"USD Coin","price":1,"decimals":6},"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619":{"address":"0x7ceb23fd6bc0add59e62ac25578270cff1b9f619","symbol":"WETH","name":"Wrapped Ether","price":1668.59,"decimals":18}},"encodedSwapData":"0xe21fd0e900000000000000000000000000000000000000000000000000000000000000200000000000000000000000001d5702c6d7eb30e42a8c94b8db7ea2e8444a37fd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000003c000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa841740000000000000000000000000000000000000000000000000000000062ec95af0000000000000000000000006131b5fae19ea4f9d964eac0408e4408b66337b50000000000000000000000000000000000000000000000000000000063f6f85b00000000000000000000000000000000000000000000000000000000000002c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000409e8aa9350000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000001d5702c6d7eb30e42a8c94b8db7ea2e8444a37fd00000000000000000000000045dda9cb7c25131df268515131f647d726f506080000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa841740000000000000000000000000000000000000000000000000ddd2935029d800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000002200000000000000000000000000513c794bc2c65c6f374a86d6ad04425e32df22e0000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000062ec95af0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000000010000000000000000000000001d5702c6d7eb30e42a8c94b8db7ea2e8444a37fd00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000ddd2935029d800000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000513c794bc2c65c6f374a86d6ad04425e32df22e0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001df7b22536f75726365223a22222c22416d6f756e74496e555344223a22313636382e3539222c22416d6f756e744f7574555344223a22313636372e393730333433222c22526566657272616c223a22222c22466c616773223a332c22496e74656772697479496e666f223a7b224b65794944223a2231222c225369676e6174757265223a225057614f647055363157744e724258424777424f77665434755547674f4e5162597654747273566d30422b626d362b6b58357362722f6b746f554e655a646b4c354378325576674541795a4a5248565349505558627833336a445262773356337549446c41584241687578616e353642524846686f7a492b422b4b396b3961716d4168712b6f4e49696e535939386e4d4a595072504b506c787a457657653043684d32756a4c7264395876474e7143494f6c7644526531426c5259425a552f625936593034454c3149796d6467684b544237316c32637541643274507335347347414f4e3534356e786a58746d6946674668343570754a5a6e6a7876524b3376754861306a71334357384f51444f41416661416261636176544b6774566b42592b4e5058683965495a6c6b4933596f766e44586e6e4236366652747647506175787a374750386a786e735730646164655a344f5a41513d3d227d7d00","routerAddress":"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5"}
Swap Found
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 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
Encoded token's permit calldata to swap without approving. The permit's spender should be the routerAddress returned in the Get Swap Route API response. See /permit
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 (1/100 of 1%). The value is in ranges [0, 2000], with 10 meaning 0.1%, and 0.1 meaning 0.001%. If no value is provided, slippageTolerance will be set to 0.
If true, the slippage tolerance can be any value. Please use with caution.
If true, call eth_gasEstimate to get gas estimation for the transaction. Also helps to detect any potential reverts.
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.
Referral info to include in the swap transaction's ClientData event.
{"code":0,"message":"successfully","data":{"amountIn":"1000000000000000000","amountInUsd":"1668.5","amountOut":"1666243758","amountOutUsd":"1666.243758","gas":"253000","gasUsd":"0.06491355324609177","additionalCostUsd":"0.0004381760190451663","additionalCostMessage":"L1 fee that pays for rolls up cost","data":"0xe21fd0e900000000000000000000000000000000000000000000000000000000000000200000000000000000000000001d5702c6d7eb30e42a8c94b8db7ea2e8444a37fd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000003e000000000000000000000000000000000000000000000000000000000000006600000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174000000000000000000000000000000000000000000000000000000006350dcae0000000000000000000000006131b5fae19ea4f9d964eac0408e4408b66337b50000000000000000000000000000000000000000000000000000000063f6fe9c00000000000000000000000000000000000000000000000000000000000002e0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000408a5da90f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000001d5702c6d7eb30e42a8c94b8db7ea2e8444a37fd0000000000000000000000004b543e89351faa242cb0172b2da0cdb52db699b40000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa841740000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dfaf9584f5d229a9dbe5978523317820a8897c5a0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000002791bca1f2de4661ed88a30c99a7a9449aa84174000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000002200000000000000000000000000513c794bc2c65c6f374a86d6ad04425e32df22e0000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000006350dcae00000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000000010000000000000000000000001d5702c6d7eb30e42a8c94b8db7ea2e8444a37fd00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000513c794bc2c65c6f374a86d6ad04425e32df22e0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001de7b22536f75726365223a22222c22416d6f756e74496e555344223a22313636382e35222c22416d6f756e744f7574555344223a22313636362e323433373538222c22526566657272616c223a22222c22466c616773223a332c22496e74656772697479496e666f223a7b224b65794944223a2231222c225369676e6174757265223a22435558755770383248546b6148425659454b574f784a7a76367a2b4f4d7952302f51324558726e41773863646e753474755344534744347a454367504f35374c626b6e366d5054344d5647726f30515a6f497750486c4a50615935426e4f347a416c6f5876532f4a4b31467066776553516b79726d555834793478624f554341655474497477546c726c4d64694e5474544852764c76555255436443443875362b6f4c68766f782b6e5336483378672f7453693566327673744471666166506864524b45496b432f7841584c4a3279764769567361564542722b55483943774e455a53756f7765424f4c4d386f4d7a3047306a4b7470395768756a50796171757832694b674f625271347974625976586935744f6d734d486935654574782b54705539546f694a5957317252456a447170426c486d5849526738714d734a6b46495361314e352f31374b447957482f48366f466e39513d3d227d7d0000","routerAddress":"0x6131B5fae19EA4f9D964eAc0408E4408b66337b5","transactionValue":"1000000000000000000"},"requestId":"9adab9e7-b007-4864-bf02-7f388b1c70cf"}