# Get wallet PnL

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

GET https://api.g.alchemy.com/trading/v1/{apiKey}/wallets/{address}/pnl

**Private preview:** Paths, parameters, response fields, and tier names are provisional.

**Compute units:** 800 (proposed; pending validation).

Measure lifetime realized and unrealized profit or loss using average cost, split by network and token. All requested networks must be EVM networks. Pagination applies to token rows. General and Premium use different methodologies and their numbers are not comparable.

Use pageKey until it is null.

Reference: https://www.alchemy.com/docs/data/trading-api/endpoints/wallets/get-wallet-pnl

## Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| apiKey | string | Yes |  |
| address | string | Yes |  |

## Query Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| networks | enum[] | Yes | Supported networks for this operation during private preview. All networks must be EVM. |
| pageKey | string | No | Omit for the first page. Reuse the returned key unchanged; stop when the response key is null. |
| pageSize | integer | No | Maximum rows per page; provisional limit. |
| sortBy | enum | No | Metric used to order token results. Default order and direction are pending. |

## Code Examples

### cURL

```bash
curl --request GET \
  --url 'https://api.g.alchemy.com/trading/v1/docs-demo/wallets/0x7942262a7a5637e6eb0eec9b91b55ec232141f87/pnl?networks=eth-mainnet'
```

### JavaScript

```javascript
const options = {method: 'GET'};

fetch('https://api.g.alchemy.com/trading/v1/docs-demo/wallets/0x7942262a7a5637e6eb0eec9b91b55ec232141f87/pnl?networks=eth-mainnet', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.g.alchemy.com/trading/v1/docs-demo/wallets/0x7942262a7a5637e6eb0eec9b91b55ec232141f87/pnl?networks=eth-mainnet"

response = requests.get(url)

print(response.text)
```

