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.
toAmountstring"0" means no route was found.
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[] | nullArray of internal swap legs.
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"
}
}Before submitting
The API always returns 200. toAmount must be non-zero and route.tx must exist. Otherwise the
route was not found or simulation failed.
if (!route.tx || route.toAmount === "0") {
throw new Error("No valid route available");
}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 plain-text response body describes the issue. |
404 | Chain ID not supported. |
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.