Skip to main content
GET
/
v1
/
portfolio
/
defi
Retrieve comprehensive DeFi portfolio data, including staking, liquidity pool (LP), and yield farming activities
curl --request GET \
  --url https://api.coinstats.app/v1/portfolio/defi \
  --header 'X-API-KEY: <api-key>'
import requests

url = "https://api.coinstats.app/v1/portfolio/defi"

headers = {"X-API-KEY": "<api-key>"}

response = requests.get(url, headers=headers)

print(response.text)
const options = {method: 'GET', headers: {'X-API-KEY': '<api-key>'}};

fetch('https://api.coinstats.app/v1/portfolio/defi', 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.coinstats.app/v1/portfolio/defi",
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.coinstats.app/v1/portfolio/defi"

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.coinstats.app/v1/portfolio/defi")
.header("X-API-KEY", "<api-key>")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.coinstats.app/v1/portfolio/defi")

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
{
  "totalAssets": {
    "USD": 46.92,
    "ETH": 0.010799824088855844,
    "BTC": 0.0004264134046889636
  },
  "protocols": [
    {
      "id": "pancakeswap-amm-v3",
      "name": "PancakeSwap",
      "logo": "https://icons.llama.fi/pancakeswap-amm-v3.jpg",
      "totalValue": {
        "USD": 46.92,
        "ETH": 0.010799824088855844,
        "BTC": 0.0004264134046889636
      },
      "blockchain": {
        "name": "Solana",
        "icon": "https://static.coinstats.app/portfolio_images/solana_dark.png"
      },
      "chain": "solana",
      "investments": [
        {
          "id": "liquidity",
          "name": "Liquidity",
          "value": {
            "USD": 46.92,
            "ETH": 0.010799824088855844,
            "BTC": 0.0004264134046889636
          },
          "symbols": "USDC + WSOL",
          "assets": [
            {
              "address": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
              "title": "Deposit",
              "amount": 20.431941,
              "symbol": "USDC",
              "price": {
                "USD": 46.92,
                "ETH": 0.010799824088855844,
                "BTC": 0.0004264134046889636
              },
              "coinId": "solana",
              "logo": "https://img-v1.raydium.io/icon/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v.png",
              "danger": true
            }
          ],
          "poolAddress": "pancakeswap-amm-v3",
          "healthRate": 123,
          "healthRateLink": "<string>",
          "poolProjectId": "PancakeSwap",
          "unlockAt": "2025-08-28T08:35:50.384Z",
          "endAt": "2025-08-28T08:35:50.384Z",
          "isProxy": true,
          "debtRatio": 0.01,
          "debtRatioLink": "https://pancakeswap.finance/swap"
        }
      ],
      "walletAddress": "wallet_address_here",
      "url": "https://pancakeswap.finance/swap"
    }
  ]
}
{
"statusCode": 400,
"message": "Bad Request",
"requestId": "11111111-2222-3333-4444-555555555555",
"path": "<requested-endpoint>"
}
{
"statusCode": 401,
"message": "Unauthorized",
"requestId": "11111111-2222-3333-4444-555555555555",
"path": "<requested-endpoint>"
}
{
"statusCode": 403,
"message": "Forbidden",
"requestId": "11111111-2222-3333-4444-555555555555",
"path": "<requested-endpoint>"
}
{
"statusCode": 404,
"message": "Not Found",
"requestId": "11111111-2222-3333-4444-555555555555",
"path": "<requested-endpoint>"
}
{
"statusCode": 409,
"message": "Transactions not synced",
"requestId": "11111111-2222-3333-4444-555555555555",
"path": "<requested-endpoint>"
}
{
"statusCode": 429,
"message": "Rate limit exceeded",
"requestId": "11111111-2222-3333-4444-555555555555",
"path": "<requested-endpoint>"
}
{
"statusCode": 503,
"message": "Service Unavailable. Please Contact Support"
}
400 credits per request
  • Detailed breakdown of DeFi assets and protocols
  • Track staked tokens, LP positions, and earned rewards
This endpoint is only available for users with a Degen plan subscription (when using shareToken).
  • shareToken OR portfolioId: Provide one of these to identify the portfolio.
    • shareToken: Get Share Token
    • portfolioId: Use a portfolio connected via POST /portfolio/wallet
  • If neither is provided, returns DeFi data for all API-connected portfolios
  • passcode: Passcode for accessing protected portfolio data (can be passed in header or query parameter)

Authorizations

X-API-KEY
string
header
required

API key required to access the endpoints. Generate one from your dashboard at https://openapi.coinstats.app and pass it in the X-API-KEY request header. Never expose your key in client-side code.

Headers

sharetoken
string
passcode
string

Passcode for accessing protected portfolio data

Example:

"123456"

Query Parameters

portfolioId
string

Portfolio ID for accessing a specific API-connected portfolio. Required if shareToken is not provided.

Example:

"abc123def456"

Response

Defi Response

totalAssets
object
required

Total value of all DeFi positions across all protocols

protocols
object[]
required

List of DeFi protocols with user positions