Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

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.

NameTypeRequiredDescription
chainIdnumberYesThe chain ID to execute the trade on
sellTokenaddressYesThe token being sold (EVM address)
buyTokenaddressYesThe token being bought (EVM address)
sellAmountdec_stringConditionalThe amount of input tokens to sell. Mutually exclusive with buyAmount
buyAmountdec_stringConditionalThe amount of output tokens to buy. Mutually exclusive with sellAmount
slippageBpsnumberNoThe maximum slippage in basis points the user is willing to accept (default 100 bps)
receiveraddressNoThe address to receive the output tokens (EVM address, defaults to the caller)
feeBpsnumberNoThe fee in basis points to be taken from the trade (max 1000 bps)
feeRecipientaddressConditionalThe recipient of the fee (EVM address). Required if feeBps is set
surplusFeeBpsnumberNoSurplus fee in basis points to be taken from the trade (max 10000 bps)
surplusFeeRecipientaddressConditionalSurplus fee recipient (EVM address). Required if surplusFeeBps is set
referralFeeBpsnumberNoReferral fee in basis points (max 1000 bps)
referralFeeRecipientaddressConditionalReferral 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:

FieldTypeDescription
blockNumbernumberThe block number the quote was generated at
amountIndec_stringThe amount the user sends
amountOutdec_stringThe amount the user receives
minimumAmountOutdec_stringThe minimum amount the user receives depending on slippage protection settings
pricenumber?The scaled price ratio between input and output tokens (input/output)
descriptionstringA description of the quote
tokensarrayList of tokens involved in the route
tokens.addressaddressThe address of the token contract
tokens.symbolstringThe symbol of the token
tokens.decimalsnumberThe number of decimals the token uses
tokens.transferFeeBpsnumberThe bps fee on transfer
tokens.priceUsdnumber?The USD price of the token (if available)
routeobjectThe route details used for the quote
route.swapsarrayThe sequence(s) of swaps in the route
route.swaps.keystringA unique key identifying the pool
route.swaps.addressaddressThe address of the liquidity pool
route.swaps.protocolstringThe protocol of the liquidity pool
route.swaps.forkstringThe name of the fork
route.swaps.tokenInaddressThe input token address for the swap
route.swaps.tokenOutaddressThe output token address for the swap
route.swaps.amountIndec_stringThe amount of input tokens for the swap
route.swaps.amountOutdec_stringThe amount of output tokens for the swap
route.amountIndec_stringThe total input amount for the route
route.amountOutdec_stringThe total output amount for the route
approvalobject?Optional approval instruction if the input token is an ERC-20
approval.tokenaddressThe address of the token to approve
approval.amountdec_stringThe amount to approve (in the smallest unit of the token)
approval.spenderaddressThe address that will be allowed to spend the tokens (router address)
transactionobjectThe transaction instruction to execute the swap
transaction.toaddressThe address to send the transaction to
transaction.datahexThe data payload for the transaction
transaction.valuedec_stringThe value to send with the transaction (for native token swaps)
feesarrayFees associated with the quote
fees.tokenaddressThe token in which the fee is charged
fees.amountdec_stringThe fee amount
fees.recipientaddressThe recipient of the fee
idstringID for logging and emitting onchain

Error Responses

Status CodeError CodeDescription
400invalid_requestChain not supported or invalid parameters provided
404not_foundNo route was found
422unprocessableInvalid parameters provided
429rate_limitedRate limiter circuit triggered
500internal_errorAn internal error occurred while processing the request
503unavailableThe 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'