### Example response of available tokens Source: https://docs.swapkit.dev/swapkit-api/swapfrom-request-sell-swap-options This is an example of the JSON response from the /swapFrom endpoint, listing various tokens available for swapping. The list can be extensive, especially for ERC-20 tokens. ```json [ "AVAX.AVAX", "BASE.ETH", "BCH.BCH", "BSC.BNB", "DOGE.DOGE", "ETH.ETH", "GAIA.ATOM", "LTC.LTC", "THOR.RUJI", "THOR.TCY", "TRON.TRX", "XRP.XRP", "THOR.RUNE", "AVAX.SOL-0XFE6B19286885A4F7F55ADAD09C3CD1F906D2478F", "AVAX.USDC-0XB97EF9EF8734C71904D8002F8B6BC66DD9C48A6E", "AVAX.USDT-0X9702230A8EA53601F5CD2DC00FDBC13D4DF4A8C7", "BASE.USDC-0X833589FCD6EDB6E08F4C7C32D4F71B54BDA02913", "BSC.BTCB-0X7130D2A12B9BCBFAE4F2634D864A1EE1CE3EAD9C", "BSC.BUSD-0XE9E7CEA3DEDCA5984780BAFC599BD69ADD087D56", "BSC.ETH-0X2170ED0880AC9A755FD29B2688956BD959F933F8", ... ``` -------------------------------- ### Swap Transaction Response Example Source: https://docs.swapkit.dev/swapkit-api/quote-and-swap-implementation-flow This is an example of a successful swap response, including transaction details like 'targetAddress', 'inboundAddress', and the transaction payload 'tx'. The 'txType' indicates the format of the transaction data. ```json { // ... all fields from above, plus: "targetAddress": "1FSHYruFaYjm5FQrzB3LmF15FMC3QwUFmy", "inboundAddress": "1FSHYruFaYjm5FQrzB3LmF15FMC3QwUFmy", "tx": "cHNidP8BAHUCAAAAAc86GvpcKcJoCV1YpX9orAcE/ZckHbLzuTXOPl0McccZAAAAAAD/////AoCWmAAAAAAAGXapFJ5Z+YVfu2g/WM/XGmu9FBGSeS5wiKx/LhEm4wAAABepFFKL8plEPOVGF9/52YVT+SKl3opehwAAAAAAAQEg/8SpJuMAAAAXqRRSi/KZRDzlRhff+dmFU/kipd6KXocAAAA=", "meta": { // ... existing meta fields, plus: "txType": "PSBT" } } ``` -------------------------------- ### GET /tokens Source: https://docs.swapkit.dev/swapkit-api/tokens-request-supported-tokens-by-a-swap-provider Fetches a list of supported tokens for a specified swap provider. ```APIDOC ## GET /tokens ### Description Provides a list of tokens supported by a specific swap provider. Requires a `provider` query parameter. ### Method GET ### Endpoint https://api.swapkit.dev/tokens #### Query Parameters - **provider** (string) - Required - The swap provider for which to retrieve tokens (e.g., CHAINFLIP). ### Request Example ```bash curl -X 'GET' \ 'https://api.swapkit.dev/tokens?provider=CHAINFLIP' \ -H 'accept: application/json' \ -H "x-api-key: YOUR_VARIABLE_HERE" ``` ### Response #### Success Response (200) - **provider** (string) - The name of the provider specified in the query. - **name** (string) - The name of the provider. - **timestamp** (string) - The timestamp of when the response was generated. - **version** (object) - The version of the token list. - **major** (number) - **minor** (number) - **patch** (number) - **keywords** (array) - Keywords associated with the token list. - **count** (number) - The number of tokens included in the response. - **tokens** (array) - An array of token objects. - **chain** (string) - The blockchain the token is associated with (e.g., ETH, BTC, SOL). - **address** (string) - The contract address of the token (only provided if it is not the gas token of the network). - **chainId** (string) - The ID of the chain (e.g., "42161" or "solana"). - **ticker** (string) - The ticker symbol of the token (e.g., ETH, BTC). - **identifier** (string) - An identifier for the token that combines chain and token address. - **symbol** (string) - The token symbol, which includes address information. - **name** (string) - The full name of the token. - **decimals** (number) - The number of decimal places the token supports. - **logoURI** (string) - A URL pointing to the token's logo image. - **coingeckoId** (string) - The identifier of the token on CoinGecko (if available). #### Response Example ```json { "provider": "CHAINFLIP", "name": "CHAINFLIP", "timestamp": "2025-01-11T16:31:04.355Z", "version": { "major": 1, "minor": 0, "patch": 0 }, "keywords": [], "count": 10, "tokens": [ { "chain": "BTC", "chainId": "bitcoin", "ticker": "BTC", "identifier": "BTC.BTC", "symbol": "BTC", "name": "Bitcoin", "decimals": 8, "logoURI": "https://storage.googleapis.com/token-list-swapkit/images/btc.btc.png", "coingeckoId": "bitcoin" }, { "chain": "ARB", "chainId": "42161", "ticker": "ETH", "identifier": "ARB.ETH", "symbol": "ETH", "name": "Arbitrum Ether", "decimals": 18, "logoURI": "https://storage.googleapis.com/token-list-swapkit/images/arb.eth.png", "coingeckoId": "ethereum" }, { "chain": "SOL", "address": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "chainId": "solana", "ticker": "USDC", "identifier": "SOL.USDC-EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "symbol": "USDC-EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "name": "Solana USDC", "decimals": 6, "logoURI": "https://storage.googleapis.com/token-list-swapkit/images/sol.usdc-epjfwdd5aufqssqem2qn1xzybapc8g4weggkzwytdt1v.png" }, ... ] } ``` ``` -------------------------------- ### Example Next Actions Object Source: https://docs.swapkit.dev/swapkit-api/v3-quote-request-a-swap-quote This JSON array contains information for the next action required to proceed with a swap, including the HTTP method, URL, and payload. ```json "nextActions": [ { "method": "POST", "url": "/swap", "payload": { "routeId": "14ddcf49-4adb-4817-a55e-1bfb1296283d" } } ] ``` -------------------------------- ### EVM Swap Transaction Example Source: https://docs.swapkit.dev/swapkit-api/v3-swap-obtain-swap-transaction-details Example of a transaction object for an EVM sell chain, representing a simple asset transfer. ```json "tx": { "to": "0x4e6960159d85254cb8e88483793f6fa8e9a49a4c", "from": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", "gas": "0x5208", "gasPrice": "0x9129260", "value": "3000000000000000000", "data": "0x" } ``` -------------------------------- ### Example Shortened Response for /swapTo Source: https://docs.swapkit.dev/swapkit-api/swapto-request-buy-swap-options The response lists all available tokens that can be swapped to. For ERC-20 tokens, this list can be extensive. ```json [ "AVAX.AVAX", "BASE.ETH", "BCH.BCH", "BSC.BNB", "DOGE.DOGE", "ETH.ETH", "GAIA.ATOM", "LTC.LTC", "THOR.RUJI", "THOR.TCY", "TRON.TRX", "XRP.XRP", "THOR.RUNE", "AVAX.SOL-0XFE6B19286885A4F7F55ADAD09C3CD1F906D2478F", "AVAX.USDC-0XB97EF9EF8734C71904D8002F8B6BC66DD9C48A6E", "AVAX.USDT-0X9702230A8EA53601F5CD2DC00FDBC13D4DF4A8C7", "BASE.USDC-0X833589FCD6EDB6E08F4C7C32D4F71B54BDA02913", "BSC.BTCB-0X7130D2A12B9BCBFAE4F2634D864A1EE1CE3EAD9C", "BSC.BUSD-0XE9E7CEA3DEDCA5984780BAFC599BD69ADD087D56", "BSC.ETH-0X2170ED0880AC9A755FD29B2688956BD959F933F8", ... ] ``` -------------------------------- ### Example Response for Supported Tokens (JSON) Source: https://docs.swapkit.dev/swapkit-api/tokens-request-supported-tokens-by-a-swap-provider This is a sample JSON response structure for the /tokens endpoint, detailing provider information and a list of available tokens with their respective properties. ```json { "provider": "CHAINFLIP", "name": "CHAINFLIP", "timestamp": "2025-01-11T16:31:04.355Z", "version": { "major": 1, "minor": 0, "patch": 0 }, "keywords": [], "count": 10, "tokens": [ { "chain": "BTC", "chainId": "bitcoin", "ticker": "BTC", "identifier": "BTC.BTC", "symbol": "BTC", "name": "Bitcoin", "decimals": 8, "logoURI": "https://storage.googleapis.com/token-list-swapkit/images/btc.btc.png", "coingeckoId": "bitcoin" }, { "chain": "ARB", "chainId": "42161", "ticker": "ETH", "identifier": "ARB.ETH", "symbol": "ETH", "name": "Arbitrum Ether", "decimals": 18, "logoURI": "https://storage.googleapis.com/token-list-swapkit/images/arb.eth.png", "coingeckoId": "ethereum" }, { "chain": "SOL", "address": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "chainId": "solana", "ticker": "USDC", "identifier": "SOL.USDC-EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "symbol": "USDC-EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "name": "Solana USDC", "decimals": 6, "logoURI": "https://storage.googleapis.com/token-list-swapkit/images/sol.usdc-epjfwdd5aufqssqem2qn1xzybapc8g4weggkzwytdt1v.png" }, ... ] } ``` -------------------------------- ### Example Route Metadata Object Source: https://docs.swapkit.dev/swapkit-api/v3-quote-request-a-swap-quote This JSON object provides additional details about a swap route, including asset information (price, image) and route tags like 'FASTEST'. ```json "meta": { "assets": [{ "asset": "ETH.ETH", "price": 2752.14, "image": "https://storage.googleapis.com/token-list-swapkit/images/eth.eth.png" }, { "asset": "BTC.BTC", "price": 97648, "image": "https://storage.googleapis.com/token-list-swapkit/images/btc.btc.png" }], "tags": ["FASTEST"] } ``` -------------------------------- ### Request Buy Swap Options Source: https://docs.swapkit.dev/swapkit-api/swapto-request-buy-swap-options Use this endpoint to get a list of tokens that can be bought with a specified asset. Include the token's identifier in the request URL. ```bash curl -X 'GET' \ 'https://api.swapkit.dev/swapTo?sellAsset=BTC.BTC' \ -H 'accept: application/json' \ -H "x-api-key: YOUR_VARIABLE_HERE" ``` -------------------------------- ### GET /providers Source: https://docs.swapkit.dev/swapkit-api/providers-request-supported-chains-by-a-swap-provider Retrieves a list of all available swap providers, their metadata, and the chains they support. ```APIDOC ## GET /providers ### Description Retrieves a comprehensive list of all available swap providers integrated by SwapKit and their supported chains and metadata. ### Method GET ### Endpoint https://api.swapkit.dev/providers ### Response #### Success Response (200) - **name** (string) - The name of the provider. - **provider** (string) - The identifier used by SwapKit to reference the provider. - **keywords** (array) - Relevant keywords for the provider. - **count** (number) - Number of supported tokens. - **logoURI** (string) - URL to the provider’s logo. - **url** (string) - URL to the provider’s token list. - **supportedChainIds** (array) - List of supported chain IDs for the provider. #### Response Example [ { "name": "CHAINFLIP_STREAMING", "provider": "CHAINFLIP_STREAMING", "keywords": [], "count": 10, "logoURI": "https://storage.googleapis.com/token-list-swapkit/images/eth.flip-0x826180541412d574cf1336d22c0c0a287822678a.png", "url": "https://storage.googleapis.com/token-list-swapkit/chainflip_streaming.json", "supportedActions": ["swap"], "supportedChainIds": ["42161", "bitcoin", "1", "solana"] } ] ``` -------------------------------- ### Handle insufficientBalance Error Response Source: https://docs.swapkit.dev/swapkit-api/quote-and-swap-implementation-flow Example JSON response structure when a wallet lacks sufficient tokens for a swap. ```json { "message": "Cannot build transaction. Insufficient balance for asset ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 amount 700 address 0x...", "error": "insufficientBalance", "data": { "chain": "ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "amount": "700", "address": "0x..." } } ``` -------------------------------- ### GET /swapTo - Request buy swap options Source: https://docs.swapkit.dev/swapkit-api/swapto-request-buy-swap-options This endpoint is used to retrieve a list of tokens that can be bought using a specified token. It returns all possible providers and can be used as an alternative filter to the /tokens endpoint or as a counterpart to the /swapFrom endpoints. ```APIDOC ## GET /swapTo ### Description Retrieves a list of tokens that can be bought using a specified token. This endpoint provides all possible providers and can be used as an alternative filter to the `/tokens` endpoint or as a counterpart to the `/swapFrom` endpoints. ### Method GET ### Endpoint `https://api.swapkit.dev/swapTo` ### Query Parameters - **sellAsset** (string) - Required - The identifier of the token you want to sell (e.g., `BTC.BTC`, `ETH.USDC-0XA0B86991C6218B36C1D19D4A2E9EB0CE3606EB48`). ### Request Example ```bash curl -X 'GET' \ 'https://api.swapkit.dev/swapTo?sellAsset=BTC.BTC' \ -H 'accept: application/json' \ -H "x-api-key: YOUR_VARIABLE_HERE" ``` ### Response #### Success Response (200) - An array of strings, where each string is a token identifier representing a token that can be bought. #### Response Example ```json [ "AVAX.AVAX", "BASE.ETH", "BCH.BCH", "BSC.BNB", "DOGE.DOGE", "ETH.ETH", "GAIA.ATOM", "LTC.LTC", "THOR.RUJI", "THOR.TCY", "TRON.TRX", "XRP.XRP", "THOR.RUNE", "AVAX.SOL-0XFE6B19286885A4F7F55ADAD09C3CD1F906D2478F", "AVAX.USDC-0XB97EF9EF8734C71904D8002F8B6BC66DD9C48A6E", "AVAX.USDT-0X9702230A8EA53601F5CD2DC00FDBC13D4DF4A8C7", "BASE.USDC-0X833589FCD6EDB6E08F4C7C32D4F71B54BDA02913", "BSC.BTCB-0X7130D2A12B9BCBFAE4F2634D864A1EE1CE3EAD9C", "BSC.BUSD-0XE9E7CEA3DEDCA5984780BAFC599BD69ADD087D56", "BSC.ETH-0X2170ED0880AC9A755FD29B2688956BD959F933F8", ... ] ``` ### Notes - Include the token's identifier in the request as a parameter, as in the example request. - For USDC on Ethereum, it would be `https://api.swapkit.dev/swapTo?sellAsset=ETH.USDC-0XA0B86991C6218B36C1D19D4A2E9EB0CE3606EB48` for example. - The response includes all available tokens to swap to using any of the providers SwapKit has available. Because of this, the list for an ERC-20 token will be quite long. ``` -------------------------------- ### EVM Transaction Response Source: https://docs.swapkit.dev/spotlights/api-migration-to-v3 Example of the transaction object returned by the /v3/swap endpoint for an EVM chain. ```json "tx": { "to": "0x4e6960159d85254cb8e88483793f6fa8e9a49a4c", "from": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", "gas": "0x5208", "gasPrice": "0x9129260", "value": "3000000000000000000", "data": "0x" }, ``` -------------------------------- ### Handle Quote Routing Errors Source: https://docs.swapkit.dev/swapkit-api/swap-types Example response when the specified providers parameter is too restrictive to find a valid route for the requested assets. ```json { "error": "noRoutesFound", "message": "No routes found for ETH.CRV-0xD533a949740bb3306d119CC777fa900bA034cd52 -> BTC.BTC", "data": { "sellAsset": "ETH.CRV-0xD533a949740bb3306d119CC777fa900bA034cd52", "buyAsset": "BTC.BTC" } } ``` -------------------------------- ### GET /swapFrom - Request sell swap options Source: https://docs.swapkit.dev/swapkit-api/swapfrom-request-sell-swap-options The /swapFrom endpoint is called specifying a token, and provides a list of tokens it can be sold for using SwapKit's API. The response includes all possible providers. It can be used as an alternative filter to the /tokens, or as a counterpart to the /swapTo endpoints. ```APIDOC ## GET /swapFrom ### Description Retrieves a list of tokens that a specified token can be sold for, including all possible providers. ### Method GET ### Endpoint https://api.swapkit.dev/swapFrom #### Query Parameters - **buyAsset** (string) - Required - The identifier of the token to check swap options for. ### Request Example ```bash curl -X 'GET' \ 'https://api.swapkit.dev/swapFrom?buyAsset=BTC.BTC' \ -H 'accept: application/json' \ -H "x-api-key: YOUR_VARIABLE_HERE" ``` ### Response #### Success Response (200) - An array of strings, where each string is a token identifier that the specified token can be sold for. #### Response Example ```json [ "AVAX.AVAX", "BASE.ETH", "BCH.BCH", "BSC.BNB", "DOGE.DOGE", "ETH.ETH", "GAIA.ATOM", "LTC.LTC", "THOR.RUJI", "THOR.TCY", "TRON.TRX", "XRP.XRP", "THOR.RUNE", "AVAX.SOL-0XFE6B19286885A4F7F55ADAD09C3CD1F906D2478F", "AVAX.USDC-0XB97EF9EF8734C71904D8002F8B6BC66DD9C48A6E", "AVAX.USDT-0X9702230A8EA53601F5CD2DC00FDBC13D4DF4A8C7", "BASE.USDC-0X833589FCD6EDB6E08F4C7C32D4F71B54BDA02913", "BSC.BTCB-0X7130D2A12B9BCBFAE4F2634D864A1EE1CE3EAD9C", "BSC.BUSD-0XE9E7CEA3DEDCA5984780BAFC599BD69ADD087D56", "BSC.ETH-0X2170ED0880AC9A755FD29B2688956BD959F933F8", ... ] ``` ### Notes - Include the token's identifier in the request as a parameter, as in the example request. - For USDC on Ethereum, it would be `https://api.swapkit.dev/swapTo?buyAsset=ETH.USDC-0XA0B86991C6218B36C1D19D4A2E9EB0CE3606EB48` for example - The response includes all available tokens to swap from using any of the providers SwapKit has available. Because of this, the list for an ERC-20 token will be quite long. ``` -------------------------------- ### Successful Price Response Source: https://docs.swapkit.dev/swapkit-api/price-lookup-token-prices This is an example of a successful JSON response when querying token prices, including CoinGecko metadata. ```json [ { "identifier": "ETH.ETH", "provider": "", "cg": { "id": "ethereum", "name": "Ethereum", "market_cap": 197138665861, "total_volume": 12560864823, "price_change_24h_usd": -39.89, "price_change_percentage_24h_usd": -2.38, "sparkline_in_7d": [...], "timestamp": "2025-04-15T12:30:44.643Z" }, "price_usd": 1653.61, "timestamp": 1744720254562 } ] ``` -------------------------------- ### Request Swap Transaction Source: https://docs.swapkit.dev/spotlights/api-migration-to-v3 Example payload for the /v3/swap endpoint using a routeId obtained from a quote. ```json { "routeId": "5ea8cd3a-05ae-4737-b223-dbcd4c7a6493", "sourceAddress": "0x0a4c79cE84202b03e95B7a692E5D728d83C44c76", "destinationAddress": "168w95Wf8tphgM7DPREXr8zLnVoE2wJCAN" } ``` -------------------------------- ### Example Estimated Time Object Source: https://docs.swapkit.dev/swapkit-api/v3-quote-request-a-swap-quote This JSON object represents the estimated time for a swap, broken down into inbound, swap, outbound, and total durations in seconds. ```json "estimatedTime": { "inbound": 30, "swap": 6, "outbound": 624, "total": 660 } ``` -------------------------------- ### Get Available NEAR Assets Source: https://docs.swapkit.dev/spotlights/near-chain-and-its-assets Use the /tokens endpoint with the provider parameter set to NEAR to retrieve a list of all tradeable NEAR assets. Ensure you check the token identifier format for both native NEAR and NEP-141 tokens. ```json https://api.swapkit.dev/tokens?provider=NEAR ``` -------------------------------- ### Request Supported Chains by Swap Provider (Bash) Source: https://docs.swapkit.dev/swapkit-api/providers-request-supported-chains-by-a-swap-provider Use this cURL command to fetch a list of all integrated swap providers and their supported chains from the SwapKit API. Ensure you replace YOUR_VARIABLE_HERE with your actual API key. ```bash curl -X 'GET' \ 'https://api.swapkit.dev/providers' \ -H 'accept: application/json' \ -H "x-api-key: YOUR_VARIABLE_HERE" ``` -------------------------------- ### Request Supported Tokens by Provider (Bash) Source: https://docs.swapkit.dev/swapkit-api/tokens-request-supported-tokens-by-a-swap-provider Use this command to fetch the list of tokens supported by a specific provider, like CHAINFLIP. Ensure you replace YOUR_VARIABLE_HERE with your actual API key. ```bash curl -X 'GET' \ 'https://api.swapkit.dev/tokens?provider=CHAINFLIP' \ -H 'accept: application/json' \ -H "x-api-key: YOUR_VARIABLE_HERE" ``` -------------------------------- ### Sample Provider Information (JSON) Source: https://docs.swapkit.dev/swapkit-api/providers-request-supported-chains-by-a-swap-provider This JSON structure represents a single provider's information as returned by the /providers endpoint. It includes details like name, logo, supported actions, and a list of chain IDs. ```json [ { "name": "CHAINFLIP_STREAMING", "provider": "CHAINFLIP_STREAMING", "keywords": [], "count": 10, "logoURI": "https://storage.googleapis.com/token-list-swapkit/images/eth.flip-0x826180541412d574cf1336d22c0c0a287822678a.png", "url": "https://storage.googleapis.com/token-list-swapkit/chainflip_streaming.json", "supportedActions": [ "swap" ], "supportedChainIds": [ "42161", "bitcoin", "1", "solana" ] }, ... ] ``` -------------------------------- ### POST /price Source: https://docs.swapkit.dev/swapkit-api/price-lookup-token-prices Fetches current price information and metadata for a list of tokens. ```APIDOC ## POST /price ### Description Retrieves the current price in USD and optional CoinGecko metadata for a provided list of token identifiers. ### Method POST ### Endpoint https://api.swapkit.dev/price ### Parameters #### Request Body - **tokens** (array) - Required - List of token identifiers to fetch price for. Each item is an object with an `identifier` field (e.g., `{ "identifier": "ETH.ETH" }`). - **metadata** (boolean) - Optional - If true, includes extended CoinGecko metadata. ### Request Example { "tokens": [ { "identifier": "ETH.ETH" }, { "identifier": "BTC.BTC" } ], "metadata": true } ### Response #### Success Response (200) - **identifier** (string) - The token identifier queried. - **price_usd** (number) - The current price of the token in USD. - **timestamp** (number) - Millisecond timestamp of the price fetch. - **cg** (object) - CoinGecko metadata (if metadata is requested). #### Response Example [ { "identifier": "ETH.ETH", "provider": "", "cg": { "id": "ethereum", "name": "Ethereum", "market_cap": 197138665861, "total_volume": 12560864823, "price_change_24h_usd": -39.89, "price_change_percentage_24h_usd": -2.38, "timestamp": "2025-04-15T12:30:44.643Z" }, "price_usd": 1653.61, "timestamp": 1744720254562 } ] ``` -------------------------------- ### Request sell swap options with curl Source: https://docs.swapkit.dev/swapkit-api/swapfrom-request-sell-swap-options Use this curl command to request a list of tokens that a specified token can be sold for. Include the token's identifier as a parameter. ```bash curl -X 'GET' \ 'https://api.swapkit.dev/swapFrom?buyAsset=BTC.BTC' \ -H 'accept: application/json' \ -H "x-api-key: YOUR_VARIABLE_HERE" ``` -------------------------------- ### NEAR Swap Quote Request Source: https://docs.swapkit.dev/spotlights/near-chain-and-its-assets Submit a POST request to the /quote endpoint to get swap rates and routing information for NEAR-based swaps. Ensure sellAmount is in the base unit and verify destination addresses for validity. ```json { "sellAsset": "NEAR.NEAR", "buyAsset": "AVAX.AVAX", "sellAmount": "10", "sourceAddress": "5c33c6218d47e00ef229f60da78d0897e1ee9665312550b8afd5f9c7bc6957d2", "destinationAddress": "0x0a4c79cE84202b03e95B7a692E5D728d83C44c76", "slippage": 3 } ``` -------------------------------- ### Fetch Prices for Multiple Tokens (cURL) Source: https://docs.swapkit.dev/swapkit-api/price-lookup-token-prices Use this cURL command to request prices for a list of tokens. Ensure you replace 'YOUR_VARIABLE_HERE' with your actual API key. ```sh curl -X POST \ 'https://api.swapkit.dev/price' \ -H 'Content-Type: application/json' \ -H "x-api-key: YOUR_VARIABLE_HERE" \ -d '{ "tokens": [ { "identifier": "ETH.ETH" }, { "identifier": "BTC.BTC" }, { "identifier": "SOL.SOL" }, {"identifier": "BSC.CAKE-0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82"} ], "metadata": true }' ``` -------------------------------- ### Fetch Price for a Single Token (cURL) Source: https://docs.swapkit.dev/swapkit-api/price-lookup-token-prices This cURL command demonstrates how to fetch the price for a single token. Remember to substitute 'YOUR_VARIABLE_HERE' with your API key. ```sh curl -X POST \ 'https://api.swapkit.dev/price' \ -H 'Content-Type: application/json' \ -H "x-api-key: YOUR_VARIABLE_HERE" \ -d '{ "tokens": [ { "identifier": "ETH.ETH" } ], "metadata": true }' ``` -------------------------------- ### List of Supported Providers (JSON) Source: https://docs.swapkit.dev/swapkit-api/providers-request-supported-chains-by-a-swap-provider This JSON array lists all the provider names that are currently integrated with SwapKit and available through the API. ```json [ "THORCHAIN", "THORCHAIN_STREAMING", "CHAINFLIP", "CHAINFLIP_STREAMING", "MAYACHAIN", "MAYACHAIN_STREAMING", "NEAR", "ONEINCH", "PANCAKESWAP", "TRADERJOE_V2", "UNISWAP_V2", "UNISWAP_V3", "CAVIAR_V1", "JUPITER", "CAMELOT_V3" ] ``` -------------------------------- ### SwapKit API General Notes Source: https://docs.swapkit.dev/swapkit-api/v3-swap-obtain-swap-transaction-details Additional notes regarding quote price refresh, balance checks, and latency for the SwapKit API. ```APIDOC ## Additional Notes ### Quote Price Refresh The quote response is cached for 60 seconds. If the `/swap` call is made after 60 seconds, the `/swap` endpoint will automatically fetch a fresh quote from the blockchain. If you always want to get the swap payload for the quote, ensure your calls are within this timeframe or handle quote refreshes accordingly. ### Balance Check By default, the API checks if the `sourceAddress` has a sufficient balance for the `fromAsset`. If you are using OKW as the wallet, which already performs this check internally, you can use `disableBalanceCheck: true` in the request body of the `/swap` request to skip this redundant check. ### Latency The `/swap` endpoint is more resource-intensive and slower due to several operations it performs: * Building the transaction payload. * Fetching UTXOs and constructing the PSBT when required. * Performing a balance check (unless disabled). * Automatically performing address screening on every `/swap` call. * Opening a deposit channel for NEAR or Chainflip providers, which can take up to 2.5 seconds. This endpoint should only be called after the user has selected a quote as their swap route. Other items included in the `/quote` endpoint response, such as `estimatedTime`, `totalSlippage`, or the fees breakdown, are also available in the `/swap` response. Some of these can be optionally excluded by using the parameters listed in the [request schema](#request-schema). ``` -------------------------------- ### Request a Swap Quote Source: https://docs.swapkit.dev/swapkit-api/quote-and-swap-implementation-flow Use this endpoint to fetch quotes for a swap. 'sourceAddress' and 'destinationAddress' are not needed for this initial quote request. Filter providers using the 'providers' argument if necessary. ```bash curl -X POST "https://api.swapkit.dev/v3/quote" \ -H "Content-Type: application/json" \ -H "x-api-key: YOUR_VARIABLE_HERE" \ -d '{ "sellAsset": "BTC.BTC", "buyAsset": "ETH.ETH", "sellAmount": "0.1", "slippage": 3 }' ``` -------------------------------- ### /swap Endpoint Optional Parameters Source: https://docs.swapkit.dev/swapkit-api/v3-swap-obtain-swap-transaction-details Details on optional parameters that can be included in the request body for the /swap endpoint. ```APIDOC ## /swap Endpoint Optional Parameters The `/swap` endpoint accepts several optional parameters in the request body to customize its behavior. ### Optional Parameters 1. **`disableBalanceCheck`** (boolean) - Optional * Skips checking the `sourceAddress` balance of the `fromAsset`. * Recommended for wallets that perform this check internally. 2. **`disableEstimate`** (boolean) - Optional * Skips gas estimation for EVM chains. 3. **`overrideSlippage`** (boolean) - Optional * Allows receiving a `/swap` transaction payload even if the output amount does not fit within the slippage parameter provided in the referenced `/quote` through the `routeId`. * This is relevant if a new quote has to be fetched. * *Note: This parameter is listed twice in the original text with the same description.* ``` -------------------------------- ### Request Swap Transaction Details Source: https://docs.swapkit.dev/swapkit-api/quote-and-swap-implementation-flow After selecting a route, use this endpoint to build the swap transaction. It requires the 'routeId' from the quote response and the user's addresses. The routeId is valid for 60 seconds. ```bash curl -X POST "https://api.swapkit.dev/v3/swap" \ -H "Content-Type: application/json" \ -H "x-api-key: YOUR_VARIABLE_HERE" \ -d '{ "routeId": "eed91159-86bd-4674-9558-48f7e4f8bac0", "sourceAddress": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", "destinationAddress": "357a3So9CbsNfBBgFYACGvxxS6tMaDoa1P" }' ``` -------------------------------- ### POST /v3/quote Source: https://docs.swapkit.dev/swapkit-api/v3-quote-request-a-swap-quote Request a swap quote to compare prices across different liquidity providers. ```APIDOC ## POST /v3/quote ### Description The first step towards performing a swap is requesting a quote, which will compare the price offered by the different swap providers. Quotes are cached for 5 minutes. ### Method POST ### Endpoint https://api.swapkit.dev/v3/quote ### Parameters #### Request Body - **sellAsset** (string) - Required - The asset being sold (e.g. "ETH.ETH"). - **buyAsset** (string) - Required - The asset being bought (e.g. "BTC.BTC"). - **sellAmount** (string) - Required - Amount in basic units (decimals separated with a dot). - **sourceAddress** (string) - Optional - Blockchain address to send the asset from. - **destinationAddress** (string) - Optional - Recipient blockchain address to send the asset to. - **providers** (array) - Optional - Limits the possible liquidity providers. - **slippage** (number) - Optional - Max slippage in percentage (5 = 5%). - **affiliateFee** (number) - Optional - Affiliate fee override in basis points (0-1000). - **cfBoost** (boolean) - Optional - Enables Chainflip boost for better rates. - **maxExecutionTime** (number) - Optional - Maximum execution time in seconds. ### Request Example { "sellAsset": "ETH.USDC-0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "buyAsset": "BTC.BTC", "sellAmount": "300", "slippage": 2 } ``` -------------------------------- ### Track NEAR Intents swap via depositAddress Source: https://docs.swapkit.dev/swapkit-api/track-request-the-status-of-a-swap Use this request to track NEAR Intents swaps by providing the deposit address instead of a hash and chain ID. ```bash curl -X 'POST' \ 'https://api.swapkit.dev/track' \ -H 'Content-Type: application/json' \ -H "x-api-key: YOUR_VARIABLE_HERE" \ -d '{ "depositAddress": "0x6f2B69c522031A7640b432172Ac84e57Dc0a3A63" }' ``` -------------------------------- ### Request Swap Quote Source: https://docs.swapkit.dev/swapkit-api/v3-quote-request-a-swap-quote Use this cURL command to request a quote for a swap. Ensure you replace 'YOUR_VARIABLE_HERE' with your actual API key. The request specifies the assets to sell and buy, the amount, and slippage tolerance. ```sh curl -X POST "https://api.swapkit.dev/v3/quote" \ -H "Content-Type: application/json" \ -H "x-api-key: YOUR_VARIABLE_HERE" \ -d '{ "sellAsset": "ETH.USDC-0xa0b86991c6218b36c1d19d4a2e9eb0cE3606eB48", "buyAsset": "BTC.BTC", "sellAmount": "300", "slippage": 2 }' ``` -------------------------------- ### SwapKit API Error Codes and Messages Source: https://docs.swapkit.dev/swapkit-api/v3-swap-obtain-swap-transaction-details A comprehensive list of error codes, their corresponding messages, HTTP status codes, and scenarios for the SwapKit API. ```APIDOC ## SwapKit API Error Codes and Messages This table outlines the various error codes, messages, status codes, and scenarios encountered when using the SwapKit API. | Error Code | Message | Status Code | Scenario | |---|---|---|---| | `swapRouteNotFound` | Route not found for routeId: {routeId} | 404 | The `routeId` does not exist in the cache (it may have expired after 5 minutes or never existed). The client must request a new quote first. | | `isSanctionedAddress` | Address {address} is sanctioned or risky | 400 | The source or destination address has been flagged by a screening service (Chainalysis/Elliptic) against sanctions lists and risk databases. | | `apiKeyInvalid` / `unauthorized` | "Invalid API key" / "Unauthorized” | 401 | The API key provided in the `x-api-key` header is missing, expired, or invalid. | | `insufficientBalance` | Insufficient balance for {chain} amount {amount} at address {address} | 400 | When `disableBalanceCheck` is `false`, the source address does not have sufficient tokens to complete the swap. The balance is fetched from the blockchain and compared to the `sellAmount`. | | `invalidSourceAddress` | Invalid source address: {address} | 400 | The source address validation fails due to an invalid format, being a smart contract when not allowed, or failing security checks. | | `invalidDestinationAddress` | Invalid destination address: {address} | 400 | The destination address validation fails due to an invalid format, being a smart contract when not allowed, or failing security checks. | | `outputAmountDeviationTooHigh` | Output amount deviation too high. Original: {originalAmount}, Refreshed: {refreshedAmount}, Deviation: {percentageChange}% | 400 | The quote was refreshed, and the new output amount deviates by more than 5% from the cached quote. This protects users from price slippage. This can be bypassed with `overrideSlippage: true`. | | `noRoutesFound` | No routes found for swap from {sellAsset} to {buyAsset} | 404 | When the quote is refreshed, no valid routes are returned from providers. This is rare and indicates that liquidity has dried up or all providers have failed. | ``` -------------------------------- ### Quote Route Schema Source: https://docs.swapkit.dev/swapkit-api/v3-quote-request-a-swap-quote Defines the structure of individual swap routes, providing details for comparing different providers. ```APIDOC ## Quote Route Schema ### Description Each route identifies a provider or group of providers for the swap, containing all necessary information to compare options. ### Fields - **routeId** (string) - UUID of this specific swap response - **providers** (array) - List of providers available for this route - **sellAsset** (string) - The asset being sold - **buyAsset** (string) - The asset being bought - **sellAmount** (string) - Amount of the sell asset in smallest units - **expectedBuyAmount** (string) - Estimated amount of the buy asset to be received - **expectedBuyAmountMaxSlippage** (string) - Worst-case buy amount considering max slippage - **fees** (array) - List of fees applied to the swap - **estimatedTime** (object) - Estimated time for different phases of the swap - **totalSlippageBps** (number) - Expected total slippage - **legs** (array) - The different involved steps in the swap - **warnings** (array) - Potential warnings about this swap provider - **meta** (object) - Other information about the transaction and the assets involved - **meta.tags** (array) - Tags like "FASTEST", "RECOMMENDED" or "CHEAPEST" - **nextActions** (object) - Data about next request to make in the flow ``` -------------------------------- ### Price Response for Unknown Token Source: https://docs.swapkit.dev/swapkit-api/price-lookup-token-prices This JSON shows the response format when a token identifier is not found or is incorrectly specified, resulting in a price of 0 USD. ```json [ { "identifier": "ETH.EHT", "provider": "", "price_usd": 0, "timestamp": 0 } ] ``` -------------------------------- ### Track transaction status via hash and chainId Source: https://docs.swapkit.dev/swapkit-api/track-request-the-status-of-a-swap Use this request to track a transaction by providing its specific hash and chain ID. ```bash curl -X 'POST' \ 'https://api.swapkit.dev/track' \ -H 'Content-Type: application/json' \ -H "x-api-key: YOUR_API_KEY_HERE" \ -d '{ "hash": "0x1890aba1c0b25126892af2ab09f5c1bba75adefc47918a96ea498764ab643ce9", "chainId": "1" }' ```