from compass_api_sdk import CompassAPI, models
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.earn.earn_positions(chain=models.V2EarnPositionsChain.BASE, owner="0x06A9aF046187895AcFc7258450B15397CAc67400")
# 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.earn.earnPositions({
chain: "base",
owner: "0x06A9aF046187895AcFc7258450B15397CAc67400",
});
console.log(result);
}
run();curl --request GET \
--url https://api.compasslabs.ai/v2/earn/positions \
--header 'x-api-key: <api-key>'const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.compasslabs.ai/v2/earn/positions', 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/v2/earn/positions",
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/v2/earn/positions"
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/v2/earn/positions")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v2/earn/positions")
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{
"aave": [
{
"balance": "1250.5432100000",
"deposits": [],
"pnl": {
"current_value": "1250.5432100000",
"realized_pnl": "0.0000000000",
"total_deposited": "1200.0000000000",
"total_pnl": "50.5432100000",
"total_pnl_percent": "4.2119341667",
"unrealized_pnl": "50.5432100000"
},
"reserve_address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"reserve_symbol": "USDC",
"type": "AAVE",
"withdrawals": []
}
],
"vaults": [
{
"balance": "5000.1234560000",
"deposits": [],
"pnl": {
"current_value": "5000.1234560000",
"realized_pnl": "0.0000000000",
"total_deposited": "4800.0000000000",
"total_pnl": "200.1234560000",
"total_pnl_percent": "4.1692386667",
"unrealized_pnl": "200.1234560000"
},
"type": "VAULT",
"underlying_symbol": "USDC",
"vault_address": "0xBEEF01735c132Ada46AA9aA4c54623cAA92A64CB",
"vault_name": "Steakhouse USDC",
"withdrawals": []
}
],
"pendle_pt": [
{
"deposits": [],
"expiry": 1735689600,
"market_address": "0x7d372819240D14fB477f17b964f95F33BeB4c704",
"pnl": {
"current_value": "2.5000000000",
"realized_pnl": "0.0000000000",
"total_deposited": "2.4500000000",
"total_pnl": "0.0500000000",
"total_pnl_percent": "2.0408163265",
"unrealized_pnl": "0.0500000000"
},
"pt_address": "0x7d372819240D14fB477f17b964f95F33BeB4c704",
"pt_balance": "2.5000000000",
"type": "PENDLE_PT",
"underlying_symbol": "weETH",
"withdrawals": []
}
],
"total_usd_value": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}List earn positions
List all Earn positions for a given owner with PnL tracking.
Returns position data including current balance, cost basis, and profit and loss. Use this endpoint to display portfolio performance, track yields over time, or build position management interfaces.
Positions are tracked across all venue types (vaults and Aave markets). Each position includes the venue address, deposited amount, and performance metrics.
from compass_api_sdk import CompassAPI, models
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.earn.earn_positions(chain=models.V2EarnPositionsChain.BASE, owner="0x06A9aF046187895AcFc7258450B15397CAc67400")
# 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.earn.earnPositions({
chain: "base",
owner: "0x06A9aF046187895AcFc7258450B15397CAc67400",
});
console.log(result);
}
run();curl --request GET \
--url https://api.compasslabs.ai/v2/earn/positions \
--header 'x-api-key: <api-key>'const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.compasslabs.ai/v2/earn/positions', 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/v2/earn/positions",
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/v2/earn/positions"
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/v2/earn/positions")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v2/earn/positions")
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{
"aave": [
{
"balance": "1250.5432100000",
"deposits": [],
"pnl": {
"current_value": "1250.5432100000",
"realized_pnl": "0.0000000000",
"total_deposited": "1200.0000000000",
"total_pnl": "50.5432100000",
"total_pnl_percent": "4.2119341667",
"unrealized_pnl": "50.5432100000"
},
"reserve_address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"reserve_symbol": "USDC",
"type": "AAVE",
"withdrawals": []
}
],
"vaults": [
{
"balance": "5000.1234560000",
"deposits": [],
"pnl": {
"current_value": "5000.1234560000",
"realized_pnl": "0.0000000000",
"total_deposited": "4800.0000000000",
"total_pnl": "200.1234560000",
"total_pnl_percent": "4.1692386667",
"unrealized_pnl": "200.1234560000"
},
"type": "VAULT",
"underlying_symbol": "USDC",
"vault_address": "0xBEEF01735c132Ada46AA9aA4c54623cAA92A64CB",
"vault_name": "Steakhouse USDC",
"withdrawals": []
}
],
"pendle_pt": [
{
"deposits": [],
"expiry": 1735689600,
"market_address": "0x7d372819240D14fB477f17b964f95F33BeB4c704",
"pnl": {
"current_value": "2.5000000000",
"realized_pnl": "0.0000000000",
"total_deposited": "2.4500000000",
"total_pnl": "0.0500000000",
"total_pnl_percent": "2.0408163265",
"unrealized_pnl": "0.0500000000"
},
"pt_address": "0x7d372819240D14fB477f17b964f95F33BeB4c704",
"pt_balance": "2.5000000000",
"type": "PENDLE_PT",
"underlying_symbol": "weETH",
"withdrawals": []
}
],
"total_usd_value": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Query Parameters
arbitrum, base, bsc, ethereum, tempo The address of the owner of the earn account to get positions for.
Response
Successful Response
Grouped positions by protocol.
This new structure groups positions by protocol type for better organization and removes the need for a discriminated union in SDK consumers.
Aave V3 lending positions.
Show child attributes
Show child attributes
[
{
"balance": "1250.5432100000",
"deposits": [],
"pnl": {
"current_value": "1250.5432100000",
"realized_pnl": "0.0000000000",
"total_deposited": "1200.0000000000",
"total_pnl": "50.5432100000",
"total_pnl_percent": "4.2119341667",
"unrealized_pnl": "50.5432100000"
},
"reserve_address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"reserve_symbol": "USDC",
"type": "AAVE",
"withdrawals": []
}
]
ERC-4626 vault positions.
Show child attributes
Show child attributes
[
{
"balance": "5000.1234560000",
"deposits": [],
"pnl": {
"current_value": "5000.1234560000",
"realized_pnl": "0.0000000000",
"total_deposited": "4800.0000000000",
"total_pnl": "200.1234560000",
"total_pnl_percent": "4.1692386667",
"unrealized_pnl": "200.1234560000"
},
"type": "VAULT",
"underlying_symbol": "USDC",
"vault_address": "0xBEEF01735c132Ada46AA9aA4c54623cAA92A64CB",
"vault_name": "Steakhouse USDC",
"withdrawals": []
}
]
Pendle Principal Token positions.
Show child attributes
Show child attributes
[
{
"deposits": [],
"expiry": 1735689600,
"market_address": "0x7d372819240D14fB477f17b964f95F33BeB4c704",
"pnl": {
"current_value": "2.5000000000",
"realized_pnl": "0.0000000000",
"total_deposited": "2.4500000000",
"total_pnl": "0.0500000000",
"total_pnl_percent": "2.0408163265",
"unrealized_pnl": "0.0500000000"
},
"pt_address": "0x7d372819240D14fB477f17b964f95F33BeB4c704",
"pt_balance": "2.5000000000",
"type": "PENDLE_PT",
"underlying_symbol": "weETH",
"withdrawals": []
}
]
Total USD value of all positions (sum of available values).
Was this page helpful?