Welcome to the GlueX Quickstart Guides! Whether you’re a developer integrating GlueX into your platform or a partner looking to utilize our framework or embed our widget, these guides will help you get up and running quickly and efficiently GlueX provides a comprehensive suite of tools to simplify complex DeFi interactions:
  • Router: Bridge, swap, lend, stake and compose multistep flows in one call
  • Exchange Rates: Fetch real time pricing across chains
  • Yield: Discover and optimize yield values
  • Debt: Borrow, repay and manage debt positions in a single transaction
  • Widget: Prebuilt UI components for a secure and smooth UX
  • Swidge (Coming Soon)
  • Solve (Coming Soon)

Router

The Route API is a powerful and flexible automated pathfinding engine designed for developers to implement efficient onchain interaction logic and calculate optimal path between any two DeFi positions. Whether you’re swapping tokens, entering positions, adding liquidity or moving assets, the API provides everything needed for handling the complex routing logic automatically

Getting Your First Router Quote

The first step in using the GlueX Router API is to generate a quote for a desired DeFi operation. This can be achieved by sending a POST request to the /v1/quote endpoint. It’s recommended to start with the below example request and then explore more customization options in the Router API Reference

Sample Request

The first step in using the GlueX Router API to generate a quote. This can be achieved by sending a POST request to the /v1/quote endpoint. It is recommended to start with the below example request and apply more customization from (here)[/docs/router/quote]
curl 'https://router.gluex.xyz/v1/quote' \
-H 'content-type: application/json' \
-H 'x-api-key: <api-key>' \
--data-raw '{
  "inputToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
  "outputToken": "0xdac17f958d2ee523a2206206994597c13d831ec7",
  "inputAmount": "100000000",
  "userAddress": "0x2...A9D",
  "outputReceiver": "0x2...A9D",
  "chainID": "ethereum",
  "uniquePID": "<unique-pid>",
  "isPermit2": false
}'

Sample Response

{
  "statusCode": 200,
  "result": {
    "inputToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
    "outputToken": "0xdac17f958d2ee523a2206206994597c13d831ec7",
    "feeToken": "0xdac17f958d2ee523a2206206994597c13d831ec7",
    "inputSender": "0x2...a9d",
    "outputReceiver": "0x2...a9d",
    "inputAmount": "100000000",
    "outputAmount": "110023345",
    "partnerFee": "0",
    "routingFee": "0",
    "effectiveInputAmount": "100000000",
    "effectiveOutputAmount": "110023345",
    "minOutputAmount": "107822878",
    "liquidityModules": [
      "uniswap_v2",
      "uniswap_v3",
      "sushiswap",
      "solidly_v3"
    ],
    "router": "0x6Ec7612828B776cC746fe0Ee5381CC93878844f7",
    "calldata": "0xb8039e98...00000000000",
    "isNativeTokenInput": false,
    "value": "0",
    "revert": true,
    "computationUnits": 2000000,
    "blockNumber": 22803966,
    "lowBalance": true
  }
}

How to Use

Once you have the /quote response, you can use any web3 library (eg: ethers.js, web3.js, web3.py) to build, sign and send the transaction. The key fields you’ll need are:
  • calldata: ABI encoded function call for the router
  • value: Native token amount to attach (if input is a native token)
  • computationUnits: Simulated gas estimate (recommended - gasLimit = computationUnits × 1.3)
Simply construct your transaction object with those fields, sign it with your EOA’s private key and broadcast it

Learn More

Examples

Exchange Rate

The Exchange Rates API provides an easy to use, scalable solution for retrieving on-chain exchange rates between any two token pairs across multiple supported blockchains. Whether you’re building a DeFi app, wallet or trading platform, you can fetch realtime, accurate rates in a single batch call

Sample Request

The first step in using the GlueX Exchange Rates API to fetch the price of a token pair. This can be achieved by sending a POST request to the root / endpoint. It is recommended to start with the below example request and apply more customization from (here)[/api-reference/exchange-rate-api/post-price]
Each call can batch upto 25 pairs per request
curl 'https://exchange-rates.gluex.xyz/' \
  -H 'content-type: application/json' \
  --data-raw '[{
    "domestic_blockchain": "ethereum",
    "domestic_token": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
    "foreign_blockchain": "ethereum",
    "foreign_token": "0xdac17f958d2ee523a2206206994597c13d831ec7"
  }]'

Sample Request

[
  {
    "domestic_token": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
    "foreign_token": "0xdac17f958d2ee523a2206206994597c13d831ec7",
    "domestic_blockchain": "ethereum",
    "foreign_blockchain": "ethereum",
    "price": "0.9991396602323227"
  }
]

How to Use

  • Parse the JSON: Iterate over the array to extract price for each token pair
  • Batching: Request up to 25 pairs at once to minimize round trips
  • No Auth Needed: Public access by default, supply an API key header for higher rate limits when available

Learn More

Examples

Widget

The GlueX Widget offers a plug and play UI for embedding full featured DeFi operations like routing, swap, bridge, stake, lend and more into your applicaation with minimal code and maximum customization

Installation

Install the core packages (using your preferred package manager):
npm install wagmi @tanstack/react-query @gluex/widget @gluex/sdk

Sample Integration

Embed the widget in your React (or compatible) app with just a few lines:
import { GlueXWidget, WidgetConfiguration } from "@gluex/widget";

const config: Partial<WidgetConfiguration> = {
  apiKey: environment.GLUEX_API_KEY,
  integrator: environment.INTEGRATOR_ID,
};

export const DeFiWidget = () => {
  return <GlueXWidget config={config} />;
};

Learn More