> ## Documentation Index
> Fetch the complete documentation index at: https://docs.solanatracker.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Solana 钱包净值走势 API

> 按小时或按天获取 Solana 钱包的净值历史，包含 DeFi 仓位，附带 24 小时和 30 天变化。

钱包的净值走势，以 USD 和 SOL 计。每个点是该小时或该天（UTC）结束时的净值。

* 通过 Wallet V2 请求过的钱包会记录净值，并在最后一次请求后继续记录 30 天。请求一个尚未记录的钱包会开始记录它。
* 钱包开始记录之前的点只计入代币，不含 DeFi 仓位，`includesPositions` 为 `false`。传入 `includesPositions=true` 可排除这些点。
* `changePercent` 是相对前一个点的变化。在从仅含代币的点切换到完整点的位置为 `null`。
* `change` 将最新的点与 24 小时前和 30 天前比较。30 天变化需要超过 30 天的时间范围。

响应中的 `time` 为 Unix 毫秒；`time_from` 和 `time_to` 为 Unix 秒。

## SDK Example

```typescript
import { Client } from '@solana-tracker/data-api';

const client = new Client({ apiKey: 'YOUR_API_KEY' });

const data = await client.getWalletChartV2('CN8w8cuh87gZYjhpaPxbD78GTrBmUKmVysqgsC9uYu9i', {
  interval: '1d', // Or '1h', up to 90 days.
  timeFrom: Math.floor(Date.now() / 1000) - 30 * 86400, // Unix seconds.
  includesPositions: true, // Leaves out the older tokens-only points.
});

console.log(data.change['24h'].percent, data.points.at(-1)?.usd);
```


## OpenAPI

````yaml /cn/data-api/wallet-v2/openapi.json get /v2/wallet/{wallet}/chart
openapi: 3.1.0
info:
  title: Solana Tracker Wallet API v2
  version: 2.0.0
  description: >-
    Solana 钱包持有和赚取的一切：代币，以及在借贷、流动性、质押、杠杆和挂单平台上的 DeFi 仓位，按 USD 和 SOL
    计价，并提供收益率、可领取奖励和净值历史。百分比直接用数字表示（6.99 即 6.99%），除另有说明外，时间均为 Unix 毫秒。
  contact:
    email: contact@solanatracker.io
servers:
  - url: https://data.solanatracker.io
    description: Production server
security:
  - apiKey: []
tags:
  - name: Wallet
    description: 钱包的净值、代币、DeFi 仓位和净值历史。
  - name: Platforms
    description: Wallet V2 支持的 DeFi 平台。
paths:
  /v2/wallet/{wallet}/chart:
    get:
      tags:
        - Wallet
      summary: Get Wallet Net Worth Chart
      description: 钱包的净值走势，每小时或每天（UTC）一个点，附带 24 小时和 30 天变化。
      operationId: getWalletChartV2
      parameters:
        - $ref: '#/components/parameters/Wallet'
        - $ref: '#/components/parameters/Interval'
        - $ref: '#/components/parameters/TimeFrom'
        - $ref: '#/components/parameters/TimeTo'
        - $ref: '#/components/parameters/IncludesPositions'
      responses:
        '200':
          description: 钱包的净值历史。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WalletV2ChartResponse'
              example:
                wallet: CN8w8cuh87gZYjhpaPxbD78GTrBmUKmVysqgsC9uYu9i
                interval: 1d
                change:
                  24h:
                    usd: -158.388082
                    percent: -0.13
                  30d:
                    usd: null
                    percent: null
                points:
                  - time: 1787011200000
                    usd: 6923.059
                    sol: 91.06526
                    includesPositions: false
                    changePercent: null
                  - time: 1795132800000
                    usd: 122629.863201
                    sol: 1781.128012921
                    includesPositions: true
                    changePercent: null
                  - time: 1795219200000
                    usd: 122824.201652
                    sol: 1750.387522537
                    includesPositions: true
                    changePercent: 0.16
                  - time: 1795305600000
                    usd: 122665.81357
                    sol: 1778.432891944
                    includesPositions: true
                    changePercent: -0.13
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          $ref: '#/components/responses/Unavailable'
      x-codeSamples:
        - lang: typescript
          label: SDK
          source: >
            import { Client } from '@solana-tracker/data-api';


            const client = new Client({ apiKey: 'YOUR_API_KEY' });


            const data = await
            client.getWalletChartV2('CN8w8cuh87gZYjhpaPxbD78GTrBmUKmVysqgsC9uYu9i',
            {
              interval: '1d', // Or '1h', up to 90 days.
              timeFrom: Math.floor(Date.now() / 1000) - 30 * 86400, // Unix seconds.
              includesPositions: true, // Leaves out the older tokens-only points.
            });


            console.log(data.change['24h'].percent, data.points.at(-1)?.usd);
      x-code-samples:
        - lang: typescript
          label: SDK
          source: >
            import { Client } from '@solana-tracker/data-api';


            const client = new Client({ apiKey: 'YOUR_API_KEY' });


            const data = await
            client.getWalletChartV2('CN8w8cuh87gZYjhpaPxbD78GTrBmUKmVysqgsC9uYu9i',
            {
              interval: '1d', // Or '1h', up to 90 days.
              timeFrom: Math.floor(Date.now() / 1000) - 30 * 86400, // Unix seconds.
              includesPositions: true, // Leaves out the older tokens-only points.
            });


            console.log(data.change['24h'].percent, data.points.at(-1)?.usd);
