> ## 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

```bash theme={null}
https://api.fibrous.finance/base/route
```

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

**amount** `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 ETH

**tokenInAddress** `string` *required*

The address of the input token.

Example: `"0x4200000000000000000000000000000000000006"` for ETH

**tokenOutAddress** `string` *required*

The address of the output token.

Example: `"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"` for USDC

**reverse** `boolean`

Not supported yet - reserved for future use.
Default: `false`

**direct** `boolean`

If true, only direct routes (single hop) will be considered.
Default: `false`

**excludeProtocols** `array[number]`

Comma-separated list of protocol IDs to exclude from routing (e.g., "1,2,3").
Default: `[]`

**integratorAddress** `string`

Integrator address for fee distribution.

**integratorFeePercentageBps** `number`

Integrator fee percentage in basis points (0-500) maximum 5%.
Example: `100` for 1%

**integratorSurplusPercentageBps** `number`

Integrator surplus percentage in basis points (0-5000) maximum 50%.
Example: `1000` for 10%

## Response

**success** `boolean`

Indicates if the route calculation was successful.

**inputToken** `object`

Details about the input token.

**name** `string`

The token's name (e.g., "Wrapped Ether")

**address** `string`

The token's contract address

**decimals** `number`

Number of decimals the token uses

**price** `number`

Current price of the token in USD

**inputAmount** `string`

Input amount in wei format.

**outputToken** `object`

Details about the output token.

**name** `string`

The token's name (e.g., "USD Coin")

**address** `string`

The token's contract address

**decimals** `number`

Number of decimals the token uses

**price** `number`

Current price of the token in USD

**outputAmount** `string`

The estimated amount of output tokens in wei format.

**estimatedGasUsed** `string`

Estimated gas cost for the swap in wei.

**estimatedGasUsedInUsd** `number`

Estimated gas cost in USD.

**time** `number`

Timestamp of route calculation.

**bestQuotesByProtocols** `array[string]`

Best quotes by protocols.

**initial** `boolean`

Whether this is an initial route.

**routeSwapType** `number`

Route swap type.

**integratorAddress** `string`

Integrator address.

**integratorFeePercentage** `number`

Integrator fee percentage in basis points (0-500) maximum 5%.

**integratorSurplusPercentage** `number`

Integrator surplus percentage in basis points (0-5000) maximum 50%.

**meta** `object`

API metadata including version and response timestamp.

**apiVersion** `string`

API version (e.g., "2.0")

**timestamp** `string`

Response timestamp in ISO 8601 format

**route** `array`

Array of route segments with detailed swap information.

**percent** `string`

Percentage of input amount going through this route

**swaps** `array`

Array of swap steps in this route segment

**protocol** `number`

Protocol identifier (e.g., 5 for Uniswap V3)

**poolName** `string`

Name of the liquidity pool

**poolAddress** `string`

Address of the liquidity pool

**percent** `string`

Percentage of the segment amount through this pool

**extraData** `object`

Protocol-specific parameters

```bash cURL theme={null}
curl -L \
  "https://api.fibrous.finance/base/route?amount=1000000000000000000&tokenInAddress=0x4200000000000000000000000000000000000006&tokenOutAddress=0x833589fcd6edb6e08f4c7c32d4f71b54bda02913" \
  --header "Accept: */*"
```

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

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

params = {
    "amount": "1000000000000000000",  # 1 ETH
    "tokenInAddress": "0x4200000000000000000000000000000000000006",
    "tokenOutAddress": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913"
}

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

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

const params = {
  amount: '1000000000000000000', // 1 ETH
  tokenInAddress: '0x4200000000000000000000000000000000000006',
  tokenOutAddress: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913'
};

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

```json Response theme={null}
{
  "success": true,
  "inputToken": {
    "name": "Wrapped Ether",
    "address": "0x4200000000000000000000000000000000000006",
    "decimals": 18,
    "price": 4337.55
  },
  "inputAmount": "1000000000000000000",
  "outputToken": {
    "name": "USD Coin",
    "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
    "decimals": 6,
    "price": 0.999796
  },
  "outputAmount": "4303439184",
  "estimatedGasUsed": "347407383168",
  "estimatedGasUsedInUsd": 0.0031034457390210508,
  "route": [
    {
      "percent": "100%",
      "swaps": [
        [
          {
            "protocol": 9,
            "poolName": "PancakeSwap V3",
            "poolAddress": "0x72ab388e2e2f6facef59e3c3fa2c4e29011c2d38",
            "fromTokenAddress": "0x4200000000000000000000000000000000000006",
            "toTokenAddress": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
            "percent": "100%",
            "extraData": {
              "fee": 100
            }
          }
        ]
      ]
    }
  ],
  "time": 0.858,
  "bestQuotesByProtocols": [],
  "initial": true,
  "routeSwapType": 2,
  "meta": {
    "apiVersion": "2.0",
    "timestamp": "2024-01-15T10:30:00.000Z"
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.