### Go

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.g.alchemy.com/trading/v1/docs-demo/wallets/0x7942262a7a5637e6eb0eec9b91b55ec232141f87/pnl?networks=eth-mainnet"

	req, _ := http.NewRequest("GET", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.get("https://api.g.alchemy.com/trading/v1/docs-demo/wallets/0x7942262a7a5637e6eb0eec9b91b55ec232141f87/pnl?networks=eth-mainnet")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://api.g.alchemy.com/trading/v1/docs-demo/wallets/0x7942262a7a5637e6eb0eec9b91b55ec232141f87/pnl?networks=eth-mainnet");
var client = new RestClient(options);
var request = new RestRequest("");
var response = await client.GetAsync(request);

Console.WriteLine("{0}", response.Content);

```


## Operation Specification

```yaml
path: /{apiKey}/wallets/{address}/pnl
method: GET
operation:
  summary: Get wallet PnL
  operationId: get-wallet-pnl
  tags:
    - Wallets
  x-shape-pending: true
  description: |-
    **Private preview:** Paths, parameters, response fields, and tier names are provisional.

    **Compute units:** 800 (proposed; pending validation).

    Measure lifetime realized and unrealized profit or loss using average cost, split by network and token. All requested networks must be EVM networks. Pagination applies to token rows. General and Premium use different methodologies and their numbers are not comparable.

    Use pageKey until it is null.
  parameters:
    - name: apiKey
      in: path
      required: true
      schema:
        type: string
        default: docs-demo
        description: For higher throughput, [create your own API key](https://dashboard.alchemy.com/signup)
    - name: networks
      in: query
      required: true
      description: Supported networks for this operation during private preview. All networks must be EVM.
      schema:
        type: array
        minItems: 1
        items:
          type: string
          enum:
            - eth-mainnet
            - base-mainnet
            - arb-mainnet
            - opt-mainnet
            - matic-mainnet
            - bnb-mainnet
            - avax-mainnet
            - linea-mainnet
            - robinhood-mainnet
            - arc-mainnet
        x-shape-pending: true
      style: form
      explode: true
    - name: address
      in: path
      required: true
      schema:
        type: string
        description: Wallet address.
        x-shape-pending: true
      example: '0x7942262a7a5637e6eb0eec9b91b55ec232141f87'
    - name: pageKey
      in: query
      description: Omit for the first page. Reuse the returned key unchanged; stop when the response key is null.
      schema:
        type: string
        x-shape-pending: true
    - name: pageSize
      in: query
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 25
        x-shape-pending: true
      description: Maximum rows per page; provisional limit.
    - name: sortBy
      in: query
      schema:
        type: string
        enum:
          - realizedPnl
          - unrealizedPnl
          - buyVolume
          - sellVolume
        x-shape-pending: true
      description: Metric used to order token results. Default order and direction are pending.
  responses:
    '200':
      description: Successful response.
      content:
        application/json:
          schema:
            type: object
            properties:
              data:
                x-shape-pending: true
                type: object
                properties:
                  address:
                    type: string
                    description: Wallet address.
                    x-shape-pending: true
                  realizedPnlUsd:
                    type:
                      - string
                      - 'null'
                    pattern: ^-?[0-9]+(\.[0-9]+)?$
                    description: Lifetime realized profit or loss in USD. Decimal string; null means unknown.
                    x-shape-pending: true
                  unrealizedPnlUsd:
                    type:
                      - string
                      - 'null'
                    pattern: ^-?[0-9]+(\.[0-9]+)?$
                    description: Current unrealized profit or loss in USD. Decimal string; null means unknown.
                    x-shape-pending: true
                  networks:
                    type: array
                    items:
                      type: object
                      properties:
                        network:
                          description: Alchemy network slug.
                          x-shape-pending: true
                          type: string
                          enum:
                            - eth-mainnet
                            - base-mainnet
                            - arb-mainnet
                            - bnb-mainnet
                            - solana-mainnet
                            - opt-mainnet
                            - matic-mainnet
                            - avax-mainnet
                            - linea-mainnet
                            - hyperliquid-mainnet
                            - robinhood-mainnet
                            - arc-mainnet
                            - tempo-mainnet
                        realizedPnlUsd:
                          type:
                            - string
                            - 'null'
                          pattern: ^-?[0-9]+(\.[0-9]+)?$
                          description: Realized profit or loss in USD. Decimal string; null means unknown.
                          x-shape-pending: true
                        unrealizedPnlUsd:
                          type:
                            - string
                            - 'null'
                          pattern: ^-?[0-9]+(\.[0-9]+)?$
                          description: Unrealized profit or loss in USD. Decimal string; null means unknown.
                          x-shape-pending: true
                      required:
                        - network
                        - realizedPnlUsd
                        - unrealizedPnlUsd
                    x-shape-pending: true
                  tokens:
                    type: array
                    items:
                      type: object
                      properties:
                        network:
                          description: Alchemy network slug.
                          x-shape-pending: true
                          type: string
                          enum:
                            - eth-mainnet
                            - base-mainnet
                            - arb-mainnet
                            - bnb-mainnet
                            - solana-mainnet
                            - opt-mainnet
                            - matic-mainnet
                            - avax-mainnet
                            - linea-mainnet
                            - hyperliquid-mainnet
                            - robinhood-mainnet
                            - arc-mainnet
                            - tempo-mainnet
                        tokenAddress:
                          type: string
                          description: Token address.
                          x-shape-pending: true
                        realizedPnlUsd:
                          type:
                            - string
                            - 'null'
                          pattern: ^-?[0-9]+(\.[0-9]+)?$
                          description: Realized profit or loss in USD. Decimal string; null means unknown.
                          x-shape-pending: true
                        unrealizedPnlUsd:
                          type:
                            - string
                            - 'null'
                          pattern: ^-?[0-9]+(\.[0-9]+)?$
                          description: Unrealized profit or loss in USD. Decimal string; null means unknown.
                          x-shape-pending: true
                        buys:
                          x-shape-pending: true
                          type: object
                          properties:
                            count:
                              type: integer
                              minimum: 0
                              description: Number of trades.
                              x-shape-pending: true
                            amount:
                              type:
                                - string
                                - 'null'
                              pattern: ^-?[0-9]+(\.[0-9]+)?$
                              description: Total token amount. Decimal string; null means unknown.
                              x-shape-pending: true
                            usd:
                              type:
                                - string
                                - 'null'
                              pattern: ^-?[0-9]+(\.[0-9]+)?$
                              description: Total trade value in USD. Decimal string; null means unknown.
                              x-shape-pending: true
                            averagePriceUsd:
                              type:
                                - string
                                - 'null'
                              pattern: ^-?[0-9]+(\.[0-9]+)?$
                              description: Average execution price in USD. Decimal string; null means unknown.
                              x-shape-pending: true
                          required:
                            - count
                            - amount
                            - usd
                            - averagePriceUsd
                        sells:
                          x-shape-pending: true
                          type: object
                          properties:
                            count:
                              type: integer
                              minimum: 0
                              description: Number of trades.
                              x-shape-pending: true
                            amount:
                              type:
                                - string
                                - 'null'
                              pattern: ^-?[0-9]+(\.[0-9]+)?$
                              description: Total token amount. Decimal string; null means unknown.
                              x-shape-pending: true
                            usd:
                              type:
                                - string
                                - 'null'
                              pattern: ^-?[0-9]+(\.[0-9]+)?$
                              description: Total trade value in USD. Decimal string; null means unknown.
                              x-shape-pending: true
                            averagePriceUsd:
                              type:
                                - string
                                - 'null'
                              pattern: ^-?[0-9]+(\.[0-9]+)?$
                              description: Average execution price in USD. Decimal string; null means unknown.
                              x-shape-pending: true
                          required:
                            - count
                            - amount
                            - usd
                            - averagePriceUsd
                      required:
                        - network
                        - tokenAddress
                        - realizedPnlUsd
                        - unrealizedPnlUsd
                        - buys
                        - sells
                    x-shape-pending: true
                required:
                  - address
                  - realizedPnlUsd
                  - unrealizedPnlUsd
                  - networks
                  - tokens
              pageKey:
                type:
                  - string
                  - 'null'
                description: Opaque continuation key. Pass it unchanged to the next request; null marks the last page.
                x-shape-pending: true
            required:
              - data
              - pageKey
          example:
            data:
              address: '0x7942262a7a5637e6eb0eec9b91b55ec232141f87'
              realizedPnlUsd: '465692.44904367876'
              unrealizedPnlUsd: '-8650.833771133304'
              networks:
                - network: eth-mainnet
                  realizedPnlUsd: '465692.44904367876'
                  unrealizedPnlUsd: '-8650.833771133304'
              tokens:
                - network: eth-mainnet
                  tokenAddress: '0xf280b16ef293d8e534e370794ef26bf312694126'
                  realizedPnlUsd: '426966.15295516116'
                  unrealizedPnlUsd: null
                  buys:
                    count: 189
                    amount: '4022337788.5875463'
                    usd: '387037.66336058924'
                    averagePriceUsd: '0.0000962220687826664247'
                  sells:
                    count: 267
                    amount: '4033593429.971638'
                    usd: '814003.8163157504'
                    averagePriceUsd: '0.000201806114187734093'
                - network: eth-mainnet
                  tokenAddress: '0x829f4b62eebe12af653b4dd4ffc480966f7d7f09'
                  realizedPnlUsd: '80504.5740565090454'
                  unrealizedPnlUsd: '-125.402615774341646'
                  buys:
                    count: 94
                    amount: '159546.97412937233'
                    usd: '108278.27599193985'
                    averagePriceUsd: '0.678660793053586349'
                  sells:
                    count: 86
                    amount: '159313.54192456175'
                    usd: '188624.4287632079'
                    averagePriceUsd: '1.18398239399212817'
            pageKey: null
    '400':
      description: Invalid request parameters.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: object
                properties:
                  message:
                    type: string
                    description: Detailed error message.
                    x-shape-pending: true
                required:
                  - message
                x-shape-pending: true
            required:
              - error
          example:
            error:
              message: Invalid request parameters.
    '401':
      description: Invalid API key.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: object
                properties:
                  message:
                    type: string
                    description: Detailed error message.
                    x-shape-pending: true
                required:
                  - message
                x-shape-pending: true
            required:
              - error
          example:
            error:
              message: Invalid API key.
    '429':
      description: Request limit reached. Retry with backoff.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: object
                properties:
                  message:
                    type: string
                    description: Detailed error message.
                    x-shape-pending: true
                required:
                  - message
                x-shape-pending: true
            required:
              - error
          example:
            error:
              message: Request limit reached. Retry with backoff.
    '503':
      description: Data temporarily unavailable. Retry with backoff.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: object
                properties:
                  message:
                    type: string
                    description: Detailed error message.
                    x-shape-pending: true
                required:
                  - message
                x-shape-pending: true
            required:
              - error
          example:
            error:
              message: Data temporarily unavailable. Retry with backoff.
```
