curl -X POST "https://starknet.api.avnu.fi/swap/v3/build" \
-H "Content-Type: application/json" \
-d '{
"quoteId": "0a5e3c8e-b5d2-4f1a-9c3d-7e6f5a4b3c2d",
"takerAddress": "0x0123...abc",
"slippage": 0.01,
"includeApprove": true
}'
// Step 1: Get quote
const params = new URLSearchParams({
sellTokenAddress: '0x049d...',
buyTokenAddress: '0x053c...',
sellAmount: '1000000000000000000',
takerAddress: account.address
});
const quoteResponse = await fetch(
`https://starknet.api.avnu.fi/swap/v3/quotes?${params}`
);
const quotes = await quoteResponse.json();
const quote = quotes[0];
// Step 2: Get execution calls
const executeResponse = await fetch('https://starknet.api.avnu.fi/swap/v3/build', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
quoteId: quote.quoteId,
takerAddress: account.address,
slippage: 0.01,
includeApprove: true
})
});
const { calls } = await executeResponse.json();
// Step 3: Execute transaction
const tx = await account.execute(calls);
await account.waitForTransaction(tx.transaction_hash);
console.log(`Swap complete: ${tx.transaction_hash}`);
import requests
from starknet_py.net.account.account import Account
# Step 1: Get quote
params = {
'sellTokenAddress': '0x049d...',
'buyTokenAddress': '0x053c...',
'sellAmount': '1000000000000000000',
'takerAddress': account.address
}
quote_response = requests.get(
'https://starknet.api.avnu.fi/swap/v3/quotes',
params=params,
)
quotes = quote_response.json()
quote = quotes[0]
# Step 2: Get execution calls
execute_response = requests.post(
'https://starknet.api.avnu.fi/swap/v3/build',
json={
'quoteId': quote['quoteId'],
'takerAddress': account.address,
'slippage': 0.01,
'includeApprove': True
},
)
calls = execute_response.json()['calls']
# Step 3: Execute transaction
tx = await account.execute(calls)
print(f"Swap complete: {tx.transaction_hash}")
{
"chainId": "0x534e5f4d41494e",
"calls": [
{
"contractAddress": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
"entrypoint": "approve",
"calldata": ["0x123...", "1000000000000000000", "0"]
},
{
"contractAddress": "0x123abc...",
"entrypoint": "swap",
"calldata": ["0x049d...", "0x053c...", "1000000000000000000", "3150000000", "0"]
}
]
}
Swap
Build Swap Calls
Get transaction calls to execute a swap
POST
/
swap
/
v3
/
build
curl -X POST "https://starknet.api.avnu.fi/swap/v3/build" \
-H "Content-Type: application/json" \
-d '{
"quoteId": "0a5e3c8e-b5d2-4f1a-9c3d-7e6f5a4b3c2d",
"takerAddress": "0x0123...abc",
"slippage": 0.01,
"includeApprove": true
}'
// Step 1: Get quote
const params = new URLSearchParams({
sellTokenAddress: '0x049d...',
buyTokenAddress: '0x053c...',
sellAmount: '1000000000000000000',
takerAddress: account.address
});
const quoteResponse = await fetch(
`https://starknet.api.avnu.fi/swap/v3/quotes?${params}`
);
const quotes = await quoteResponse.json();
const quote = quotes[0];
// Step 2: Get execution calls
const executeResponse = await fetch('https://starknet.api.avnu.fi/swap/v3/build', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
quoteId: quote.quoteId,
takerAddress: account.address,
slippage: 0.01,
includeApprove: true
})
});
const { calls } = await executeResponse.json();
// Step 3: Execute transaction
const tx = await account.execute(calls);
await account.waitForTransaction(tx.transaction_hash);
console.log(`Swap complete: ${tx.transaction_hash}`);
import requests
from starknet_py.net.account.account import Account
# Step 1: Get quote
params = {
'sellTokenAddress': '0x049d...',
'buyTokenAddress': '0x053c...',
'sellAmount': '1000000000000000000',
'takerAddress': account.address
}
quote_response = requests.get(
'https://starknet.api.avnu.fi/swap/v3/quotes',
params=params,
)
quotes = quote_response.json()
quote = quotes[0]
# Step 2: Get execution calls
execute_response = requests.post(
'https://starknet.api.avnu.fi/swap/v3/build',
json={
'quoteId': quote['quoteId'],
'takerAddress': account.address,
'slippage': 0.01,
'includeApprove': True
},
)
calls = execute_response.json()['calls']
# Step 3: Execute transaction
tx = await account.execute(calls)
print(f"Swap complete: {tx.transaction_hash}")
{
"chainId": "0x534e5f4d41494e",
"calls": [
{
"contractAddress": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
"entrypoint": "approve",
"calldata": ["0x123...", "1000000000000000000", "0"]
},
{
"contractAddress": "0x123abc...",
"entrypoint": "swap",
"calldata": ["0x049d...", "0x053c...", "1000000000000000000", "3150000000", "0"]
}
]
}
Overview
Returns transaction calls needed to execute a swap based on a quote. You execute these calls with your account/wallet to complete the swap on-chain.Request
string
required
Unique quote identifier (UUID) from the
/quotes endpointstring
Address executing the swap (optional if provided during quote request). Mutually exclusive with
privatenumber
required
Maximum acceptable slippage (range: 0-1, e.g., 0.01 for 1%, default: 0.05 for 5%)
boolean
required
If true, response includes approve call if necessary
boolean
default:"false"
If true, builds the swap for private execution: the backend sets the taker to avnu’s executor and the response includes
executorAddress plus the inner calls (approve + swap; includeApprove is forced to true). Sending takerAddress alongside private returns a 400. See Private SwapResponse
string
Network identifier (e.g., “0x534e5f4d41494e”)
array
required
string
avnu’s private executor address. Only returned when
private is truecurl -X POST "https://starknet.api.avnu.fi/swap/v3/build" \
-H "Content-Type: application/json" \
-d '{
"quoteId": "0a5e3c8e-b5d2-4f1a-9c3d-7e6f5a4b3c2d",
"takerAddress": "0x0123...abc",
"slippage": 0.01,
"includeApprove": true
}'
// Step 1: Get quote
const params = new URLSearchParams({
sellTokenAddress: '0x049d...',
buyTokenAddress: '0x053c...',
sellAmount: '1000000000000000000',
takerAddress: account.address
});
const quoteResponse = await fetch(
`https://starknet.api.avnu.fi/swap/v3/quotes?${params}`
);
const quotes = await quoteResponse.json();
const quote = quotes[0];
// Step 2: Get execution calls
const executeResponse = await fetch('https://starknet.api.avnu.fi/swap/v3/build', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
quoteId: quote.quoteId,
takerAddress: account.address,
slippage: 0.01,
includeApprove: true
})
});
const { calls } = await executeResponse.json();
// Step 3: Execute transaction
const tx = await account.execute(calls);
await account.waitForTransaction(tx.transaction_hash);
console.log(`Swap complete: ${tx.transaction_hash}`);
import requests
from starknet_py.net.account.account import Account
# Step 1: Get quote
params = {
'sellTokenAddress': '0x049d...',
'buyTokenAddress': '0x053c...',
'sellAmount': '1000000000000000000',
'takerAddress': account.address
}
quote_response = requests.get(
'https://starknet.api.avnu.fi/swap/v3/quotes',
params=params,
)
quotes = quote_response.json()
quote = quotes[0]
# Step 2: Get execution calls
execute_response = requests.post(
'https://starknet.api.avnu.fi/swap/v3/build',
json={
'quoteId': quote['quoteId'],
'takerAddress': account.address,
'slippage': 0.01,
'includeApprove': True
},
)
calls = execute_response.json()['calls']
# Step 3: Execute transaction
tx = await account.execute(calls)
print(f"Swap complete: {tx.transaction_hash}")
{
"chainId": "0x534e5f4d41494e",
"calls": [
{
"contractAddress": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
"entrypoint": "approve",
"calldata": ["0x123...", "1000000000000000000", "0"]
},
{
"contractAddress": "0x123abc...",
"entrypoint": "swap",
"calldata": ["0x049d...", "0x053c...", "1000000000000000000", "3150000000", "0"]
}
]
}
Was this page helpful?
⌘I