Skip to main content

GlueX Router API

GlueX Router API is a powerful and flexible tool designed for developers to implement efficient on-chain interaction logic across multiple supported blockchains. Whether you’re building a DeFi application or optimizing cross-chain workflows, the API provides everything you need for seamless integration.

πŸš€ Key Features​

  • Multi-Chain Support: Operates seamlessly across a wide range of blockchains.
  • Comprehensive DeFi Protocol Coverage: Supports DEXs, lending, yield farming, staking, and more.
  • Fast Response Times: Average round-trip time of ~500ms.
  • Optimized Execution: Default configurations minimize reverts and protect users from MEV.
  • Positive Slippage Rewards: All positive slippage is returned to the user.
  • Dynamic Fee Structure: Transparent, volume-based routing fees.

Additional Features​

πŸ›‘ Surge Protection​

Surge Protection is a built-in safety mechanism designed to protect users from volatile price swings and shallow liquidity that could result in significant value loss.

Imagine you're swapping 100 USDC for another token. Surge Protection checks what would happen if you tried to reverse that trade in the same block, without any other transactions in between. If the system estimates that you'd only get back, say, 84 USDC, it considers that a potential red flag.

Rather than letting the trade go through and leaving you with a surprise loss, Surge Protection intervenes. It halts the transaction and alerts you that the trade would lead to a direct loss in the input token’s value.

This isn't just another featureβ€”it's a new class of trade safety. By simulating the reverse of your trade before execution, it evaluates:

  • Liquidity depth
  • Price impact
  • Volatility risk

If the projected loss exceeds 10%, the trade is blocked.

Why it matters:

  • No more entering a trade and immediately regretting it.
  • No more being the exit liquidity in a volatile or low-depth pool.
  • Surge Protection gives users peace of mind with pre-trade risk visibility.

Note: Surge Protection is enabled by default. If you understand the risks and still want to proceed with the trade, you can explicitly disable it by setting "surgeProtection": false in your API request payload.

πŸ›‹ Partial Fill Order​

In volatile or low-liquidity market conditions, executing a full trade might not be optimalβ€”or even possibleβ€”without incurring high slippage. That’s where Partial Fill Orders come in.

When you enable partial fills by setting "isPartialFill": true, the GlueX Router will dynamically determine the optimal amount of your input token to use for the swap. It calculates the most efficient route and returns both:

  • The partial input amount that should be filled.
  • The expected output amount based on that partial fill.

This gives you the best possible execution, even when the full amount can't be traded effectively in one go.

Use case example: Say you want to swap 1000 USDC, but due to shallow liquidity or aggressive slippage, only 730 USDC can be swapped optimally. With partial fills enabled, the router will suggest using just 730 USDC and return the expected output for that amountβ€”ensuring you get a better trade rather than forcing through a poor one.

Why use Partial Fills?

  • Prevents large orders from being hit with high price impact.
  • Dynamically adapts to current market conditions.
  • Enables smarter routing with minimal manual tuning.

Note: Partial fill logic is opt-in. To enable it, set "isPartialFill": true in your payload. If left unset or set to false, the router will attempt to fill the entire input amount.

πŸ” Buy Order​

In a Sell Order, the user specifies the input amount, and the router calculates the best possible output amount.

Buy Orders work in reverse: the user specifies the output amount they want to receive, and the router calculates the required input amount to fulfill the trade.

To use a Buy Order, set the "orderType" field in the payload to "BUY" and include the desired "outputAmount".

If orderType is not provided, the router defaults to a Sell Order, and "inputAmount" must be included.

orderTypeRequired FieldDescription
BUYoutputAmountAmount of the output token to receive
SELLinputAmountAmount of the input token to sell

Fee Schedule​

Unlike other routers that retain positive slippage as hidden fees or charge additional fee on transactions, GlueX Router returns all positive slippage directly to users and there are no hidden charges. During volatile markets, this can result in significant savings.


πŸ“Š API Tiers​

GlueX offers flexible rate limits to meet different project needs:

TierRequests per Second (RPS)Burst CapacityDescription
Basic33For small apps, testing, or prototypes
Growth1030Suitable for mid-size DApps or production use
Premium2050Supports high-frequency trading or aggregators
EnterpriseCustomCustomTailored SLAs, support, and throughput limits

πŸ“± API Endpoints​

Comprehensive endpoint documentation is available to help you get started quickly. Each endpoint includes detailed descriptions, request/response formats, and examples.

POST /price​

Returns a price estimate for a swap. Does not include calldata or simulation metadata.

  • Surge Protection: true by default
  • Partial Fills supported
  • Returns all Common Response Fields

POST /quote​

Returns a price quote + calldata for executing the trade on-chain. Includes simulation data.

  • Simulation enabled by default (computeEstimate: true)
  • Includes all Common Response Fields

πŸ” Query Parameters​

NameTypeRequiredDescription
chainIDstringConditionalHuman-readable chain name (ethereum)
networkIDstring/integerConditionalNumeric chain ID (1 = Ethereum)
inputTokenstringβœ…ERC-20 address of token to sell
outputTokenstringβœ…ERC-20 address of token to buy
inputAmountstring/integerConditionalAmount of inputToken (with SELL)
outputAmountstring/integerConditionalAmount of outputToken (with BUY)
orderTypestringConditional"SELL" or "BUY"
userAddressstringβœ…Address initiating the swap
outputReceiverstringβœ…Address receiving the output
uniquePIDstringβœ…Partner ID for tracking
computeEstimatebooleanOptionalEnable simulation (default: true for /quote)
computeStablebooleanOptionalInclude USD values in response
surgeProtectionbooleanOptionalEnable trade safety (default: true)
isPartialFillbooleanOptionalAllow partial swaps (default: false)
isPermit2booleanOptionalEnable Permit2 for allowances
slippagestring/integerOptionalMax slippage (in basis points)
partnerFeestring/integerOptionalFee in bps applied to outputAmount

πŸ“€ Common Response Fields​

These fields appear in both /price and /quote responses:

FieldTypeDescription
inputTokenstringERC-20 address of input
outputTokenstringERC-20 address of output
feeTokenstringToken used for fees
inputSenderstringSwap initiator
outputReceiverstringRecipient of output
inputAmountstringAmount of input tokens
outputAmountstringOutput token amount
partnerFeestringPartner fee amount
routingFeestringGlueX routing fee
effectiveInputAmountstringActual used input (partial fills)
effectiveOutputAmountstringNet output after fees
minOutputAmountstringSlippage-protected output
liquidityModulesarrayModules used in the swap route
isNativeTokenInputbooleanInput is native token (e.g., ETH)
valuestringNative value to send with transaction

πŸ”§ Endpoint-Specific Fields​

/price Only​

FieldTypeDescription
surgeValueintegerEstimated reverse loss (in %)

/quote Only​

FieldTypeDescription
calldatastringABI-encoded transaction data
revertbooleanWould the transaction revert?
computationUnitsintegerEstimated gas cost
lowBalancebooleanTrue if balance is insufficient
blockNumberintegerBlock number used for simulation
simulationobjectRaw trace/debug object (advanced use)

Tutorials​

We offer several guides to teach you about the most important principles of the API. They will teach you step by step how to integrate our endpoints into your dApp:

  1. Getting Started
  2. Deposit to a Lending Vault
  3. Mint Liquidity Position in a DEX
  4. Swapping Native Tokens
  5. Using Permit2