### Get Route API Request Examples Source: https://docs.kyberswap.com/kyberswap-solutions/kyberswap-zap-as-a-service/kyberswap-zap-as-a-service-zaas-api/zaas-http-api Provides example requests for the ZaaS API 'Get Route' endpoint using cURL, JavaScript, Python, and Ruby. These examples demonstrate how to query for swap routes with specific parameters and headers. ```Bash curl -X GET "https://zap-api.kyberswap.com/polygon/api/v1/in/route?dex=DEX_UNISWAPV3&pool.id=0xb46388f104ff88aac68626a316aaf3a924f32055&position.tickLower=-24800&position.tickUpper=32400&tokensIn=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE&amountsIn=1000000000000000000&slippage=100" \ -H "accept: application/json"\ -H "x-client-id: zap-docs" ``` ```JavaScript fetch('https://zap-api.kyberswap.com/polygon/api/v1/in/route?dex=DEX_UNISWAPV3&pool.id=0xb46388f104ff88aac68626a316aaf3a924f32055&position.tickLower=-24800&position.tickUpper=32400&tokensIn=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE&amountsIn=1000000000000000000&slippage=100', { headers: { 'accept': 'application/json', 'x-client-id': 'zap-docs' } }); ``` ```Python import requests headers = { 'accept': 'application/json', 'x-client-id': 'zap-docs', } params = { 'dex': 'DEX_UNISWAPV3', 'pool.id': '0xb46388f104ff88aac68626a316aaf3a924f32055', 'position.tickLower': '-24800', 'position.tickUpper': '32400', 'tokensIn': '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', 'amountsIn': '1000000000000000000', 'slippage': '100', } response = requests.get('https://zap-api.kyberswap.com/polygon/api/v1/in/route', params=params, headers=headers) ``` ```Ruby require 'net/http' uri = URI('https://zap-api.kyberswap.com/polygon/api/v1/in/route?dex=DEX_UNISWAPV3&pool.id=0xb46388f104ff88aac68626a316aaf3a924f32055&position.tickLower=-24800&position.tickUpper=32400&tokensIn=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE&amountsIn=1000000000000000000&slippage=100') req = Net::HTTP::Get.new(uri) req['accept'] = 'application/json' req['x-client-id'] = 'zap-docs' req_options = { use_ssl: uri.scheme == 'https' } res = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http| http.request(req) end ``` -------------------------------- ### Build Route Example Source: https://docs.kyberswap.com/kyberswap-solutions/kyberswap-zap-as-a-service/kyberswap-zap-as-a-service-zaas-api/zaas-http-api Demonstrates how to call the KyberSwap API to build a transaction route using various client languages. It includes examples for making POST requests with necessary headers and JSON payload. ```Bash curl -X POST "https://zap-api.kyberswap.com/polygon/api/v1/in/route/build" \ -H "accept: application/json"\ -H "content-type: application/json"\ -H "x-client-id: zap-docs" \ -d '{"sender":"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270","recipient":"0x5cb738DAe833Ec21fe65ae1719fAd8ab8cE7f23D","route":"KLUv/WALBWUVAKavgSFAb9qflX03+n9Wj9hEtiy3sD717uBIcklIUtb9UBVFASZwAG8AewCseGGDZz+f91M98txGAZqZqQsXPJhqdXGMHUIosW9O3X9D9ykvz587bZntFA+ybObckq051tD33d6immunvvu1fJ584ZaJB7tzeUH7jBfGkjJLmzw1GHNfFpS6uHNC7SJxoQMzFkbw7EKHR7EubGBGFDwMD76LRM+krFq9qkyNUC9kEi1HIhRHC7BQ8iwgDMREw9E88FRyoQUe3d1X1WmZdd13nzPVJkbpFzKe9ImUFau7UkkdoU7rrkob/cLF8yr1lzvRdntKumohg+d/c1MyvypzJ3ZnVvmqUP/CCZ4MFRR4b3mPgEmai5fykypW/M+uUGc6UqjV+vaERXQuLpywCFTMSWW+a2rki1JyJv301E6EuKEkvAnDloWPaYxxsAqB13BIFJo3IWEHB3k7n1FCrqvSKw5wk4ZUrp6p7OnTanbzoEAo2KPg8SYgEsWHb+4OUMcV4GmAOiwMlcrDQ6WC3tilpdQOpUrWinl/I8SaO19ljaGwCjy58OK5R0HTdAWK0Cu13SgoCBMNCNMGIhgMvlCiiXg8g4PuNRIRjmcBsBUAktd4MIa1iAeTaFy8CLOY4HlIKM1baBwUDqZ/XfvWqSrba5ma77q5X5V6i/o178ZAIBHMcHBY+BoKRIInQCBAAkOIkfEBRAi1htoyA+Fh2bFWvRh8hvz97PowAKx1qdsQ5xjp2pgs22UIOyQAShdlhjfwZzCdB+z1ohnGvFnSTTKxnORd4epZFuIeA+w2wAw7LgAorNLwQsqNf+xgg82V4vgsD37S9QzcQQb7FtadgPK3lKx7U4HBskxWQGuCP0HydKwMJ+YSsBBVIoM2YptDA0F2jZS8pJQuID3loJeJAg==","deadline":1800000000,"source":"zap-docs"}' ``` ```JavaScript fetch('https://zap-api.kyberswap.com/polygon/api/v1/in/route/build', { method: 'POST', headers: { 'accept': 'application/json', 'content-type': 'application/json', 'x-client-id': 'zap-docs' }, body: JSON.stringify({ 'sender': '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270', 'recipient': '0x5cb738DAe833Ec21fe65ae1719fAd8ab8cE7f23D', 'route': 'KLUv/WALBWUVAKavgSFAb9qflX03+n9Wj9hEtiy3sD717uBIcklIUtb9UBVFASZwAG8AewCseGGDZz+f91M98txGAZqZqQsXPJhqdXGMHUIosW9O3X9D9ykvz587bZntFA+ybObckq051tD33d6immunvvu1fJ584ZaJB7tzeUH7jBfGkjJLmzw1GHNfFpS6uHNC7SJxoQMzFkbw7EKHR7EubGBGFDwMD76LRM+krFq9qkyNUC9kEi1HIhRHC7BQ8iwgDMREw9E88FRyoQUe3d1X1WmZdd13nzPVJkbpFzKe9ImUFau7UkkdoU7rrkob/cLF8yr1lzvRdntKumohg+d/c1MyvypzJ3ZnVvmqUP/CCZ4MFRR4b3mPgEmai5fykypW/M+uUGc6UqjV+vaERXQuLpywCFTMSWW+a2rki1JyJv301E6EuKEkvAnDloWPaYxxsAqB13BIFJo3IWEHB3k7n1FCrqvSKw5wk4ZUrp6p7OnTanbzoEAo2KPg8SYgEsWHb+4OUMcV4GmAOiwMlcrDQ6WC3tilpdQOpUrWinl/I8SaO19ljaGwCjy58OK5R0HTdAWK0Cu13SgoCBMNCNMGIhgMvlCiiXg8g4PuNRIRjmcBsBUAktd4MIa1iAeTaFy8CLOY4HlIKM1baBwUDqZ/XfvWqSrba5ma77q5X5V6i/o178ZAIBHMcHBY+BoKRIInQCBAAkOIkfEBRAi1htoyA+Fh2bFWvRh8hvz97PowAKx1qdsQ5xjp2pgs22UIOyQAShdlhjfwZzCdB+z1ohnGvFnSTTKxnORd4epZFuIeA+w2wAw7LgAorNLwQsqNf+xgg82V4vgsD37S9QzcQQb7FtadgPK3lKx7U4HBskxWQGuCP0HydKwMJ+YSsBBVIoM2YptDA0F2jZS8pJQuID3loJeJAg==', 'deadline': 1800000000, 'source': 'zap-docs' }) }); ``` ```Python import requests headers = { 'accept': 'application/json', 'content-type': 'application/json', 'x-client-id': 'zap-docs', } json_data = { 'sender': '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270', 'recipient': '0x5cb738DAe833Ec21fe65ae1719fAd8ab8cE7f23D', 'route': 'KLUv/WALBWUVAKavgSFAb9qflX03+n9Wj9hEtiy3sD717uBIcklIUtb9UBVFASZwAG8AewCseGGDZz+f91M98txGAZqZqQsXPJhqdXGMHUIosW9O3X9D9ykvz587bZntFA+ybObckq051tD33d6immunvvu1fJ584ZaJB7tzeUH7jBfGkjJLmzw1GHNfFpS6uHNC7SJxoQMzFkbw7EKHR7EubGBGFDwMD76LRM+krFq9qkyNUC9kEi1HIhRHC7BQ8iwgDMREw9E88FRyoQUe3d1X1WmZdd13nzPVJkbpFzKe9ImUFau7UkkdoU7rrkob/cLF8yr1lzvRdntKumohg+d/c1MyvypzJ3ZnVvmqUP/CCZ4MFRR4b3mPgEmai5fykypW/M+uUGc6UqjV+vaERXQuLpywCFTMSWW+a2rki1JyJv301E6EuKEkvAnDloWPaYxxsAqB13BIFJo3IWEHB3k7n1FCrqvSKw5wk4ZUrp6p7OnTanbzoEAo2KPg8SYgEsWHb+4OUMcV4GmAOiwMlcrDQ6WC3tilpdQOpUrWinl/I8SaO19ljaGwCjy58OK5R0HTdAWK0Cu13SgoCBMNCNMGIhgMvlCiiXg8g4PuNRIRjmcBsBUAktd4MIa1iAeTaFy8CLOY4HlIKM1baBwUDqZ/XfvWqSrba5ma77q5X5V6i/o178ZAIBHMcHBY+BoKRIInQCBAAkOIkfEBRAi1htoyA+Fh2bFWvRh8hvz97PowAKx1qdsQ5xjp2pgs22UIOyQAShdlhjfwZzCdB+z1ohnGvFnSTTKxnORd4epZFuIeA+w2wAw7LgAorNLwQsqNf+xgg82V4vgsD37S9QzcQQb7FtadgPK3lKx7U4HBskxWQGuCP0HydKwMJ+YSsBBVIoM2YptDA0F2jZS8pJQuID3loJeJAg==', 'deadline': 1800000000, 'source': 'zap-docs', } response = requests.post('https://zap-api.kyberswap.com/polygon/api/v1/in/route/build', headers=headers, json=json_data) ``` -------------------------------- ### Install KyberSwap Liquidity Widget Source: https://docs.kyberswap.com/kyberswap-solutions/kyberswap-liquidity-widget/integrating-the-kyberswap-liquidity-widget Instructions for installing the KyberSwap Liquidity Widget library using npm or Yarn package managers. This is the initial step required to integrate the widget into your project. ```bash npm i @kyberswap/liquidity-widgets ``` ```bash yarn add @kyberswap/liquidity-widgets ``` -------------------------------- ### Install KyberSwap Widget via npm Source: https://docs.kyberswap.com/kyberswap-solutions/kyberswap-widget/developer-guides/integrating-the-kyberswap-widget Installs the KyberSwap widgets library using the npm package manager. This is the first step to integrating the swap widget into your project. ```shell npm i @kyberswap/widgets ``` -------------------------------- ### Install KyberSwap Widget via Yarn Source: https://docs.kyberswap.com/kyberswap-solutions/kyberswap-widget/developer-guides/integrating-the-kyberswap-widget Installs the KyberSwap widgets library using the Yarn package manager. This is an alternative to npm for installing the necessary dependencies. ```shell yarn add @kyberswap/widgets ``` -------------------------------- ### ZaaS API: Get Route Endpoint Source: https://docs.kyberswap.com/kyberswap-solutions/kyberswap-zap-as-a-service/kyberswap-zap-as-a-service-zaas-api/zaas-http-api This entry details the 'Get Route' endpoint for the ZaaS API, which helps find optimal routes for token swaps. It includes the OpenAPI specification URL and example requests for fetching routing information. ```APIDOC OpenAPI Specification: https://1368568567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fw1XgQJc40kVeGUIxgI7c%2Fuploads%2FKb7c0Iq7tzY7f82rIq8J%2Fopenapi.yaml?alt=media&token=dc0081be-5e7a-4a26-932b-b6f8d6ebe333 Endpoint: GET /api/v1/in/route Description: Retrieves the optimal route for a token swap (zap in) based on specified parameters like DEX, pool ID, tick ranges, input tokens, amounts, and slippage. Parameters: - dex: The decentralized exchange identifier (e.g., DEX_UNISWAPV3). - pool.id: The ID of the liquidity pool. - position.tickLower: The lower tick bound for concentrated liquidity positions. - position.tickUpper: The upper tick bound for concentrated liquidity positions. - tokensIn: The input token address or identifier. - amountsIn: The amount of input tokens. - slippage: The maximum acceptable slippage percentage. Headers: - accept: application/json - x-client-id: A unique identifier for the client, required for rate limiting. Base URL: https://zap-api.kyberswap.com/{chain} (where {chain} is a supported blockchain, e.g., 'arbitrum'). ``` -------------------------------- ### KyberSwap Aggregator API V1 Get Swap Route (APIDOC) Source: https://docs.kyberswap.com/kyberswap-solutions/kyberswap-aggregator/developer-guides/execute-a-swap-with-the-aggregator-api The V1 Get Swap Route API allows integrators to query for optimal swap rates by providing tokenIn, tokenOut, and amountIn parameters. The API returns a data object containing routeSummary for human-readable routing data and routerAddress for the contract facilitating the swap. This is the recommended API for efficient route queries. ```apidoc API: GET /v1/routes Description: Queries for superior swap rates and routing information. Parameters: - tokenIn: (Required) The address of the input token. - tokenOut: (Required) The address of the output token. - amountIn: (Required) The amount of the input token to be swapped, represented as a string. - ... (other optional parameters available on specification page) Returns: - routeSummary: An object containing routing data in a human-readable format, representing the best rate found. - routerAddress: The address of the KyberSwap router contract that facilitates the swap. Example Usage: GET /v1/routes?tokenIn=0x...&tokenOut=0x...&amountIn=1000000000000000000 Note: This API is part of the V1 Aggregator API, which is more performant than the non-versioned API. ``` -------------------------------- ### KNCL to KNC v2 Migration Process Source: https://docs.kyberswap.com/governance/kyberdao/faq Step-by-step guide on how to migrate legacy KNCL tokens to the new KNC v2 token using the KyberSwap migration portal. This process involves connecting a wallet, approving the token, and initiating the migration transaction. ```APIDOC Migration Portal: https://kyberswap.com/kyberdao/stake-knc Steps: 1. Connect wallet to KyberSwap on the Ethereum network. 2. Open the migration portal UI. 3. Approve KNCL balance for use (one-time onchain transaction). 4. Specify KNCL amount to migrate and click 'Migrate' (onchain transaction). ``` -------------------------------- ### Embed KyberSwap iFrame Source: https://docs.kyberswap.com/kyberswap-solutions/kyberswap-widget/iframe-alternative Example of how to embed the KyberSwap iFrame into a website or dApp using JSX. Demonstrates common parameter configurations for input/output currencies, fee settings, and chain ID. ```jsx