# Aggregator API

## Get Quote

**Base URL:**

```
https://open-aggregator-api.naviprotocol.io
```

<mark style="color:green;">`Get`</mark> `/find_routes`

The `find_routes` API endpoint identifies the optimal routes for swapping one token (`from`) to another (`target`) based on the specified amount and additional parameters. It determines the best swap paths by considering factors such as route depth and the input amount type.

**Headers**

| Name         | Value             | Description                                                                      |
| ------------ | ----------------- | -------------------------------------------------------------------------------- |
| x-navi-token | String (optional) | Serves the same function as `apiKey` in sdk, used to authenticate user requests. |
|              |                   |                                                                                  |

**Body**

| Name           | Type                 | Description                                                                                                                                                                                                                                                                                                                                                                                                            |
| -------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| from           | String               | The token address you are swapping from (e.g., `Sui-0x2::sui::SUI`).                                                                                                                                                                                                                                                                                                                                                   |
| target         | String               | The token address you want to swap to (e.g., `NAVX-0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX`).                                                                                                                                                                                                                                                                                   |
| amount         | String               | The amount of the `fromCoinAddress` token to swap, specified with decimals (e.g., `1000000000`).                                                                                                                                                                                                                                                                                                                       |
| by\_amount\_in | Boolean              | <p>Specifies whether the provided amount is the input amount for the swap.<br>Please only use <code>True</code></p>                                                                                                                                                                                                                                                                                                    |
| depth          | String               | <p>The maximum number of hops allowed in the route search, balancing performance and accuracy.<br>Default: <code>3</code></p>                                                                                                                                                                                                                                                                                          |
| dexList        | Enum List (optional) | <p></p><p>A comma-separated list of decentralized exchanges (DEXs) to include for routing the swap. If left empty, all available DEXs will be considered.<br>(e.g., <code>\['cetus', 'turbos']</code>)</p><p>Supported DEXs:</p><ul><li>Cetus</li><li>Turbos</li><li>Aftermath</li><li>Deepbook</li><li>Bluefin</li><li>Momentum</li><li>VSui</li><li>HaSui</li><li>Magma</li><li>Magma (ALMM)</li><li>FlowX</li></ul> |
| version        | Integer              | Higher versions may unlock more features. Current version is `12`                                                                                                                                                                                                                                                                                                                                                      |

**Sample Request**

```
https://open-aggregator-api.naviprotocol.io/find_routes?
from=0x2::sui::SUI&
target=0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7%3A%3Ausdc%3A%3AUSDC
&amount=100000000&by_amount_in=true&depth=3&version=12
```

**Sample Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "data": {
        "amount_in": "100000000",
        "amount_out": 223857,
        "routes": [
            {
                "path": [
                    {
                        "id": "0xa63347f0a3d79e36c629866d72d148403907088cca219d80bdd5461d79d34d46",
                        "type": "0x3492c874c1e3b3e2984e8c41b589e642d4d0a5d6459e5a9cfc2d52fd7c89c267::pool::Pool<0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI, 0x2::sui::SUI>",
                        "provider": "bluefin",
                        "from": "0x2::sui::SUI",
                        "target": "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI",
                        "a2b": false,
                        "direction": false,
                        "fee_rate": 100,
                        "lot_size": 0,
                        "amount_in": 100000000,
                        "amount_out": 95226771,
                        "extended_details": {
                            "after_sqrt_price": 0
                        },
                        "info_for_ptb": {
                            "packageId": "0x6c796c3ab3421a68158e0df18e4657b2827b1f8fed5ed4b82dba9c935988711b",
                            "moduleName": "gateway",
                            "functionName": "route_swap",
                            "byAmountIn": true,
                            "minSqrtPrice": "79226673515401279992447579055",
                            "amountLimit": 0,
                            "typeArguments": [
                                "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI",
                                "0x2::sui::SUI"
                            ]
                        }
                    },
                    {
                        "id": "0xaa020ad81e1621d98d4fb82c4acb80dc064722f24ef828ab633bef50fc28268b",
                        "type": "0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb::pool::Pool<0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC, 0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI>",
                        "provider": "cetus",
                        "from": "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI",
                        "target": "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",
                        "a2b": false,
                        "direction": false,
                        "fee_rate": 500,
                        "lot_size": 0,
                        "amount_in": 95226771,
                        "amount_out": 223857,
                        "extended_details": {
                            "after_sqrt_price": 0
                        },
                        "info_for_ptb": {
                            "globalConfigId": "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f",
                            "packageId": "0x6f5e582ede61fe5395b50c4a449ec11479a54d7ff8e0158247adfda60d98970b",
                            "moduleName": "router",
                            "functionName": "swap",
                            "typeArguments": [
                                "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",
                                "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI"
                            ],
                            "minSqrtPrice": "79226673515401279992447579055"
                        }
                    }
                ],
                "amount_in": 100000000,
                "amount_out": 223857,
                "initial_price": 0
            }
        ],
        "from_token": {
            "address": "0x2::sui::SUI",
            "decimals": 9,
            "price": 2.178773719491083
        },
        "to_token": {
            "address": "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",
            "decimals": 6,
            "price": 1.0002348920262438
        },
        "is_accurate": true
    }
}
```

{% endtab %}

{% tab title="400" %}

```json
{
    "error": "not support" //Means this method is not supported yet
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: 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:

```
GET https://naviprotocol.gitbook.io/astros/astros-dex-aggregator/aggregator-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
