First, choose how you execute
The API always returns the best route. How that route reaches the chain is your choice, and it decides which guide you follow.
The rest of this page follows the first path.
1. Get an API key
- Register and log in.
- Generate an API key. It starts with
sk_. - Send it on every request as
Authorization: Bearer sk_....
2. Quote
assetInandassetOutare contract addresses (C...). The two above are XLM and USDC on mainnet.amountis in stroops, the asset’s smallest unit (7 decimals for XLM and USDC).protocolslists the venues to consider.GET /protocols?network=mainnetreturns the accepted values. SDEX is only priced whensdexis in the list.slippageBpsis optional and defaults to 50 (0.5%).
amountIn, amountOut, the minimum you will accept
(otherAmountThreshold), the routePlan and a platform field that says how the route
executes: aggregator, router or sdex.
3. Build, sign and send
/send.
Build soon after you quote. Prices move, and if your partner fee changed in between,
/quote/build returns 409: quote again and build from the new quote.
Testnet
Use the same base URL with?network=testnet. Testnet quotes come only from Soroswap pools and
carry no fee. Fund an account with Friendbot and mint test tokens at
faucet.soroswap.finance.
Next
- Fees and revenue share: earn on the swaps you route.
- Gasless Trustline: onboard users who hold no XLM.
- Errors and Going to production.
- API Reference: every endpoint and field.
- Beginner guide: the same flow step by step, with a Freighter example.