Skip to main content
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_KEY and OLYMPEX_PASSPHRASE set 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 .ts files directly, in an ES module project (npm pkg set type=module); Python needs 3.8 or later with requests, 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, as POLYGON_RPC_URL in this guide.
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.
Send the chain’s current gas price as the hint instead of a constant, as a string of whole gwei rounded up, for example "36". Some sources reject fractional gwei: a hint such as "35.2" makes the openOceanV3 source fail, and the quote silently leaves it out. On a chain whose gas price is below 1 gwei, rounding up gives "1", above the real price. The hint doesn’t set your transaction’s gas price.
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.
To try the request without writing code, use the console on Get a quote. It signs in your browser, so use a test key there and keep production credentials on your servers. If the browser blocks the call, Copy as cURL runs the same request from a terminal.
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.
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.
Keep amounts as 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.
If 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, and data.mode is "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, and error.details names each field to fix. This one sent chainId as a string, a malformed token address, amount as a number and no gasPrice:

Common pitfalls

Base units in amount. amount is human-readable. Sending "10000000" to mean 10 USDT quotes ten million USDT, and a swap built from it asks the wallet for that amount.
The wrong decimals for outAmount. Convert outAmount with the output token’s decimals, not the input token’s. For a USDT (6 decimals) to WETH (18 decimals) swap, the wrong choice is off by a factor of 10¹².
Stale quotes. A quote is not reserved, and prices move between the quote and the swap. Request POST /swap right after the quote, and quote again if the user waits before confirming.
chainId as a string. Every endpoint takes chain IDs as JSON integers (137). A string such as "137" returns 400 VALIDATION_ERROR.

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.