from compass_api_sdk import CompassAPI, models
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.uniswap_v3.uniswap_quote_sell_exactly(chain=models.V1UniswapQuoteSellExactlyChain.ARBITRUM, token_in="USDC", token_out="USDC", fee=models.V1UniswapQuoteSellExactlyFeeEnum.ZERO_DOT_01, amount_in=1)
# Handle response
print(res)import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.uniswapV3.uniswapQuoteSellExactly({
chain: "arbitrum",
tokenIn: "USDC",
tokenOut: "USDC",
fee: "0.01",
amountIn: 1,
});
console.log(result);
}
run();curl --request GET \
--url https://api.compasslabs.ai/v1/uniswap/quote/sell_exactly \
--header 'x-api-key: <api-key>'const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.compasslabs.ai/v1/uniswap/quote/sell_exactly', 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.compasslabs.ai/v1/uniswap/quote/sell_exactly",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.compasslabs.ai/v1/uniswap/quote/sell_exactly"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.compasslabs.ai/v1/uniswap/quote/sell_exactly")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v1/uniswap/quote/sell_exactly")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"amount_out": "<string>",
"price_after": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Get quote - From Specified Amount
This endpoint calculates the amount of input tokens required to purchase a specified amount of output tokens from a Uniswap pool.
It also provides the resulting price after the transaction. The calculation takes into account the current pool state and the specified fee tier.
from compass_api_sdk import CompassAPI, models
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.uniswap_v3.uniswap_quote_sell_exactly(chain=models.V1UniswapQuoteSellExactlyChain.ARBITRUM, token_in="USDC", token_out="USDC", fee=models.V1UniswapQuoteSellExactlyFeeEnum.ZERO_DOT_01, amount_in=1)
# Handle response
print(res)import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.uniswapV3.uniswapQuoteSellExactly({
chain: "arbitrum",
tokenIn: "USDC",
tokenOut: "USDC",
fee: "0.01",
amountIn: 1,
});
console.log(result);
}
run();curl --request GET \
--url https://api.compasslabs.ai/v1/uniswap/quote/sell_exactly \
--header 'x-api-key: <api-key>'const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.compasslabs.ai/v1/uniswap/quote/sell_exactly', 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.compasslabs.ai/v1/uniswap/quote/sell_exactly",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.compasslabs.ai/v1/uniswap/quote/sell_exactly"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.compasslabs.ai/v1/uniswap/quote/sell_exactly")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v1/uniswap/quote/sell_exactly")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"amount_out": "<string>",
"price_after": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Query Parameters
arbitrum, base, ethereum The symbol or address of the token to swap from. A token identifier - either a supported symbol (e.g., USDC, WETH) or a valid Ethereum address (0x...)
"USDC"
"WETH"
"0xA0b86a33E6441ccF30EE5DdEF1E9b652C91ac1c8"
The symbol or address of the token to swap to. A token identifier - either a supported symbol (e.g., USDC, WETH) or a valid Ethereum address (0x...)
"USDC"
"WETH"
"0xA0b86a33E6441ccF30EE5DdEF1E9b652C91ac1c8"
The fee to pay for the swap The transaction fee of a Uniswap pool in bips.
Uniswap supports 4 different fee levels.
0.01, 0.05, 0.3, 1.0 The amount of the token to swap from
x > 0Response
Successful Response
Was this page helpful?