POST /quotes tells you how much of the output token a swap returns, which liquidity source offers the best route and, if you ask, what the transaction costs in gas. This guide quotes 10 USDT to USDC on Polygon. A quote is read-only: it moves no funds and reserves nothing.
You need an API key ID, secret key and passphrase. Create a test API key gives you working credentials in one click. If your browser blocks the call, create one from a terminal.
Prerequisites
OLYMPEX_API_KEY_ID,OLYMPEX_SECRET_KEYandOLYMPEX_PASSPHRASEset in your server’s environment. Quotes are signed requests, so signing happens on your server, never in a browser or mobile app.- The signing helper for your language, saved next to your code. TypeScript needs Node.js 22.18 or later, which runs
.tsfiles directly, in an ES module project (npm pkg set type=module); Python needs 3.8 or later withrequests, installed in a virtual environment as the quickstart shows. Sign requests explains every header and publishes two known-answer vectors. - For the unit conversion and the gas price in TypeScript: viem 2 (
npm install viem) and an RPC URL for the chain, asPOLYGON_RPC_URLin this guide.
Signing helpers: sign-request.ts, sign_request.py and sign-request.sh
Signing helpers: sign-request.ts, sign_request.py and sign-request.sh
- TypeScript
- Python
- Bash
sign-request.ts
Steps
1
Choose the chain and tokens
Set
chainId to the EVM chain ID as an integer, for example 137 for Polygon. Olympex supports Ethereum (1), Optimism (10), BNB Chain (56), Polygon (137), Base (8453), Arbitrum (42161), Avalanche (43114) and Linea (59144). GET /chains returns the enabled chain IDs, without names: keep the names in your code, and offer a chain only while its ID is in the response. See Supported chains.Token addresses can be lowercase or EIP-55 checksummed. For the chain’s native token (POL on Polygon, ETH on Ethereum), use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE. GET /tokens lists it in lowercase, 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee, and quotes accept either casing, so compare addresses case-insensitively.Olympex resolves token decimals itself, but you need the output token’s decimals to display the result. Take decimals from GET /tokens, which returns the tokens Olympex lists on a chain, or read decimals() from the token contract. The list doesn’t limit what you can quote: any valid token address works, listed or not, and the quote tells you whether it has a route. This guide uses:2
Build the request body
Optional fields tune the result:
Send
amount, slippage and gasPrice as decimal strings. A JSON number in any of them returns 400 VALIDATION_ERROR, as the example under Verify shows.3
Send the request
Each call signs the body with a new timestamp and nonce. Olympex compares several liquidity sources for every quote, so a response can take several seconds; the helpers wait up to 35 seconds, a little longer than the gateway timeout of about 30 seconds. The TypeScript snippets in the next steps continue
get-swap-quote.ts.4
Read the response
The quote is in
data.quote of the standard envelope:meta.requestId identifies the request. Log it: support needs it to find the request.If no source can quote the pair and amount, the call fails with 422 NO_ROUTE. It can be temporary: retry with backoff, then try another amount or pair. See When no route is found.The response below was requested with includeGasInfo: true, so it carries dataFeeTransaction.Response
Response
5
Convert the output to display units
outAmount is in base units of the output token. Divide it by 10 to the power of that token’s decimals: "9979975" of 6-decimal USDC is 9.979975 USDC.bigint or Decimal until you format them for display. Floating-point arithmetic loses precision on 18-decimal tokens.6
Keep fallback sources for the swap
aggregatorOrder lists every source that quoted the pair, best first, and can be null. Build the list you’ll try with POST /swap: the winner first, then the rest.POST /swap returns 422 NO_ROUTE or 500 SWAP_ERROR for one source, try the next. Do the same when POST /swap succeeds but eth_estimateGas of its calldata reverts: a 200 doesn’t guarantee that the calldata executes. A fallback source can return less than the winner, so show the user the outAmount and minOutAmount from the POST /swap response, not the quote’s. Execute a swap uses this list, and Aggregation and routing explains the ranking.7
Add the gas fee estimate (optional)
Set
includeGasInfo: true to receive dataFeeTransaction in the quote. This request also sends the chain’s current gas price as the hint:gasMultiplier scales estimatedGas when includeGasInfo is true. dataFeeTransaction derives from the source’s estimatedGas, which leaves out the Olympex contracts, so treat it as a lower bound. The fee your user pays depends on the gas used and the gas price when the transaction is mined, so present this value as an estimate, and add a buffer when you size an allowance from valueToApprove or transactionFeeInToken. Gas and fees covers every gas field.Verify
- The response has
"success": true, anddata.modeis"single-chain". outAmount, converted with the output token’s decimals, is close to the input amount for a stablecoin pair: 10 USDT quoted 9.979975 USDC in the example above.- A rejected body returns
400 VALIDATION_ERROR, anderror.detailsnames each field to fix. This one sentchainIdas a string, a malformed token address,amountas a number and nogasPrice:
Common pitfalls
What’s next
Execute a swap
Turn the quote into calldata and send it from a wallet.
Get a quote
Every field of
POST /quotes, with a console to try it.Aggregation and routing
How Olympex compares liquidity sources.
Gas and fees
Gas estimates, protocol fees and integrator fees.
