> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fibrous.finance/llms.txt
> Use this file to discover all available pages before exploring further.

# Route

> Find the optimal trading route through Fibrous liquidity pools

## Endpoint

<CodeGroup>
  ```bash theme={null}
  https://api.fibrous.finance/hyperevm/route
  ```
</CodeGroup>

Find the optimal trading route through Fibrous's liquidity pools to maximize output and minimize slippage. This endpoint analyzes multiple protocols, pool depths, and potential paths to deliver the most efficient swap execution for your tokens.

## Query Parameters

<ParamField query="amount" type="string" required>
  The amount of input tokens in wei format. For tokens with 18 decimals, multiply the amount by 10^18.

  Example: `"1000000000000000000"` for 1 HYPE
</ParamField>

<ParamField query="tokenInAddress" type="string" required>
  The address of the input token.

  Example: `"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"` for HYPE
</ParamField>

<ParamField query="tokenOutAddress" type="string" required>
  The address of the output token.

  Example: `"0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb"` for USDC
</ParamField>

<ParamField query="reverse" type="boolean" optional>
  If true, the amount parameter represents the desired output amount instead of input amount.
  Default: `false`
</ParamField>

<ParamField query="direct" type="boolean" optional>
  If true, only direct swaps between the input and output tokens will be considered.
  Default: `false`
</ParamField>

<ParamField query="excludeProtocols" type="array[string]" optional>
  Array of protocol names to exclude from routing.
  Default: `[]`
</ParamField>

## Response

<ResponseField name="success" type="boolean">
  Indicates if the request was successful.
</ResponseField>

<ResponseField name="routeSwapType" type="number">
  Type of swap route
</ResponseField>

<ResponseField name="inputToken" type="object">
  Details about the input token.

  <Expandable>
    <ResponseField name="name" type="string">
      The token's name (e.g., "Wrapped Ether")
    </ResponseField>

    <ResponseField name="address" type="string">
      The token's contract address
    </ResponseField>

    <ResponseField name="decimals" type="number">
      Number of decimals the token uses
    </ResponseField>

    <ResponseField name="price" type="number">
      Current price of the token in USD
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="outputToken" type="object">
  Details about the output token.

  <Expandable>
    <ResponseField name="name" type="string">
      The token's name (e.g., "USD Coin")
    </ResponseField>

    <ResponseField name="address" type="string">
      The token's contract address
    </ResponseField>

    <ResponseField name="decimals" type="number">
      Number of decimals the token uses
    </ResponseField>

    <ResponseField name="price" type="number">
      Current price of the token in USD
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="outputAmount" type="string">
  The estimated amount of output tokens in wei format.
</ResponseField>

<ResponseField name="estimatedGasUsed" type="string">
  Estimated gas cost for the swap in wei.
</ResponseField>

<ResponseField name="estimatedGasUsedInUsd" type="number">
  Estimated gas cost in USD.
</ResponseField>

<ResponseField name="route" type="array">
  Array of route segments with detailed swap information.

  <Expandable>
    <ResponseField name="percent" type="string">
      Percentage of input amount going through this route
    </ResponseField>

    <ResponseField name="swaps" type="array">
      Array of swap steps in this route segment

      <Expandable>
        <ResponseField name="protocol" type="number">
          Protocol identifier (e.g., 5 for Uniswap V3)
        </ResponseField>

        <ResponseField name="poolName" type="string">
          Name of the liquidity pool
        </ResponseField>

        <ResponseField name="poolAddress" type="string">
          Address of the liquidity pool
        </ResponseField>

        <ResponseField name="percent" type="string">
          Percentage of the segment amount through this pool
        </ResponseField>

        <ResponseField name="extraData" type="object">
          Protocol-specific parameters
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -L \
    "https://api.fibrous.finance/hyperevm/route?amount=1000000000000000000&tokenInAddress=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&tokenOutAddress=0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb" \
    --header "Accept: */*"
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.fibrous.finance/hyperevm/route"

  params = {
      "amount": "1000000000000000000",  # 1 HYPE
      "tokenInAddress": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
      "tokenOutAddress": "0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb"
  }

  response = requests.get(url, params=params)
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const axios = require('axios');

  const params = {
    amount: '1000000000000000000', // 1 HYPE
    tokenInAddress: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
    tokenOutAddress: '0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb'
  };

  axios.get('https://api.fibrous.finance/hyperevm/route', { params })
    .then(response => console.log(response.data))
    .catch(error => console.error(error));
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
      "success": true,
      "routeSwapType": 0,
      "inputToken": {
          "name": "Wrapped HYPE",
          "address": "0x5555555555555555555555555555555555555555",
          "decimals": 18,
          "price": "55.19"
      },
      "inputAmount": "10000000000000000000",
      "outputToken": {
          "name": "USD₮0",
          "address": "0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb",
          "decimals": 6,
          "price": "1.001"
      },
      "outputAmount": "551482197",
      "time": 0.257,
      "estimatedGasUsed": "50659003741392",
      "estimatedGasUsedInUsd": 0.005660637078063142,
      "route": [
          {
              "percent": "100%",
              "swaps": [
                  [
                      {
                          "protocol": 13,
                          "poolName": "hybraFinanceV3",
                          "poolAddress": "0x5a716e045421b0977ca5bfb4f3394139c6a069bc",
                          "fromTokenAddress": "0x5555555555555555555555555555555555555555",
                          "toTokenAddress": "0xfd739d4e423301ce9385c1fb8850539d657c296d",
                          "percent": "100.00%",
                          "extraData": {
                              "fee": 25
                          }
                      }
                  ],
                  [
                      {
                          "protocol": 18,
                          "poolName": "kittenSwapAlgebraV4",
                          "poolAddress": "0x3cf44ef1500c1d559c8e81dffd6baeb0966b2712",
                          "fromTokenAddress": "0xfd739d4e423301ce9385c1fb8850539d657c296d",
                          "toTokenAddress": "0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb",
                          "percent": "98.00%",
                          "extraData": null
                      },
                      {
                          "protocol": 15,
                          "poolName": "gLiquidV3",
                          "poolAddress": "0x5e43a757ba769d4cd5fe568ae2429d4ae69e0ecf",
                          "fromTokenAddress": "0xfd739d4e423301ce9385c1fb8850539d657c296d",
                          "toTokenAddress": "0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb",
                          "percent": "2.00%",
                          "extraData": null
                      }
                  ]
              ]
          }
      ],
      "bestQuotesByProtocols": [],
      "initial": false
  }
  ```
</ResponseExample>
