Skip to main content
GET
/
{network}
/
v2
/
routeAndCallData
{
  "route": {
    "success": true,
    "inputToken": {},
    "outputToken": {},
    "outputAmount": "<string>",
    "route": [
      {}
    ],
    "meta": {}
  },
  "calldata": {
    "route": {
      "token_in": "<string>",
      "token_out": "<string>",
      "amount_in": "<string>",
      "amount_out": "<string>",
      "min_received": "<string>",
      "destination": "<string>",
      "swap_type": 123
    },
    "swap_parameters": [
      {
        "token_in": "<string>",
        "token_out": "<string>",
        "rate": "<string>",
        "protocol_id": "<string>",
        "pool_address": "<string>",
        "swap_type": 123,
        "extra_data": "<string>"
      }
    ]
  },
  "router_address": "<string>",
  "meta": {
    "apiVersion": "<string>",
    "timestamp": "<string>"
  }
}

Overview

The Route and Calldata V2 endpoint combines route finding and calldata generation in a single request, reducing API calls and latency. This is a V2-only endpoint that provides enhanced features including integrator support and metadata. Currently available on Evm networks.
This endpoint is V2-only and currently available on Evm networks. For V1, use separate /route and /calldata endpoints.

Endpoint

  • Evm networks
https://api.fibrous.finance/{network}/v2/routeAndCallData
Find the optimal trading route through Fibrous Finance’s liquidity pools and generate the transaction calldata for executing the swap. This endpoint combines route finding with calldata generation, making it ideal for direct integration with smart contracts.

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 token
tokenInAddress
string
required
The address of the input token.Example: "0x0000000000000000000000000000000000000000" for native token
tokenOutAddress
string
required
The address of the output token.Example: "0x3bd359c1119da7da1d913d1c4d2b7c461115433a" for wrapped token
reverse
boolean
Not supported yet - reserved for future use. Default: false
direct
boolean
If true, only direct swaps between the input and output tokens will be considered. Default: false
excludeProtocols
string
Comma-separated list of protocol IDs to exclude from routing (e.g., “1,2,3”). Default: ""
slippage
number
required
Maximum acceptable slippage percentage (0-49, e.g., 0.5 for 0.5%).
destination
string
required
Recipient address for the output tokens.
integratorAddress
string
Integrator wallet address to receive fees or surplus. Requires API key authentication.
integratorFeePercentageBps
number
Integrator fee percentage in basis points (0-500, maximum 5%). Cannot be used together with integratorSurplusPercentageBps.
integratorSurplusPercentageBps
number
Integrator surplus percentage in basis points (0-5000, maximum 50%). Cannot be used together with integratorFeePercentageBps.
API Key Required: Integrator features (integratorAddress, integratorFeePercentageBps, integratorSurplusPercentageBps) require an API key. Partners must obtain an API key from Fibrous Finance to use these monetization features. Include the API key in the request headers as X-API-Key.

Response

route
object
The complete route response object (same structure as /v2/route endpoint).
calldata
object
Transaction calldata for executing the swap.
router_address
string
Router contract address for executing the swap.
meta
object
required
API metadata including version and timestamp.

Example Request

curl -L \
  "https://api.fibrous.finance/{network}/v2/routeAndCallData?amount=1000000000000000000&tokenInAddress=0x0000000000000000000000000000000000000000&tokenOutAddress=0x3bd359c1119da7da1d913d1c4d2b7c461115433a&slippage=0.5&destination=0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb" \
  --header "Accept: */*"

Example Response

{
  "route": {
    "success": true,
    "routeSwapType": 0,
    "inputToken": {
      "name": "Monad",
      "address": "0x0000000000000000000000000000000000000000",
      "decimals": 18,
      "price": 0
    },
    "inputAmount": "1000000000000000000",
    "outputToken": {
      "name": "Wrapped Monad",
      "address": "0x3bd359c1119da7da1d913d1c4d2b7c461115433a",
      "decimals": 18,
      "price": 0
    },
    "outputAmount": "1000000000000000000",
    "estimatedGasUsed": "0",
    "estimatedGasUsedInUsd": 0,
    "route": [],
    "time": 0,
    "bestQuotesByProtocols": [],
    "initial": false,
    "meta": {
      "apiVersion": "2.0",
      "timestamp": "2024-01-15T10:30:00.000Z"
    }
  },
  "calldata": {
    "route": {
      "token_in": "0x0000000000000000000000000000000000000000",
      "token_out": "0x3bd359c1119da7da1d913d1c4d2b7c461115433a",
      "amount_in": "1000000000000000000",
      "amount_out": "1000000000000000000",
      "min_received": "995000000000000000",
      "destination": "0x742d35cc6634c0532925a3b844bc9e7595f0beb",
      "swap_type": 0
    },
    "swap_parameters": []
  },
  "router_address": "0x274602a953847d807231d2370072f5f4e4594b44",
  "meta": {
    "apiVersion": "2.0",
    "timestamp": "2024-01-15T10:30:00.000Z"
  }
}

When to Use This Endpoint

Use This Endpoint

  • Single-step swap execution
  • Minimizing API calls
  • Reducing latency
  • Simple integrations
  • Immediate execution needed

Use Separate Endpoints

  • Need to display route preview
  • User confirmation required
  • Complex routing logic
  • Custom route manipulation
  • Two-step flow preferred

Benefits Over V1 Approach

V1 (2 API calls):
  1. GET /route - Get optimal route
  2. GET /calldata - Generate calldata from route
V2 (1 API call):
  1. GET /v2/routeAndCallData - Get route and calldata together
This reduces:
  • API latency (one round trip instead of two)
  • API call count (50% reduction)
  • Code complexity (single request handling)

Best Practices

  1. Verify min_received - Always check that the minimum received amount matches your expectations
  2. Check destination - Ensure the destination address is correct before executing
  3. Use fresh data - This endpoint provides fresh route and calldata, ideal for immediate execution
  4. Monitor meta.timestamp - Track when the response was generated for debugging