components:
  parameters:
    Wallet:
      name: wallet
      in: path
      required: true
      schema:
        type: string
        default: CN8w8cuh87gZYjhpaPxbD78GTrBmUKmVysqgsC9uYu9i
      description: 钱包地址。
    Interval:
      name: interval
      in: query
      schema:
        type: string
        enum:
          - 1d
          - 1h
        default: 1d
      description: '`1d` 每天一个点（单次最多 5 年，默认 365 天），`1h` 每小时一个点（单次最多 90 天，默认 7 天）。'
    TimeFrom:
      name: time_from
      in: query
      schema:
        type: integer
      description: 开始时间，Unix 秒，包含该时间。默认为 `time_to` 之前 7 天（`1h`）或 365 天（`1d`）。
    TimeTo:
      name: time_to
      in: query
      schema:
        type: integer
      description: 结束时间，Unix 秒，包含该时间。默认为当前时间。不能早于 `time_from`。
    IncludesPositions:
      name: includesPositions
      in: query
      schema:
        type: boolean
      description: '`true` 只返回包含 DeFi 仓位的点，不返回较早的仅含代币的点。'
  schemas:
    WalletV2ChartResponse:
      type: object
      required:
        - wallet
        - interval
        - change
        - points
      properties:
        wallet:
          type: string
        interval:
          type: string
          enum:
            - 1h
            - 1d
        change:
          type: object
          description: >-
            Change between the latest point and the points 24 hours and 30 days
            earlier. Null when there is no earlier point to compare with, or
            when one of the two points counts tokens only. The 30-day change
            needs a time range longer than 30 days.
          required:
            - 24h
            - 30d
          properties:
            24h:
              type: object
              required:
                - usd
                - percent
              properties:
                usd:
                  type:
                    - number
                    - 'null'
                  description: Change in USD over 24 hours.
                percent:
                  type:
                    - number
                    - 'null'
                  description: >-
                    Change in percent (6.99 means 6.99%). Null when the earlier
                    value was 0.
            30d:
              type: object
              required:
                - usd
                - percent
              properties:
                usd:
                  type:
                    - number
                    - 'null'
                  description: Change in USD over 30 days.
                percent:
                  type:
                    - number
                    - 'null'
                  description: >-
                    Change in percent (6.99 means 6.99%). Null when the earlier
                    value was 0.
        points:
          type: array
          items:
            type: object
            required:
              - time
              - usd
              - sol
              - includesPositions
              - changePercent
            properties:
              time:
                type: integer
                description: Start of the hour or day (UTC), in Unix milliseconds.
              usd:
                type: number
                description: Net worth in USD.
              sol:
                type:
                  - number
                  - 'null'
                description: Net worth in SOL. Null when the SOL price was unavailable.
              includesPositions:
                type: boolean
                description: >-
                  `false` on older points that count tokens only, without DeFi
                  positions. Their `usd` can't be compared with full points.
              changePercent:
                type:
                  - number
                  - 'null'
                description: >-
                  Change in percent from the previous point. Null on the first
                  point, after a point worth 0, and where tokens-only points
                  switch to full points.
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: Error message.
  responses:
    BadRequest:
      description: 钱包地址或查询参数无效。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: 'Invalid sort. Valid options are: value, amount, change24h'
    Unauthorized:
      description: API 密钥缺失或无效。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unavailable:
      description: 暂时无法加载该钱包。请在 `Retry-After` 秒后重试。
      headers:
        Retry-After:
          description: 重试前需等待的秒数。
          schema:
            type: integer
            example: 1
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error: Wallet data is temporarily unavailable, please retry
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: API Key for authentication

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.