Skip to main content
Share tokens provide a secure way to access portfolio data from the CoinStats app through the API. This authentication method allows you to share specific portfolio information without exposing your main API credentials.

What is a Share Token?

A share token is a unique identifier that grants API access to a specific portfolio. It’s generated directly from your CoinStats portfolio and can be used to:
  • View portfolio holdings and balances
  • Access transaction history
  • Retrieve DeFi positions and staking data
  • Get portfolio performance metrics and charts
  • Add transactions to manual portfolios
Share tokens are available to all CoinStats users — generate one from your portfolio using the Share button (see below). All portfolio endpoints require either a share token or proper API authentication.

Getting Your Share Token

1

Visit your CoinStats Portfolio

Go to CoinStats Portfolio and make sure you are signed in to your account.
2

Access the Share Button

In the top-right corner of the page, click on the Share button.
Share Button Location
3

Generate a Share Link

This will bring up sharing preferences for your portfolio. Fill Title and Description and Click Generate Link.
Make sure you understand the privacy implications of sharing your portfolio data before generating a link.
4

Extract the Share Token

In the generated URL, the segment following /p/ is your share token.
Share Button Location
Copy only the token portion (without additional slashes or characters).

Passcode Protection

Some portfolios may be protected with an additional passcode for extra security. If a portfolio requires a passcode, you can include it in your requests using either query parameters or headers (recommended):

Method 2: Query Parameter

The passcode is an optional 6-digit code that can be set when sharing a portfolio for additional privacy protection. Headers are recommended for better security as they keep sensitive information out of URL logs.

Using Share Tokens in API Requests

Share tokens can be provided via the sharetoken request header (recommended) or as a query parameter. Include the share token in the sharetoken header:
With passcode:

Method 2: Query Parameter

Pass shareToken as a query parameter:
With passcode:

Hybrid Approach

You can also mix query parameters and headers:
Headers take precedence over query parameters when both are provided for the same value.

Endpoints That Use Share Tokens

All portfolio-related endpoints require share tokens:

Portfolio Value

Get comprehensive portfolio profit/loss data and metrics

Portfolio Holdings

View all coins in your portfolio with current holdings and PnL

Portfolio Chart

Historical performance data for portfolio visualization

Transaction History

Complete transaction history with filtering options

Add Transaction

Add new transactions to manual portfolios

DeFi Positions

Staking, liquidity pools, and yield farming data

Portfolio Snapshots

Historical portfolio snapshot data over time

Security Best Practices

  • Store share tokens passcode securely using environment variables
  • Never expose share tokens passcode in client-side code
  • Keep track of where you’ve shared your portfolio links
  • Consider using passcode protection for sensitive portfolios

Error Handling

Common errors when using share tokens:
Solution: Ensure you’re providing the share token either as a query parameter or header.
Solution: Verify that your share token is correct and the portfolio still exists.
Solution: Include the correct passcode in your request parameters.
Solution: This error occurs when trying to add transactions to a portfolio you don’t own or to non-manual portfolios.