Get Swap Route
Returns the optimal split-route across all available liquidity sources, with ready-to-use calldata for direct on-chain execution.
The core endpoint. Returns the optimal split-route across all available liquidity sources for the given chain. Routes are simulation-verified and the response includes ready-to-use calldata for direct on-chain execution via the Nordstern Guard Contract.
Parameters
chain_idreqintegerEVM-compatible chain ID (path parameter).
srcreqstringContract address of the input token. Use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for the
chain's native token (ETH, MATIC, BNB, etc.).
dstreqstringContract address of the output token. Use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE to
receive the chain's native token.
amountreqstringAmount of the input token in its base units (e.g. 1000000000000000000 for 1 ETH, 1000000
for 1 USDC). Use string format to safely handle uint256 values.
fromreqstringWallet address that will receive the output tokens.
slippagenumberSlippage tolerance in percent. Default: 0.5.
convenienceFeenumberConvenience fee in percent to be added. Default: 0.
convenienceFeeRecipientstringAddress to receive the convenience fee.
Request
curl 'https://api.nordstern.finance/aggregator/8453?src=0x4200000000000000000000000000000000000006&dst=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913&amount=1000000000000000000&from=0xYourWalletAddress&slippage=0.5' \
-H "Referer: https://yourdomain.com"const params = new URLSearchParams({
src: "0x4200000000000000000000000000000000000006",
dst: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
amount: "1000000000000000000",
from: "0xYourWalletAddress",
slippage: "0.5",
});
const response = await fetch(
`https://api.nordstern.finance/aggregator/8453?${params}`,
{ headers: { "Referer": "https://yourdomain.com" } }
);
const route = await response.json();
console.log(route);import requests
url = "https://api.nordstern.finance/aggregator/8453"
params = {
"src": "0x4200000000000000000000000000000000000006",
"dst": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"amount": "1000000000000000000",
"from": "0xYourWalletAddress",
"slippage": 0.5,
}
headers = {"Referer": "https://yourdomain.com"}
response = requests.get(url, params=params, headers=headers)
print(response.json())Response
srcstringSource token address (echoes request param).
dststringDestination token address (echoes request param).
fromAmountstringInput amount in the token's base units. Matches the request amount.
toAmountstringExpected output amount in the destination token's base units. Always non-zero — when no route
is found the API responds with 422 instead (see Errors).
gasEstimatestringEstimated gas units the transaction will consume. Add a 20% buffer when using this as a gas limit. Do not pass it directly.
simulationBlockintegerBlock number at which the route was simulated. Revalidate if more than 1–2 blocks have elapsed before submission.
swapsobject[]Array of internal swap legs. Always contains at least one entry.
txobjectReady-to-submit EVM transaction. Pass this directly to your wallet or provider.
The tx object
tx.fromstringSender wallet address (echoes request from param).
tx.tostringGuard Contract address for this chain.
tx.datastringEncoded transaction calldata. Submit as-is. Do not modify.
tx.valuestring"0" for ERC-20 inputs. Non-zero when src is
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE. Pass it directly when submitting the transaction.
{
"src": "0x4200000000000000000000000000000000000006",
"dst": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"fromAmount": "1000000000000000000",
"toAmount": "2120362157",
"gasEstimate": "1045694",
"simulationBlock": 46334743,
"swaps": ...,
"tx": {
"from": "0xYourWalletAddress",
"to": "0xC87De04e2EC1F4282dFF2933A2D58199f688fC3d",
"data": "0x3f0bde25...",
"value": "0"
}
}Error handling
A 200 response always contains a usable route: non-zero toAmount and a tx object. Every
failure — no route found, simulation revert, invalid parameters — returns an HTTP error status
with a JSON {"error": "..."} body instead, so check the status code before reading the route:
if (!response.ok) {
const { error } = await response.json();
throw new Error(`Route request failed (${response.status}): ${error}`);
}
const route = await response.json();Before submitting the transaction, approve the Guard Contract (tx.to) to spend your input
token. Call approve(routerAddress, amount) on the ERC-20 contract. If the allowance is
already sufficient, skip this step.
Errors
| Code | Meaning |
|---|---|
400 | Missing or invalid parameter. The JSON response body describes the issue. |
403 | Disallowed parameter combination (e.g. convenience fee above 10%, invalid fee-exempt key). |
404 | Chain ID not supported. |
422 | No swap route found (unknown token, insufficient liquidity), or the route reverted in simulation. Not retryable with the same inputs. |
500 | Unexpected server error. |
502 | The RPC node backing the simulation failed. Safe to retry. |
503 | Liquidity state behind the requested minimumBlock, or server overloaded. Retry after a short delay. |
504 | Request timed out before routing finished. Safe to retry. |
See Errors for the full error format.
Overview
The Nordstern API is a REST interface that returns JSON. All requests are made over HTTPS using GET or POST.
Simulate Swap
Simulates an arbitrary swap transaction via eth_call and returns the received output amount, gas usage and raw return data — without holding funds or sending anything on-chain.