samples/http/quickstart.sh, step by step. It lists the assets your workspace can trade, asks every venue for a quote on 10 USDC to USDT, takes the best quote and places the order.
Each step shows the script’s code under cURL. The TypeScript SDK tab shows the same step in TetraFi’s TypeScript SDK, which is not published to npm yet: it is coming soon. Its example differs from the script in two ways: it quotes USDC for ETH, and after ordering it waits until the order ends.
The API may change until launch. Every change is listed in the Changelog.
Before you begin
You needbash, curl, jq and openssl, and an exchange or OTC venue account connected to your workspace that holds the USDC you sell.
Get a key with venue trading
This guide places the order with the API key alone, so it orders a Basic quote: one TetraFi executes for you on your venue account. That needs an API key with:- Read quotes, Submit orders and Read orders;
- venue trading, switched on for the key by a workspace owner or an admin who manages credentials;
- request signing, and the key’s signing secret.
- Open Settings, find Personal API keys under Your account, then select Open API keys and Create key.
- In Create API key, enter a Name. Under Permissions, tick Read quotes, Submit orders and Read orders.
- Switch Venue trading on and select Create key.
- Copy API Key and Request-signing secret to your secret manager, keeping them separate. They are shown once and cannot be recovered. Tick I have saved both credentials securely and select Done.
unavailable with apiKeyOrganisationWalletScopeRequired or onchainWalletNotUsable until an owner or admin grants a wallet. Give a key organisation wallets explains that separate step.
The key is bound to its workspace, so the script sends no workspace id: every request works in the key’s own workspace. If you need the id later, GET /api/v1/me returns it in workspaceId, and in the app a workspace owner or admin finds it as Workspace ID in the workspace’s settings, on the General tab.
On-chain (Advanced) execution is not open yet: Advanced venues are listed in
sources as unavailable with the reason advancedModeDisabled, and are not asked. This guide and every sample on this site use Basic quotes.1
Set your environment
Export your base URL, key and the key’s signing secret.The script starts with one helper,
tetrafi, that sends a request with your key, signs it when TETRAFI_SIGNING_SECRET is set, and stops the script with the error body on any error status.2
List the assets you can trade
GET /api/v1/assets returns every asset your workspace can trade, with its variants and the chains it is deployed on. The script checks that both sides of the pair are listed.Response (shortened)
3
Request quotes and pick the best
POST /api/v1/quotes asks every venue at once. The body names the asset you sell (sell), the asset you buy (buy) and sellAmount, the exact amount you sell. To fix the amount you buy instead, send buyAmount. Leave out chain on a side to let venues quote it on any chain or off-chain.Quotes come back best first, by what you buy net of fees. The script takes the first one whose next is order: a quote you can order now. If none is, it prints every venue’s outcome from sources and stops.Response (shortened)
In the app, this is the quote list on the trade page.
4
Place the order
POST /api/v1/orders with the quote id places the order on the held terms. Send an Idempotency-Key header with a value you generate and keep: a retry with the same key and body returns the first answer instead of placing a second order. Each quote can be ordered once.When the quote’s minReceiveRequired is true, send minReceive, the least you accept: the script uses the quoted buy.amount less TETRAFI_SLIPPAGE_BPS (default 50, or 0.5%), rounded down to the bought asset’s decimals from GET /api/v1/assets.The script places the order only when you set TETRAFI_PLACE_ORDER=1. Without it, it stops after the quote and prints the quote id it would order.Response (shortened)
"kind": "basicTrade" with the venue trade in operation. status and terminal say where it is, and statusUrl is where to read it again.5
Read the status
Read the order at the The script reads the status once. In your own code, poll every 10 to 15 seconds until In the app, the same trade appears under Trades.
statusUrl the answer gave. The read answers the same envelope as the order answer, for every kind of order.terminal is true. outcomeUnknown is not a failure: the trade was sent and may have filled, so keep reading it and never place a new order for it (Order status).The script’s last line is a one-line summary:Output
Run the whole script
| jq works on the result. Without TETRAFI_PLACE_ORDER=1, the summary reads "ordered": false.
If nothing quotes
When no quote’snext is order, the script stops with NO_ACTIONABLE_QUOTE and lists each venue’s status and reason from sources. The outcomes a new key most often sees:
Errors and refusals lists more outcomes.
Next steps
Authentication
Permissions, request signing, rotation and rate limits.
Orders
Order fields, minimum receive, retries and following an order to the end.