EVM Swaps

KyberSwap Aggregator EVM APIs

Download OpenAPI specification:

circle-check

Note on integrations: clientID

EVM swap APIs

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 From APIv1 To APIv2 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, KyberSwap highly encourages all integrators to implement the latest API [V2] version. While both versions of the API remains backwards compatible, only the [V2] APIs will continue to receive updates and hence developers are highly encouraged to implement the latest [V2] APIs to avoid any disruptions as the [V1] API will eventually be deprecated.

circle-info

ZkSync Era support

For integrators looking to build on top of the KyberSwap Aggregator on ZkSync Era (ChainID: 324), please note that only the [V2] API is supported.

API [V2]: Latest

[V2] Get Swap Route

get

Retrieve the route information about a Swap between 2 tokens. Please use V2 GET API for a more performant route query. 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.

Path parameters
chainstringRequired

Supported chains:

  • arbitrum
  • aurora
  • avalanche
  • bsc
  • bttc
  • cronos
  • ethereum
  • fantom
  • oasis
  • polygon
  • velas
  • optimism
  • zksync
Query parameters
tokenInstringRequired

Address of the input token 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE in case of native token

tokenOutstringRequired

Address of the output token 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE in case of native token

amountInstringRequired

Amount of the input token (in wei)

saveGasbooleanOptional

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)

includedSourcesstringOptional

DEX IDs included in the route, separated by comma

excludedSourcesstringOptional

DEX IDs excluded from the route, separated by comma

gasIncludebooleanOptional

Determines whether gas costs are included when searching for route

gasPricestringOptional

Estimated price of gas required for swap, in wei units

feeAmountstringOptional

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

chargeFeeBystring · enumOptional

Indicates whether fee is charged by input token currency_in or output token currency_out Default is empty whereby no fee is charged

Possible values:
isInBpsbooleanOptional

if true, fee is taken in BPS

feeReceiverstringOptional

Address to receive fee (if chargeFeeBy is not empty)

Header parameters
x-client-idstringOptional

String to present to your client (i.e. clientID)

Responses
chevron-right
200

Swap Found

application/json
codestringOptional

Response code

messagestringOptional

Response message

get
/{chain}/api/v1/routes

[V2] Post Swap Route For Encoded Data

post

Get the encoded swap route to be forwarded to the KyberSwap router contract. For simplicity, the request body should contain the routeSummary returned by [V2] Get Swap Route appended with the additional tx parameters.

Path parameters
chainstringRequired

Supported chains:

  • arbitrum
  • aurora
  • avalanche
  • bsc
  • bttc
  • cronos
  • ethereum
  • fantom
  • oasis
  • polygon
  • velas
  • optimism
  • zksync
Header parameters
x-client-idstringOptional

String to present to your client (i.e. clientID)

Body
deadlineintegerOptional

Deadline (in Unix time second) for the transaction to be executed. Default will be +20 minute. Cannot be in the past.

slippageToleranceintegerOptional

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%. Default value is 50/10000 ~ 0.5%.

senderstringRequired

Address which the swap input tokens will be debited from

recipientstringRequired

Address which the swap output tokens will be sent to

sourcestringOptional

String to present to your client (i.e. clientID)

Responses
chevron-right
200

Successfully encoded

application/json
codestringOptional

Response code

messagestringOptional

Response message

post
/{chain}/api/v1/route/build

API [V1]: Sunset period

[V1] Get Swap Info with Encoded Data

get

Retrieve the information about a Swap between 2 tokens with encoded data to submit to KyberSwap router contract

Path parameters
chainstringRequired

Supported chains:

  • arbitrum
  • aurora
  • avalanche
  • bsc
  • bttc
  • cronos
  • ethereum
  • fantom
  • oasis
  • polygon
  • velas
  • optimism
Query parameters
tokenInstringRequired

Address of the input token 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE in case of native token

tokenOutstringRequired

Address of the output token 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE in case of native token

amountInstringRequired

Amount of the input token (in wei)

saveGasbooleanOptional

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)

slippageTolerancestringOptional

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%. Default value is 50/10000 ~ 0.5%.

isInBpsbooleanOptional

if true, fee is taken in BPS

chargeFeeBystring · enumOptional

Indicates whether fee is charged by input token currency_in or output token currency_out Default is empty whereby no fee is charged

Possible values:
feeReceiverstringOptional

Address to receive fee (if chargeFeeBy is not empty)

feeAmountstringOptional

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

deadlinestringOptional

Deadline (in Unix time second) for the transaction to be executed. Default will be +20 minute. Cannot be in the past.

Example: 1551036863
tostringRequired

Address to receive the output token

clientDatastringOptional

Json string to present to your client (i.e. clientID)

Example: {"source":"EnterYourClientIdHere"}
Header parameters
Accept-Versionstring · enumRequired

Version of Aggregator

Possible values:
Responses
chevron-right
200

Swap Found

application/json
inputAmountstringOptional

The input amount of tokenIn, in wei

outputAmountstringOptional

The input amount of tokenOut, in wei

totalGasintegerOptional

Estimated gas fee

gasPriceGweistringOptional

Current gas price in Gwei

gasUsdnumberOptional

Current gas price in USD

amountInUsdnumberOptional

Estimate of input value, in USD

amountOutUsdnumberOptional

Estimate of out value, in USD

receivedUsdnumberOptional

Estimate of final received value, in USD

encodedSwapDatastringOptional

The encoded data to be sent to our router address

routerAddressstringOptional

The KyberSwap router address

get
/{chain}/route/encode
200

Swap Found

Last updated

Was this helpful?