Get swap quote
curl --request POST \
--url https://api.privy.io/v1/wallets/{wallet_id}/swap/quote \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--header 'privy-app-id: <privy-app-id>' \
--data '
{
"base_amount": "1000000000000000000",
"amount_type": "exact_input",
"source": {
"asset_address": "native",
"caip2": "eip155:1"
},
"destination": {
"asset_address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"caip2": "eip155:1"
}
}
'HttpResponse<String> response = Unirest.post("https://api.privy.io/v1/wallets/{wallet_id}/swap/quote")
.header("privy-app-id", "<privy-app-id>")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"base_amount\": \"1000000000000000000\",\n \"amount_type\": \"exact_input\",\n \"source\": {\n \"asset_address\": \"native\",\n \"caip2\": \"eip155:1\"\n },\n \"destination\": {\n \"asset_address\": \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"caip2\": \"eip155:1\"\n }\n}")
.asString();const options = {
method: 'POST',
headers: {
'privy-app-id': '<privy-app-id>',
Authorization: 'Basic <encoded-value>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
base_amount: '1000000000000000000',
amount_type: 'exact_input',
source: {asset_address: 'native', caip2: 'eip155:1'},
destination: {asset_address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', caip2: 'eip155:1'}
})
};
fetch('https://api.privy.io/v1/wallets/{wallet_id}/swap/quote', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.privy.io/v1/wallets/{wallet_id}/swap/quote",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'base_amount' => '1000000000000000000',
'amount_type' => 'exact_input',
'source' => [
'asset_address' => 'native',
'caip2' => 'eip155:1'
],
'destination' => [
'asset_address' => '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
'caip2' => 'eip155:1'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json",
"privy-app-id: <privy-app-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.privy.io/v1/wallets/{wallet_id}/swap/quote"
payload := strings.NewReader("{\n \"base_amount\": \"1000000000000000000\",\n \"amount_type\": \"exact_input\",\n \"source\": {\n \"asset_address\": \"native\",\n \"caip2\": \"eip155:1\"\n },\n \"destination\": {\n \"asset_address\": \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"caip2\": \"eip155:1\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("privy-app-id", "<privy-app-id>")
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"caip2": "eip155:1",
"input_token": "native",
"output_token": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"input_amount": "1000000000000000000",
"est_output_amount": "2000000000",
"minimum_output_amount": "1980000000",
"gas_estimate": "150000"
}Swaps
Get swap quote
Get a price quote for swapping tokens within a wallet.
POST
/
v1
/
wallets
/
{wallet_id}
/
swap
/
quote
Get swap quote
curl --request POST \
--url https://api.privy.io/v1/wallets/{wallet_id}/swap/quote \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--header 'privy-app-id: <privy-app-id>' \
--data '
{
"base_amount": "1000000000000000000",
"amount_type": "exact_input",
"source": {
"asset_address": "native",
"caip2": "eip155:1"
},
"destination": {
"asset_address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"caip2": "eip155:1"
}
}
'HttpResponse<String> response = Unirest.post("https://api.privy.io/v1/wallets/{wallet_id}/swap/quote")
.header("privy-app-id", "<privy-app-id>")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"base_amount\": \"1000000000000000000\",\n \"amount_type\": \"exact_input\",\n \"source\": {\n \"asset_address\": \"native\",\n \"caip2\": \"eip155:1\"\n },\n \"destination\": {\n \"asset_address\": \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"caip2\": \"eip155:1\"\n }\n}")
.asString();const options = {
method: 'POST',
headers: {
'privy-app-id': '<privy-app-id>',
Authorization: 'Basic <encoded-value>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
base_amount: '1000000000000000000',
amount_type: 'exact_input',
source: {asset_address: 'native', caip2: 'eip155:1'},
destination: {asset_address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', caip2: 'eip155:1'}
})
};
fetch('https://api.privy.io/v1/wallets/{wallet_id}/swap/quote', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.privy.io/v1/wallets/{wallet_id}/swap/quote",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'base_amount' => '1000000000000000000',
'amount_type' => 'exact_input',
'source' => [
'asset_address' => 'native',
'caip2' => 'eip155:1'
],
'destination' => [
'asset_address' => '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
'caip2' => 'eip155:1'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json",
"privy-app-id: <privy-app-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.privy.io/v1/wallets/{wallet_id}/swap/quote"
payload := strings.NewReader("{\n \"base_amount\": \"1000000000000000000\",\n \"amount_type\": \"exact_input\",\n \"source\": {\n \"asset_address\": \"native\",\n \"caip2\": \"eip155:1\"\n },\n \"destination\": {\n \"asset_address\": \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n \"caip2\": \"eip155:1\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("privy-app-id", "<privy-app-id>")
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"caip2": "eip155:1",
"input_token": "native",
"output_token": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"input_amount": "1000000000000000000",
"est_output_amount": "2000000000",
"minimum_output_amount": "1980000000",
"gas_estimate": "150000"
}Swap quotes reflect real-time market conditions and can change quickly. Fetch a fresh quote before
executing a swap to ensure your app displays accurate pricing.
Authorizations
Headers
Body
application/json
Input for requesting a token swap quote.
Response
200 - application/json
Swap quote retrieved successfully.
Pricing data for a token swap.
Estimated fees for the swap. Only present for cross-chain swaps.
Estimated fee paid to the relayer.
- RelayerFee
- PrivyFee
- DeveloperFee
Show child attributes
Show child attributes
Example:
{
"type": "privy",
"recipient": "0x1234567890abcdef1234567890abcdef12345678",
"amount": "0.20"
}
Was this page helpful?

