curl --request POST \
--url https://api.portalhq.io/api/v3/clients/me/integrations/0x/swap/quote \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"chainId": "<string>",
"buyToken": "<string>",
"sellToken": "<string>",
"sellAmount": "<string>",
"zeroXApiKey": "<string>",
"slippageBps": 123,
"excludedSources": "<string>",
"swapFeeRecipient": "<string>",
"swapFeeBps": 123,
"swapFeeToken": "<string>"
}
'import requests
url = "https://api.portalhq.io/api/v3/clients/me/integrations/0x/swap/quote"
payload = {
"chainId": "<string>",
"buyToken": "<string>",
"sellToken": "<string>",
"sellAmount": "<string>",
"zeroXApiKey": "<string>",
"slippageBps": 123,
"excludedSources": "<string>",
"swapFeeRecipient": "<string>",
"swapFeeBps": 123,
"swapFeeToken": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
chainId: '<string>',
buyToken: '<string>',
sellToken: '<string>',
sellAmount: '<string>',
zeroXApiKey: '<string>',
slippageBps: 123,
excludedSources: '<string>',
swapFeeRecipient: '<string>',
swapFeeBps: 123,
swapFeeToken: '<string>'
})
};
fetch('https://api.portalhq.io/api/v3/clients/me/integrations/0x/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.portalhq.io/api/v3/clients/me/integrations/0x/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([
'chainId' => '<string>',
'buyToken' => '<string>',
'sellToken' => '<string>',
'sellAmount' => '<string>',
'zeroXApiKey' => '<string>',
'slippageBps' => 123,
'excludedSources' => '<string>',
'swapFeeRecipient' => '<string>',
'swapFeeBps' => 123,
'swapFeeToken' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.portalhq.io/api/v3/clients/me/integrations/0x/swap/quote"
payload := strings.NewReader("{\n \"chainId\": \"<string>\",\n \"buyToken\": \"<string>\",\n \"sellToken\": \"<string>\",\n \"sellAmount\": \"<string>\",\n \"zeroXApiKey\": \"<string>\",\n \"slippageBps\": 123,\n \"excludedSources\": \"<string>\",\n \"swapFeeRecipient\": \"<string>\",\n \"swapFeeBps\": 123,\n \"swapFeeToken\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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))
}HttpResponse<String> response = Unirest.post("https://api.portalhq.io/api/v3/clients/me/integrations/0x/swap/quote")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"chainId\": \"<string>\",\n \"buyToken\": \"<string>\",\n \"sellToken\": \"<string>\",\n \"sellAmount\": \"<string>\",\n \"zeroXApiKey\": \"<string>\",\n \"slippageBps\": 123,\n \"excludedSources\": \"<string>\",\n \"swapFeeRecipient\": \"<string>\",\n \"swapFeeBps\": 123,\n \"swapFeeToken\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.portalhq.io/api/v3/clients/me/integrations/0x/swap/quote")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"chainId\": \"<string>\",\n \"buyToken\": \"<string>\",\n \"sellToken\": \"<string>\",\n \"sellAmount\": \"<string>\",\n \"zeroXApiKey\": \"<string>\",\n \"slippageBps\": 123,\n \"excludedSources\": \"<string>\",\n \"swapFeeRecipient\": \"<string>\",\n \"swapFeeBps\": 123,\n \"swapFeeToken\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"rawResponse": {
"blockNumber": "<string>",
"buyAmount": "<string>",
"buyToken": "<string>",
"fees": {},
"issues": {},
"liquidityAvailable": true,
"minBuyAmount": "<string>",
"route": {},
"sellAmount": "<string>",
"sellToken": "<string>",
"tokenMetadata": {},
"totalNetworkFee": "<string>",
"transaction": {
"to": "<string>",
"data": "<string>",
"gas": "<string>",
"gasPrice": "<string>",
"value": "<string>",
"from": "<string>"
}
}
}
}{
"error": "<string>"
}{
"error": "<string>"
}Get a swap quote
Retrieves a swap quote with full transaction details for trading tokens on a specific chain. Use this endpoint when you are ready to execute a swap and need the complete transaction to sign and broadcast.
curl --request POST \
--url https://api.portalhq.io/api/v3/clients/me/integrations/0x/swap/quote \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"chainId": "<string>",
"buyToken": "<string>",
"sellToken": "<string>",
"sellAmount": "<string>",
"zeroXApiKey": "<string>",
"slippageBps": 123,
"excludedSources": "<string>",
"swapFeeRecipient": "<string>",
"swapFeeBps": 123,
"swapFeeToken": "<string>"
}
'import requests
url = "https://api.portalhq.io/api/v3/clients/me/integrations/0x/swap/quote"
payload = {
"chainId": "<string>",
"buyToken": "<string>",
"sellToken": "<string>",
"sellAmount": "<string>",
"zeroXApiKey": "<string>",
"slippageBps": 123,
"excludedSources": "<string>",
"swapFeeRecipient": "<string>",
"swapFeeBps": 123,
"swapFeeToken": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
chainId: '<string>',
buyToken: '<string>',
sellToken: '<string>',
sellAmount: '<string>',
zeroXApiKey: '<string>',
slippageBps: 123,
excludedSources: '<string>',
swapFeeRecipient: '<string>',
swapFeeBps: 123,
swapFeeToken: '<string>'
})
};
fetch('https://api.portalhq.io/api/v3/clients/me/integrations/0x/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.portalhq.io/api/v3/clients/me/integrations/0x/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([
'chainId' => '<string>',
'buyToken' => '<string>',
'sellToken' => '<string>',
'sellAmount' => '<string>',
'zeroXApiKey' => '<string>',
'slippageBps' => 123,
'excludedSources' => '<string>',
'swapFeeRecipient' => '<string>',
'swapFeeBps' => 123,
'swapFeeToken' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.portalhq.io/api/v3/clients/me/integrations/0x/swap/quote"
payload := strings.NewReader("{\n \"chainId\": \"<string>\",\n \"buyToken\": \"<string>\",\n \"sellToken\": \"<string>\",\n \"sellAmount\": \"<string>\",\n \"zeroXApiKey\": \"<string>\",\n \"slippageBps\": 123,\n \"excludedSources\": \"<string>\",\n \"swapFeeRecipient\": \"<string>\",\n \"swapFeeBps\": 123,\n \"swapFeeToken\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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))
}HttpResponse<String> response = Unirest.post("https://api.portalhq.io/api/v3/clients/me/integrations/0x/swap/quote")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"chainId\": \"<string>\",\n \"buyToken\": \"<string>\",\n \"sellToken\": \"<string>\",\n \"sellAmount\": \"<string>\",\n \"zeroXApiKey\": \"<string>\",\n \"slippageBps\": 123,\n \"excludedSources\": \"<string>\",\n \"swapFeeRecipient\": \"<string>\",\n \"swapFeeBps\": 123,\n \"swapFeeToken\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.portalhq.io/api/v3/clients/me/integrations/0x/swap/quote")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"chainId\": \"<string>\",\n \"buyToken\": \"<string>\",\n \"sellToken\": \"<string>\",\n \"sellAmount\": \"<string>\",\n \"zeroXApiKey\": \"<string>\",\n \"slippageBps\": 123,\n \"excludedSources\": \"<string>\",\n \"swapFeeRecipient\": \"<string>\",\n \"swapFeeBps\": 123,\n \"swapFeeToken\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"rawResponse": {
"blockNumber": "<string>",
"buyAmount": "<string>",
"buyToken": "<string>",
"fees": {},
"issues": {},
"liquidityAvailable": true,
"minBuyAmount": "<string>",
"route": {},
"sellAmount": "<string>",
"sellToken": "<string>",
"tokenMetadata": {},
"totalNetworkFee": "<string>",
"transaction": {
"to": "<string>",
"data": "<string>",
"gas": "<string>",
"gasPrice": "<string>",
"value": "<string>",
"from": "<string>"
}
}
}
}{
"error": "<string>"
}{
"error": "<string>"
}Authorizations
Client API Key or Client Session Token (CST). Pass as a Bearer token in the Authorization header.
Body
Chain ID in CAIP-2 format (e.g. eip155:1).
Token symbol or address to buy (e.g. USDC).
Token symbol or address to sell (e.g. ETH).
Amount to sell in the smallest unit (e.g. wei).
Optional 0x API key.
Maximum acceptable slippage in basis points (e.g. 100 = 1%).
Comma-separated list of liquidity sources to exclude.
Address to receive swap fees.
Swap fee in basis points.
Token to collect fees in.
Response
Swap quote retrieved successfully
Show child attributes
Show child attributes
Was this page helpful?