Skip to main content
This quickstart takes you from no credentials to a signed quote for 10 USDT to USDC on Polygon. You create a test API key, save a reference signer, list the chains Olympex has enabled, and request a quote. To try the same requests without a terminal, use the API console, which signs them in your browser.
You need a terminal and one of bash or zsh, Node.js 22.18 or later, or Python 3.8 or later. You don’t need a wallet or tokens: nothing in this quickstart signs or sends a transaction, or creates an order.

Prerequisites

Pick one language and follow its tab in each step.

Steps

1

Create a test API key

Create a key with the console below. It creates a real API account on the live Olympex API and shows three values: the API key ID, the secret key (a random string) and a generated passphrase. Copy all three now: Olympex can’t show the secret key or the passphrase again.The console also loads the new key into every API console on this site until you reload the page. If your browser blocks the call, create the key from a terminal instead.Export the three values in the terminal you use for the next steps. The signers read them from the environment.
Downloaded the olympex.env file from the console instead? Load it with set -a; . ./olympex.env; set +a, which exports every variable in the file without typing a secret into your shell history.
2

Save the reference signer

Save the signer for your language next to your code. Each one takes the method, the path and, for POST and PATCH, the body. It signs the request with your secret key and sends it with the four signed headers. The TypeScript and Python signers canonicalize the JSON body; the shell function expects a body that is already canonical (keys sorted at every level, no whitespace). Sign requests explains each step of the algorithm.
sign-request.sh
Load the function into the same terminal:
3

List the enabled chains

Start with a request that has no body. GET /chains returns the IDs of the chains Olympex has enabled. A GET sends no body, so the signer signs the empty string.
The shell function prints the full response envelope. chainIds lists every chain Olympex has enabled, in ascending numeric order:
The chain IDs are integers, the same type every endpoint takes. meta.apiKeyId is the API key ID that signed the request. The TypeScript and Python helpers return data directly, and raise OlympexApiError with the HTTP status, error.code and meta.requestId when the call fails. A gateway response, such as a 401 or 403 from a signing problem, has no meta.requestId, so the helpers raise it without a request ID. Its ID is in the apigw-requestid response header: log that header from your HTTP client, or add -i to a cURL command to see it.Two related calls work the same way. GET /tokens?chainId=137 returns the tokens Olympex lists on Polygon, with each token’s address, symbol and decimals: in the shell, quote the path (olympex_request GET '/tokens?chainId=137') because zsh treats ? as a wildcard. POST /support-chain checks a single chain ID, sent as an integer, against the same list.
4

Get a quote

Request the best route for 10 USDT to USDC on Polygon with 1% slippage.
What each field means:
  • mode: single-chain for a swap on one chain. A transfer between two chains uses cross-chain and different params.
  • chainId: the chain as an integer (137), as on every endpoint.
  • inTokenAddress, outTokenAddress: the token you sell and the token you buy. Use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for the chain’s native token.
  • amount: how much you sell, as a human-readable decimal string. "10" is 10 USDT; don’t convert it to base units.
  • slippage: the maximum slippage as a percent string. "1" is 1%.
  • gasPrice: a gas price hint in gwei, required for single-chain quotes. Send whole gwei as a string, rounded up: some sources reject fractional gwei. On a chain whose gas price is below 1 gwei, that rounds up to "1", above the real price. The hint doesn’t set your transaction’s gas price.
5

Read the response

A successful quote looks like this. Yours has different numbers, and often different routes, because prices move.
To display outAmount, divide it by 10 to the power of the output token’s decimals: the decimals that GET /tokens returns for the token, or the token contract’s decimals(). Libraries such as viem and ethers do this with formatUnits.
A quote is not reserved. Prices move between the quote and the swap, so when you build a swap, request it right after the quote and protect it with slippage.

Verify

You’re set up when both calls return "success": true:
  • The chain list includes 137.
  • The quote returns an outAmount, an aggregatorId and a meta.requestId.
If a call fails, match the response: Errors and retries lists every error code.

Common pitfalls

outAmount is in base units. "9979975" is 9.979975 USDC, not almost ten million. Shown without conversion, it overstates the output by a factor of 10 to the power of the token’s decimals. The input amount is the opposite: a human-readable decimal.
Treat the passphrase like the secret key. It is sent on every request, so anything that logs request headers captures it. Keep all three values out of source control, client-side code, tickets and chat. export lines can end up in your shell history.
There is no sandbox. Your test key is a real account on the live API. Chain and token lists, quotes and chain checks are read-only, but the calldata that POST /swap returns is real mainnet calldata: broadcasting it moves funds. A limit order or DCA strategy you create with a test key is a real order too, and Olympex can execute it against the maker wallet’s allowance.

What’s next

Execute a swap

Turn a quote into calldata, approve the spender and broadcast from your wallet.

Place a limit order

Sign the token pair, approve the order contract, create an order and follow it to completion.

Sign requests

The signing algorithm, requests without a body, the known-answer vectors and troubleshooting.

API reference overview

Every endpoint, with examples and an in-browser console.