Skip to main content

Portfolio Performance Chart

Get historical data to visualize your portfolio’s performance over various time periods. This endpoint provides time-series data showing how your portfolio value has changed, perfect for creating charts and analyzing trends.

Key Features

  • Multiple Time Ranges: View data from 24 hours to all-time history
  • Time-Series Data: Arrays of timestamps and corresponding values
  • Performance Tracking: Track portfolio growth and declines over time
  • Historical Profit/Loss: See how your PnL has evolved
  • Trend Analysis: Identify patterns and market cycles in your portfolio
This endpoint is only available for users with a Degen plan subscription. You’ll need a share token to access portfolio data. Learn more about Share Token Authentication.

Get Portfolio Chart Data

Retrieve historical portfolio performance data:
curl -H "X-API-KEY: your-api-key" \
  "https://openapiv1.coinstats.app/portfolio/chart?shareToken=YOUR_SHARE_TOKEN&type=1w"
8 credits per request

Parameters

ParameterTypeRequiredDescription
shareTokenstringYesYour portfolio share token (how to get it)
typestringYesTime range for chart data
passcodestringNoPasscode if your portfolio is protected

Time Range Options

TypeDescriptionData Points
24hLast 24 hoursHourly data points
1wLast 7 days6-hour intervals
1mLast 30 daysDaily data points
3mLast 90 daysDaily data points
6mLast 180 daysDaily data points
1yLast 365 daysDaily data points
allAll-time historyVariable intervals
For better security, pass the share token and passcode in headers:
curl -H "X-API-KEY: your-api-key" \
     -H "sharetoken: YOUR_SHARE_TOKEN" \
     -H "passcode: 123456" \
     "https://openapiv1.coinstats.app/portfolio/chart?type=1m"

Example Response

The response is an array of arrays, where each sub-array contains [timestamp, value]:
{
  "result": [
    [1701388800000, 125430.52],
    [1701475200000, 128945.76],
    [1701561600000, 126780.44],
    [1701648000000, 130205.18],
    [1701734400000, 132890.92],
    [1701820800000, 131450.38],
    [1701907200000, 134720.65]
  ]
}

Data Format

  • First element: Unix timestamp in milliseconds
  • Second element: Portfolio value in USD at that timestamp

Visualization Examples

JavaScript Chart Example

Using Chart.js to visualize portfolio performance:
const response = await fetch('https://openapiv1.coinstats.app/portfolio/chart?shareToken=YOUR_SHARE_TOKEN&type=1m', {
  headers: { 'X-API-KEY': 'your-api-key' }
});
const data = await response.json();

// Transform data for Chart.js
const chartData = {
  labels: data.result.map(point => new Date(point[0]).toLocaleDateString()),
  datasets: [{
    label: 'Portfolio Value (USD)',
    data: data.result.map(point => point[1]),
    borderColor: 'rgb(75, 192, 192)',
    tension: 0.1
  }]
};

// Create chart
new Chart(ctx, {
  type: 'line',
  data: chartData,
  options: {
    responsive: true,
    plugins: {
      title: {
        display: true,
        text: 'Portfolio Performance - Last 30 Days'
      }
    }
  }
});

Python Visualization

Using matplotlib to plot portfolio data:
import requests
import matplotlib.pyplot as plt
from datetime import datetime

response = requests.get(
    'https://openapiv1.coinstats.app/portfolio/chart',
    params={'shareToken': 'YOUR_SHARE_TOKEN', 'type': '1m'},
    headers={'X-API-KEY': 'your-api-key'}
)
data = response.json()

# Extract timestamps and values
timestamps = [datetime.fromtimestamp(point[0]/1000) for point in data['result']]
values = [point[1] for point in data['result']]

# Create plot
plt.figure(figsize=(12, 6))
plt.plot(timestamps, values, linewidth=2)
plt.title('Portfolio Performance - Last 30 Days')
plt.xlabel('Date')
plt.ylabel('Value (USD)')
plt.grid(True, alpha=0.3)
plt.xticks(rotation=45)
plt.tight_layout()
plt.show()

Use Cases

Performance Dashboard

Build interactive dashboards showing portfolio growth over time

Trend Analysis

Identify bull and bear market cycles in your portfolio

Goal Tracking

Monitor progress toward investment goals with visual charts

Historical Reports

Generate historical performance reports for any time period

Calculate Performance Metrics

Use chart data to calculate custom metrics:
async function getPortfolioMetrics(shareToken, period) {
  const response = await fetch(
    `https://openapiv1.coinstats.app/portfolio/chart?shareToken=${shareToken}&type=${period}`,
    { headers: { 'X-API-KEY': 'your-api-key' } }
  );
  const data = await response.json();
  
  const values = data.result.map(p => p[1]);
  const firstValue = values[0];
  const lastValue = values[values.length - 1];
  const maxValue = Math.max(...values);
  const minValue = Math.min(...values);
  
  return {
    currentValue: lastValue,
    startValue: firstValue,
    change: lastValue - firstValue,
    changePercent: ((lastValue - firstValue) / firstValue * 100).toFixed(2),
    highValue: maxValue,
    lowValue: minValue,
    volatility: ((maxValue - minValue) / minValue * 100).toFixed(2)
  };
}

// Usage
const metrics = await getPortfolioMetrics('YOUR_SHARE_TOKEN', '1m');
console.log(`30-Day Performance: ${metrics.changePercent}%`);
console.log(`Volatility: ${metrics.volatility}%`);

Comparing Time Periods

Compare performance across different time ranges:
async function comparePerformance(shareToken) {
  const periods = ['24h', '1w', '1m', '1y'];
  const results = {};
  
  for (const period of periods) {
    const response = await fetch(
      `https://openapiv1.coinstats.app/portfolio/chart?shareToken=${shareToken}&type=${period}`,
      { headers: { 'X-API-KEY': 'your-api-key' } }
    );
    const data = await response.json();
    const values = data.result.map(p => p[1]);
    const change = ((values[values.length - 1] - values[0]) / values[0] * 100).toFixed(2);
    results[period] = `${change}%`;
  }
  
  return results;
}

// Output example:
// { '24h': '+2.4%', '1w': '+5.8%', '1m': '+12.3%', '1y': '+45.6%' }

Error Handling

{
  "error": "shareToken is required"
}
Solution: Include the share token in your request
{
  "error": "Invalid time range type"
}
Solution: Use one of the valid time range options (24h, 1w, 1m, 3m, 6m, 1y, all)
{
  "error": "Invalid API key"
}
Solution: Check that your API key is correct and active
{
  "error": "This endpoint requires a Degen plan subscription"
}
Solution: Upgrade to a Degen plan to access portfolio endpoints
{
  "error": "Shared portfolio not found"
}
Solution: Verify your share token is correct
{
  "error": "Passcode required for this portfolio"
}
Solution: Include the correct passcode in your request
Chart data availability depends on your portfolio’s history. New portfolios may have limited historical data for longer time ranges.

Best Practices

  • Cache chart data and refresh periodically rather than on every page load
  • Use appropriate time ranges for your use case (24h for real-time, 1m for recent trends)
  • Check for empty arrays or null values in responses
  • Implement fallbacks for portfolios with limited history
  • Use line charts for continuous data
  • Add annotations for significant events (large deposits/withdrawals)
  • Include percentage changes in chart titles for context