> For the complete documentation index, see [llms.txt](https://docs.anyroute.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.anyroute.xyz/sdk/openapi.md).

# Smart Router API

The SmartRouter API has two interfaces: **findPath** and **swapPath**.

* **findPath**: Estimates prices (provides quotes).
* **swapPath**: Generates on-chain transaction parameters.
* **swap**: Call Smart Contract.

### 1.Find Path

<pre><code>Path: https://smartx.anyroute.xyz/findPath?chainId=10143&#x26;amountIn=300000000000000000&#x26;tokenIn=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE&#x26;tokenOut=0xf817257fed379853cDe0fa4F97AB987181B1E5Ea&#x26;pathDeep=3&#x26;slippage=0.001&#x26;poolSafeMode=true
Type: GET
<strong>Request Param:
</strong>    chainId: 143
    amountIn: 300000000000000000
    tokenIn: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE(Native Token)
    tokenOut: out
    pathDeep: 3, Max 3, Max pools of One Router
    slippage: 0.005, 0.5%
    referral: user address, will share 50% protocol fee
    appFeeRecipient: app fee receiver
    appFeeRate: app fee rate, max 20% per tx, 20% limit by Aggregate SmartContract
    poolSafeMode: 
        true: The router will not include new tokens in the middle, ensuring that the router is always
        false: The router will include new tokens in the middle, Some spam tokens may cause swap failures
Response Param:
{
    "result_code": 0, // 0: OK
    "result_message": "",
    "result_data": {
        "chain_id": 10143,
        "routes": [ // Routers Array
            {
                "pools": [
                    { // First Pool of First Router
                        "pool_id": "0x7C2253A768E4AA90AFA9f9F246D8728064ee4c42",
                        "dex_id": 2, // DexID, 1: uniswapV2, 2:uniswapV3
                        "token_in": "0x760AfE86e5de5fa0Ee542fc7B7B713e1c5425701",
                        "token_out": "0xf817257fed379853cDe0fa4F97AB987181B1E5Ea",
                        "amount_in": "300000000000000000",
                        "amount_out": "0",
                        "min_amount_out": "2582336",
                        "fee": 500 // Denominator: 1000000
                    }
                ],
                "amount_in": "300000000000000000",
                "min_amount_out": "2582336"
            }
        ],
        "contract_in": "0x760AfE86e5de5fa0Ee542fc7B7B713e1c5425701",
        "contract_out": "0xf817257fed379853cDe0fa4F97AB987181B1E5Ea",
        "amount_in": "300000000000000000",
        "amount_out": "2584921",
        "min_amount_out": "2582336",
        "in_eth": true, // true: TokenIn is Native Token
        "out_eth": false // true: TokenOut is Native Token
    }
}
</code></pre>

### 2.Swap Path

<pre><code>Path: https://smartx.anyroute.xyz/swapPath
Type: Poost
<strong>Request Param:
</strong>    {
        "chain_id": 143,
        "deadline": 1744472550160,
        "routes": [ // response of findPath
            {
                "pools": [
                    {
                        "pool_id": "0x0B924f975F67632C1b8Af61B5B63415976a88791",
                        "dex_id": 1,
                        "token_in": "0x760AfE86e5de5fa0Ee542fc7B7B713e1c5425701",
                        "token_out": "0x836047a99e11F376522B447bffb6e3495Dd0637c",
                        "amount_in": "37500000000000000",
                        "amount_out": "0",
                        "min_amount_out": "0",
                        "fee": 0
                    },
                    {
                        "pool_id": "0xA9dC2fA6d8454961C253DfE9F84436f73eE19982",
                        "dex_id": 2,
                        "token_in": "0x836047a99e11F376522B447bffb6e3495Dd0637c",
                        "token_out": "0x88b8E2161DEDC77EF4ab7585569D2415a1C1055D",
                        "amount_in": "0",
                        "amount_out": "0",
                        "min_amount_out": "0",
                        "fee": 100
                    },
                    {
                        "pool_id": "0x2653c274082865f79996B4a8BB3f5C6cF89d6266",
                        "dex_id": 2,
                        "token_in": "0x88b8E2161DEDC77EF4ab7585569D2415a1C1055D",
                        "token_out": "0xf817257fed379853cDe0fa4F97AB987181B1E5Ea",
                        "amount_in": "0",
                        "amount_out": "0",
                        "min_amount_out": "372548",
                        "fee": 100
                    }
                ],
                "amount_in": "37500000000000000",
                "min_amount_out": "372548",
                "amount_out": "0"
            },
            {
                "pools": [
                    {
                        "pool_id": "0x719DDc248Cd1f0a8E771379E1dF472FA97E2547a",
                        "dex_id": 2,
                        "token_in": "0x760AfE86e5de5fa0Ee542fc7B7B713e1c5425701",
                        "token_out": "0x1d62a99977D111143f58D6235fF5df9Efe4B9B09",
                        "amount_in": "37500000000000000",
                        "amount_out": "0",
                        "min_amount_out": "0",
                        "fee": 3000
                    },
                    {
                        "pool_id": "0x5B5046039C671C723c8b6024Cf8DB1C7413ff582",
                        "dex_id": 2,
                        "token_in": "0x1d62a99977D111143f58D6235fF5df9Efe4B9B09",
                        "token_out": "0xf817257fed379853cDe0fa4F97AB987181B1E5Ea",
                        "amount_in": "0",
                        "amount_out": "0",
                        "min_amount_out": "368945",
                        "fee": 500
                    }
                ],
                "amount_in": "37500000000000000",
                "min_amount_out": "368945",
                "amount_out": "0"
            },
            {
                "pools": [
                    {
                        "pool_id": "0x0B924f975F67632C1b8Af61B5B63415976a88791",
                        "dex_id": 1,
                        "token_in": "0x760AfE86e5de5fa0Ee542fc7B7B713e1c5425701",
                        "token_out": "0x836047a99e11F376522B447bffb6e3495Dd0637c",
                        "amount_in": "37500000000000000",
                        "amount_out": "0",
                        "min_amount_out": "0",
                        "fee": 0
                    },
                    {
                        "pool_id": "0x89e15b5F62a724Acb308e3C5Ff7Be535A1a7fc8c",
                        "dex_id": 2,
                        "token_in": "0x836047a99e11F376522B447bffb6e3495Dd0637c",
                        "token_out": "0xf817257fed379853cDe0fa4F97AB987181B1E5Ea",
                        "amount_in": "0",
                        "amount_out": "0",
                        "min_amount_out": "364440",
                        "fee": 100
                    }
                ],
                "amount_in": "37500000000000000",
                "min_amount_out": "364440",
                "amount_out": "0"
            },
            {
                "pools": [
                    {
                        "pool_id": "0x827Ac01C1DECb57040FF41C902F090B42E7561Fe",
                        "dex_id": 2,
                        "token_in": "0x760AfE86e5de5fa0Ee542fc7B7B713e1c5425701",
                        "token_out": "0xcf5a6076cfa32686c0Df13aBaDa2b40dec133F1d",
                        "amount_in": "112500000000000000",
                        "amount_out": "0",
                        "min_amount_out": "0",
                        "fee": 100
                    },
                    {
                        "pool_id": "0x9b8B6fBb0AD45e5bBE2d6E81f264992adB5D799b",
                        "dex_id": 1,
                        "token_in": "0xcf5a6076cfa32686c0Df13aBaDa2b40dec133F1d",
                        "token_out": "0xf817257fed379853cDe0fa4F97AB987181B1E5Ea",
                        "amount_in": "0",
                        "amount_out": "0",
                        "min_amount_out": "1062780",
                        "fee": 0
                    }
                ],
                "amount_in": "112500000000000000",
                "min_amount_out": "1062780",
                "amount_out": "0"
            },
            {
                "pools": [
                    {
                        "pool_id": "0x6e4B7be5Ef7F8950C76BAa0bd90125BC9b33c8db",
                        "dex_id": 1,
                        "token_in": "0x760AfE86e5de5fa0Ee542fc7B7B713e1c5425701",
                        "token_out": "0x0F0BDEbF0F83cD1EE3974779Bcb7315f9808c714",
                        "amount_in": "75000000000000000",
                        "amount_out": "0",
                        "min_amount_out": "0",
                        "fee": 0
                    },
                    {
                        "pool_id": "0x4369AEf063306C8eDEd660a2018605D583353697",
                        "dex_id": 2,
                        "token_in": "0x0F0BDEbF0F83cD1EE3974779Bcb7315f9808c714",
                        "token_out": "0x88b8E2161DEDC77EF4ab7585569D2415a1C1055D",
                        "amount_in": "0",
                        "amount_out": "0",
                        "min_amount_out": "0",
                        "fee": 100
                    },
                    {
                        "pool_id": "0x2653c274082865f79996B4a8BB3f5C6cF89d6266",
                        "dex_id": 2,
                        "token_in": "0x88b8E2161DEDC77EF4ab7585569D2415a1C1055D",
                        "token_out": "0xf817257fed379853cDe0fa4F97AB987181B1E5Ea",
                        "amount_in": "0",
                        "amount_out": "0",
                        "min_amount_out": "704133",
                        "fee": 100
                    }
                ],
                "amount_in": "75000000000000000",
                "min_amount_out": "704133",
                "amount_out": "0"
            }
        ],
        "contract_in": "0x760AfE86e5de5fa0Ee542fc7B7B713e1c5425701",
        "contract_out": "0xf817257fed379853cDe0fa4F97AB987181B1E5Ea",
        "amount_in": "300000000000000000",
        "amount_out": "2875723",
        "min_amount_out": "2872847",
        "referral": "0x760AfE86e5de5fa0Ee542fc7B7B713e1c5425701", // Referral Account
        "in_eth":1, // 1: TokenIn is Native Token
        "out_eth":0 // 1: TokenOut is Native Token
    }
Response Param:
{
    // Data is the parameter of the aggregated Swap that can be directly uploaded to the chain
    "data": "0000000000000000000000000000000000000000000000000429d069189e000000000000000000000000000000000000000000000000000000000000002bd60f760afe86e5de5fa0ee542fc7b7b713e1c5425701f817257fed379853cde0fa4f97ab987181b1e5ea000001962aaaab1000000500000000000000000000000000000000000000000000000000853a0d2313c000030102020302760afe86e5de5fa0ee542fc7b7b713e1c5425701836047a99e11f376522b447bffb6e3495dd0637c02836047a99e11f376522b447bffb6e3495dd0637c88b8e2161dedc77ef4ab7585569d2415a1c1055d0288b8e2161dedc77ef4ab7585569d2415a1c1055df817257fed379853cde0fa4f97ab987181b1e5ea000300000064006400000000000000000000000000000000000000000000000000853a0d2313c0000202020202760afe86e5de5fa0ee542fc7b7b713e1c54257011d62a99977d111143f58d6235ff5df9efe4b9b09021d62a99977d111143f58d6235ff5df9efe4b9b09f817257fed379853cde0fa4f97ab987181b1e5ea00020bb801f400000000000000000000000000000000000000000000000000853a0d2313c0000201020202760afe86e5de5fa0ee542fc7b7b713e1c5425701836047a99e11f376522b447bffb6e3495dd0637c02836047a99e11f376522b447bffb6e3495dd0637cf817257fed379853cde0fa4f97ab987181b1e5ea000200000064000000000000000000000000000000000000000000000000018fae27693b40000202010202760afe86e5de5fa0ee542fc7b7b713e1c5425701cf5a6076cfa32686c0df13abada2b40dec133f1d02cf5a6076cfa32686c0df13abada2b40dec133f1df817257fed379853cde0fa4f97ab987181b1e5ea000200640000000000000000000000000000000000000000000000000000010a741a46278000030102020302760afe86e5de5fa0ee542fc7b7b713e1c54257010f0bdebf0f83cd1ee3974779bcb7315f9808c714020f0bdebf0f83cd1ee3974779bcb7315f9808c71488b8e2161dedc77ef4ab7585569d2415a1c1055d0288b8e2161dedc77ef4ab7585569d2415a1c1055df817257fed379853cde0fa4f97ab987181b1e5ea0003000000640064",
    "gas_limit": 2800000 // The estimated GasLimit will be too high. It is recommended to use the estimated value of rpc directly.
}
</code></pre>

### 3.Swap

#### Contract Address:

| Chain    | Contract Address                           |
| -------- | ------------------------------------------ |
| Monad    | 0xBb22D96bA9c9AF27A7e4bD7a2939D9c27636858c |
| BSC      | 0x20632d35a86c3Ce1e83270d7a0eb08318b754B0D |
| Base     | 0xF5352D62c9539cf5B8d87FCA0a6fB698e51c0f19 |
| Ethereum |                                            |
| Solana   |                                            |

#### Swap Method ABI:

```
[
  {
    "inputs": [
      {
        "internalType": "bytes",
        "name": "data",
        "type": "bytes"
      }
    ],
    "name": "swap",
    "outputs": [],
    "stateMutability": "payable",
    "type": "function"
  }
]
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.anyroute.xyz/sdk/openapi.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
