> ## 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.

# Wallet balance

> Recibe cambios de balance de SOL de una wallet de Solana vía Datastream WebSocket para tracking en vivo, alertas y dashboards de portfolio.

## SDK Example

```typescript theme={null}
import { Datastream } from '@solana-tracker/data-api';

const dataStream = new Datastream({
  wsUrl: 'wss://datastream.solanatracker.io/YOUR_API_KEY',
});

dataStream.on('error', console.error);
await dataStream.connect();

const sub = dataStream.subscribe.wallet('FbMxP3GVq8TQ36nbYgx4NP9iygMpwAwFWJwW81ioCiSF').balance().on((data) => {
  console.log(data);
});

// sub.unsubscribe();
```


## AsyncAPI

````yaml es/datastream/wallet.json walletBalance
id: walletBalance
title: Wallet balance
description: Cambios de saldo de cualquier token
servers:
  - id: production
    protocol: wss
    host: datastream.solanatracker.io
    bindings: []
    variables:
      - id: apiKey
        description: Su clave API única de la suscripción a Data API
        defaultValue: YOUR_DATASTREAM_KEY
        allowedValues: []
        examples: []
address: /
parameters: []
bindings: []
operations:
  - &ref_2
    id: subscribeToBalance
    title: Subscribe to balance
    description: Subscribe to wallet balance
    type: receive
    messages:
      - &ref_5
        id: joinBalance
        payload:
          - name: joinBalance
            description: Subscribe to wallet balance changes
            type: object
            properties:
              - name: type
                type: string
                description: join
                required: true
              - name: room
                type: string
                description: Wallet balance room (wallet:{walletAddress}:balance)
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
            - room
          properties:
            type:
              type: string
              const: join
              default: join
              x-parser-schema-id: <anonymous-schema-51>
            room:
              type: string
              pattern: ^wallet:[A-Za-z0-9]{32,44}:balance$
              description: Wallet balance room (wallet:{walletAddress}:balance)
              default: wallet:FV1r15rbNKkJanXLheoJA7fXEq6NDuMJ3bukXuhJWyV1:balance
              x-parser-schema-id: <anonymous-schema-52>
          examples:
            - type: join
              room: wallet:FV1r15rbNKkJanXLheoJA7fXEq6NDuMJ3bukXuhJWyV1:balance
          x-parser-schema-id: <anonymous-schema-50>
        title: Join balance
        description: Subscribe to wallet balance changes
        example: |-
          {
            "type": "join",
            "room": "wallet:FV1r15rbNKkJanXLheoJA7fXEq6NDuMJ3bukXuhJWyV1:balance"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: joinBalance
          - id: x-parser-message-name
            value: joinBalance
    bindings: []
    extensions: &ref_1
      - id: x-codeSamples
        value: &ref_8
          - lang: typescript
            label: SDK
            source: >
              import { Datastream } from '@solana-tracker/data-api';


              const dataStream = new Datastream({
                wsUrl: 'wss://datastream.solanatracker.io/YOUR_API_KEY',
              });


              dataStream.on('error', console.error);

              await dataStream.connect();


              const sub =
              dataStream.subscribe.wallet('FbMxP3GVq8TQ36nbYgx4NP9iygMpwAwFWJwW81ioCiSF').balance().on((data)
              => {
                console.log(data);
              });


              // sub.unsubscribe();
      - id: x-parser-unique-object-id
        value: walletBalance
  - &ref_4
    id: receiveBalanceData
    title: Receive balance data
    description: Receive balance updates
    type: send
    messages:
      - &ref_7
        id: balanceMessage
        payload:
          - name: balanceMessage
            description: Balance change notification
            type: object
            properties:
              - name: type
                type: string
                description: message
                required: false
              - name: room
                type: string
                required: false
              - name: data
                type: object
                examples: &ref_0
                  - wallet: FV1r15rbNKkJanXLheoJA7fXEq6NDuMJ3bukXuhJWyV1
                    token: Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB
                    amount: 78816.844996
                  - wallet: FV1r15rbNKkJanXLheoJA7fXEq6NDuMJ3bukXuhJWyV1
                    token: So11111111111111111111111111111111111111112
                    amount: 1.2345
                required: false
                properties:
                  - name: wallet
                    type: string
                    description: Wallet public key that received the balance update
                    required: true
                  - name: token
                    type: string
                    description: >-
                      Token mint address. Native SOL uses the wrapped SOL mint
                      `So11111111111111111111111111111111111111112` (same
                      identifier for SOL balance updates on these rooms).
                    required: true
                  - name: amount
                    type: number
                    description: >-
                      UI token amount after the update (decimal human units, not
                      raw integer base units / lamports). Example:
                      `78816.844996` for a fractional SPL balance. Use this
                      value for display and reconciliation against UI balances;
                      convert with mint decimals if you need raw integer
                      amounts.
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            type:
              type: string
              const: message
              x-parser-schema-id: <anonymous-schema-57>
            room:
              type: string
              x-parser-schema-id: <anonymous-schema-58>
            data:
              type: object
              required:
                - wallet
                - token
                - amount
              properties:
                wallet:
                  type: string
                  description: Wallet public key that received the balance update
                  x-parser-schema-id: <anonymous-schema-59>
                token:
                  type: string
                  description: >-
                    Token mint address. Native SOL uses the wrapped SOL mint
                    `So11111111111111111111111111111111111111112` (same
                    identifier for SOL balance updates on these rooms).
                  x-parser-schema-id: <anonymous-schema-60>
                amount:
                  type: number
                  description: >-
                    UI token amount after the update (decimal human units, not
                    raw integer base units / lamports). Example: `78816.844996`
                    for a fractional SPL balance. Use this value for display and
                    reconciliation against UI balances; convert with mint
                    decimals if you need raw integer amounts.
                  x-parser-schema-id: <anonymous-schema-61>
              examples: *ref_0
              x-parser-schema-id: BalanceUpdate
          examples:
            - type: message
              data:
                wallet: FV1r15rbNKkJanXLheoJA7fXEq6NDuMJ3bukXuhJWyV1
                token: Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB
                amount: 78816.844996
              room: wallet:FV1r15rbNKkJanXLheoJA7fXEq6NDuMJ3bukXuhJWyV1:balance
          x-parser-schema-id: <anonymous-schema-56>
        title: Balance message
        description: Balance change notification
        example: |-
          {
            "type": "message",
            "data": {
              "wallet": "FV1r15rbNKkJanXLheoJA7fXEq6NDuMJ3bukXuhJWyV1",
              "token": "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
              "amount": 78816.844996
            },
            "room": "wallet:FV1r15rbNKkJanXLheoJA7fXEq6NDuMJ3bukXuhJWyV1:balance"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: balanceMessage
          - id: x-parser-message-name
            value: balanceMessage
    bindings: []
    extensions: *ref_1
  - &ref_3
    id: unsubscribeFromBalance
    title: Unsubscribe from balance
    description: Unsubscribe from balance
    type: receive
    messages:
      - &ref_6
        id: leaveBalance
        payload:
          - name: leaveBalance
            description: Unsubscribe from balance updates
            type: object
            properties:
              - name: type
                type: string
                description: leave
                required: true
              - name: room
                type: string
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
            - room
          properties:
            type:
              type: string
              const: leave
              default: leave
              x-parser-schema-id: <anonymous-schema-63>
            room:
              type: string
              default: wallet:FV1r15rbNKkJanXLheoJA7fXEq6NDuMJ3bukXuhJWyV1:balance
              x-parser-schema-id: <anonymous-schema-64>
          examples:
            - type: leave
              room: wallet:FV1r15rbNKkJanXLheoJA7fXEq6NDuMJ3bukXuhJWyV1:balance
          x-parser-schema-id: <anonymous-schema-62>
        title: Leave balance
        description: Unsubscribe from balance updates
        example: |-
          {
            "type": "leave",
            "room": "wallet:FV1r15rbNKkJanXLheoJA7fXEq6NDuMJ3bukXuhJWyV1:balance"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: leaveBalance
          - id: x-parser-message-name
            value: leaveBalance
    bindings: []
    extensions: *ref_1
sendOperations:
  - *ref_2
  - *ref_3
receiveOperations:
  - *ref_4
sendMessages:
  - *ref_5
  - *ref_6
receiveMessages:
  - *ref_7
extensions:
  - id: x-codeSamples
    value: *ref_8
  - id: x-parser-unique-object-id
    value: walletBalance
securitySchemes:
  - id: apiKeyAuth
    name: apiKey
    type: httpApiKey
    description: >-
      API key for authentication. Include your Datastream key in the connection
      URL: wss://datastream.solanatracker.io/{DATASTREAM_KEY}
    in: header
    extensions: []

````

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