This document provides a comprehensive guide to the structures used when interacting with the Router API. Understanding these formats is crucial for correctly constructing your requests and parsing the API responses

Request Parameters

The following parameters may be included in the request payload for /v1/price and /v1/quote endpoints
NameTypeRequiredDefault ValueDescription
chainIDstringConditionalIdentifier for the target chain (eg: ethereum)
networkIDstring/integerConditionalNumerical chain ID (eg: 1 for Ethereum)
inputTokenstringERC20 token address to be sold
outputTokenstringERC20 token address to be bought
inputAmountstring/integerConditionalAmount of input token (used for SELL orders)
outputAmountstring/integerConditionalDesired amount of output token (used for BUY orders)
orderTypestringConditionalType of order: BUY or SELL
userAddressstringInitiator’s wallet address
outputReceiverstringAddress to receive the output token
uniquePIDstringPartner ID for analytics and attribution
computeEstimatebooleanOptionaltrueEnable simulation
computeStablebooleanOptionalfalseInclude USD value metadata in response
surgeProtectionbooleanOptionalfalseEnable or disable Surge Protection
isPartialFillbooleanOptionalfalseAllow partial fill swaps
isPermit2booleanOptionalfalseUse Permit2 for allowance approvals
slippagestring/integerOptionalMaximum slippage allowed (in basis points)
partnerFeestring/integerOptional0Fee in bps applied to output
partnerAddressstringConditionalEOA to receive partner fee and surplus
modulesFilterarrayOptional[]Restrict routing to specified liquidity modules
activateSurplusFeebooleanOptionalfalseEnable surplus sharing contract

Common Response Fields

The following fields are returned in both /v1/price and /v1/quote responses.
FieldTypeDescription
inputTokenstringERC20 address of input token
outputTokenstringERC20 address of output token
feeTokenstringToken used to pay any applicable fees
inputSenderstringAddress initiating the trade
outputReceiverstringAddress receiving the output
inputAmountstringOriginal input amount
outputAmountstringExpected output amount
partnerFeestringAmount of fee allocated to partner
routingFeestringGlueX’s routing fee (typically zero)
effectiveInputAmountstringActual used input in the swap (for partial fills)
effectiveOutputAmountstringActual received output after fees and routing
minOutputAmountstringSlippage-protected minimum output
liquidityModulesarrayLiquidity sources/modules used
isNativeTokenInputbooleanIndicates if native token (eg: ETH) was used
valuestringValue (in wei) sent with transaction (if applicable)

Endpoint Specific Response Fields

Fields for /v1/price

FieldTypeDescription
surgeValueintegerProjected reverse loss estimate in percentage

Fields for /v1/quote

FieldTypeDescription
calldatastringABI encoded transaction data
revertbooleanIndicates if trade would revert onchain
computationUnitsintegerEstimated gas cost
lowBalancebooleanTrue if user balance is insufficient
blockNumberintegerBlock number used during simulation
simulationobjectDetailed trace/debug object for advanced usage