Quote API
Use the https://route.withfabric.xyz/v1/quote endpoint to fetch quotes and executable routing details to perform token swaps.
Request Parameters
All request parameters are passed as query parameters via a GET request. Required parameters must be included for a quote to be generated.
| Name | Type | Required | Description |
|---|---|---|---|
chainId | number | Yes | The chain ID to execute the trade on |
sellToken | address | Yes | The token being sold (EVM address) |
buyToken | address | Yes | The token being bought (EVM address) |
sellAmount | dec_string | Conditional | The amount of input tokens to sell. Mutually exclusive with buyAmount |
buyAmount | dec_string | Conditional | The amount of output tokens to buy. Mutually exclusive with sellAmount |
slippageBps | number | No | The maximum slippage in basis points the user is willing to accept (default 100 bps) |
receiver | address | No | The address to receive the output tokens (EVM address, defaults to the caller) |
feeBps | number | No | The fee in basis points to be taken from the trade (max 1000 bps) |
feeRecipient | address | Conditional | The recipient of the fee (EVM address). Required if feeBps is set |
surplusFeeBps | number | No | Surplus fee in basis points to be taken from the trade (max 10000 bps) |
surplusFeeRecipient | address | Conditional | Surplus fee recipient (EVM address). Required if surplusFeeBps is set |
referralFeeBps | number | No | Referral fee in basis points (max 1000 bps) |
referralFeeRecipient | address | Conditional | Referral fee recipient (EVM address). Required if referralFeeBps is set |
Response Payload
The response payload for a successful quote request will contain the following fields as a JSON object:
| Field | Type | Description |
|---|---|---|
blockNumber | number | The block number the quote was generated at |
amountIn | dec_string | The amount the user sends |
amountOut | dec_string | The amount the user receives |
minimumAmountOut | dec_string | The minimum amount the user receives depending on slippage protection settings |
price | number? | The scaled price ratio between input and output tokens (input/output) |
description | string | A description of the quote |
tokens | array | List of tokens involved in the route |
tokens.address | address | The address of the token contract |
tokens.symbol | string | The symbol of the token |
tokens.decimals | number | The number of decimals the token uses |
tokens.transferFeeBps | number | The bps fee on transfer |
tokens.priceUsd | number? | The USD price of the token (if available) |
route | object | The route details used for the quote |
route.swaps | array | The sequence(s) of swaps in the route |
route.swaps.key | string | A unique key identifying the pool |
route.swaps.address | address | The address of the liquidity pool |
route.swaps.protocol | string | The protocol of the liquidity pool |
route.swaps.fork | string | The name of the fork |
route.swaps.tokenIn | address | The input token address for the swap |
route.swaps.tokenOut | address | The output token address for the swap |
route.swaps.amountIn | dec_string | The amount of input tokens for the swap |
route.swaps.amountOut | dec_string | The amount of output tokens for the swap |
route.amountIn | dec_string | The total input amount for the route |
route.amountOut | dec_string | The total output amount for the route |
approval | object? | Optional approval instruction if the input token is an ERC-20 |
approval.token | address | The address of the token to approve |
approval.amount | dec_string | The amount to approve (in the smallest unit of the token) |
approval.spender | address | The address that will be allowed to spend the tokens (router address) |
transaction | object | The transaction instruction to execute the swap |
transaction.to | address | The address to send the transaction to |
transaction.data | hex | The data payload for the transaction |
transaction.value | dec_string | The value to send with the transaction (for native token swaps) |
fees | array | Fees associated with the quote |
fees.token | address | The token in which the fee is charged |
fees.amount | dec_string | The fee amount |
fees.recipient | address | The recipient of the fee |
id | string | ID for logging and emitting onchain |
Error Responses
| Status Code | Error Code | Description |
|---|---|---|
400 | invalid_request | Chain not supported or invalid parameters provided |
404 | not_found | No route was found |
422 | unprocessable | Invalid parameters provided |
429 | rate_limited | Rate limiter circuit triggered |
500 | internal_error | An internal error occurred while processing the request |
503 | unavailable | The router is currently unavailable |
Example error response body:
{
"statusCode": 404,
"traceId": "019cc05a-115e-78d3-8f62-e3b041eaeefe",
"message": "No route found",
}Example Request and Response
Request
curl --get 'https://route.withfabric.xyz/v1/quote' \
--data-urlencode 'chainId=8453' \
--data-urlencode 'buyToken=0x4200000000000000000000000000000000000006' \
--data-urlencode 'sellToken=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' \
--data-urlencode 'sellAmount=1000000' \
--data-urlencode 'slippageBps=50'