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

# Subscribe Balance Changes

> Subscribe to real-time token and native balance changes.

<Callout icon="activity" color="#FFC107" iconType="regular">To keep the connection alive, you need to send a ping message every less than 60 seconds.</Callout>

You can subscribe and unsubscribe to any amount of topics you want on a single connection.

To update a topic subscription, you can resubscribe to the same topic with new parameters.

Incoming messages will include a `topic` field that you can use to filter the type of message.

<Tip>When **subscribing**, you can leave any of the array fields of the `params` object empty to subscribe to all entries for that field.</Tip>
<Tip>When **unsubscribing**, you can leave the `topics` array empty to unsubscribe from all topics.</Tip>


## AsyncAPI

````yaml dist/asyncapi.yml solanaAssetsBalanceChangesSubscription
id: solanaAssetsBalanceChangesSubscription
title: Balance Changes Subscription
description: Subscribe to real-time token and native balance change events.
servers:
  - id: production
    protocol: wss
    host: refract.prismapi.io
    bindings: []
    variables: []
address: /v1/ws
parameters: []
bindings: []
operations:
  - &ref_2
    id: receiveSolanaAssetsBalanceChangesSubscription
    title: Receive solana assets balance changes subscription
    type: send
    messages:
      - &ref_5
        id: balanceChangesSubscriptionMessage
        contentType: application/json
        payload:
          - name: Balance Changes Message
            description: Message containing the balance change data.
            type: object
            properties:
              - name: topic
                type: string
                enumValues:
                  - solana.dex.prices
                  - solana.dex.swaps
                  - solana.dex.trades
                  - solana.dex.pools
                  - solana.dex.profiles.wallet
                  - solana.dex.profiles.token
                  - solana.dex.profiles.position
                  - solana.assets.transfers
                  - solana.assets.balance-changes
                required: false
              - name: data
                type: object
                required: false
                properties:
                  - name: id
                    type: integer
                    required: false
                  - name: balance_type
                    type: string
                    enumValues:
                      - spl_token_balance
                      - native_balance
                    required: false
                  - name: stack_height
                    type: integer
                    required: false
                  - name: token_address
                    type: string
                    required: false
                  - name: owner_address
                    type: string
                    required: false
                  - name: pre_balance
                    type: number
                    required: false
                  - name: post_balance
                    type: number
                    required: false
                  - name: block_slot
                    type: integer
                    required: false
                  - name: block_time
                    type: string
                    required: false
                  - name: tx_hash
                    type: string
                    required: false
        headers: []
        jsonPayloadSchema:
          type: object
          properties:
            topic:
              x-fern-type-name: SubscriptionTopicEnum
              type: string
              enum:
                - solana.dex.prices
                - solana.dex.swaps
                - solana.dex.trades
                - solana.dex.pools
                - solana.dex.profiles.wallet
                - solana.dex.profiles.token
                - solana.dex.profiles.position
                - solana.assets.transfers
                - solana.assets.balance-changes
              x-parser-schema-id: <anonymous-schema-383>
            data:
              x-fern-type-name: SolanaAssetsBalanceChangeMessage
              type: object
              properties:
                id:
                  type: integer
                  x-parser-schema-id: <anonymous-schema-385>
                balance_type:
                  x-fern-type-name: SolanaAssetsBalanceChangeTypeEnum
                  type: string
                  enum:
                    - spl_token_balance
                    - native_balance
                  x-parser-schema-id: <anonymous-schema-386>
                stack_height:
                  type: integer
                  x-parser-schema-id: <anonymous-schema-387>
                token_address:
                  type: string
                  x-parser-schema-id: <anonymous-schema-388>
                owner_address:
                  type: string
                  x-parser-schema-id: <anonymous-schema-389>
                pre_balance:
                  type: number
                  x-parser-schema-id: <anonymous-schema-390>
                post_balance:
                  type: number
                  x-parser-schema-id: <anonymous-schema-391>
                block_slot:
                  type: integer
                  x-parser-schema-id: <anonymous-schema-392>
                block_time:
                  type: string
                  format: date-time
                  x-parser-schema-id: <anonymous-schema-393>
                tx_hash:
                  type: string
                  x-parser-schema-id: <anonymous-schema-394>
              x-parser-schema-id: <anonymous-schema-384>
          x-parser-schema-id: <anonymous-schema-382>
        title: Balance Changes Message
        description: Message containing the balance change data.
        example: |-
          {
            "topic": "solana.assets.balance-changes",
            "data": {
              "id": 1,
              "balance_type": "spl_token_balance",
              "stack_height": 2,
              "token_address": "13NyGvtCdrBUqRSRHJUfw6yXFLoZ9VBu27RL8fq4daos",
              "owner_address": "CsVdJ8WH8Q9eHSTRpwtwN3TYApm24QnLKYUMNxJ3DaED",
              "pre_balance": 256.4115815,
              "post_balance": 1991.57546081,
              "block_slot": 382423380,
              "block_time": "2026-05-28T12:00:00Z"
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: balanceChangesSubscriptionMessage
          - id: x-parser-message-name
            value: balanceChangesSubscriptionMessage
    bindings: []
    extensions: &ref_0
      - id: x-parser-unique-object-id
        value: solanaAssetsBalanceChangesSubscription
  - &ref_1
    id: sendSolanaAssetsBalanceChangesSubscription
    title: Send solana assets balance changes subscription
    type: receive
    messages:
      - &ref_3
        id: subscribeBalanceChanges
        contentType: application/json
        payload:
          - name: Subscribe Balance Changes
            description: Subscribe to balance change updates.
            type: object
            properties:
              - name: method
                type: string
                enumValues:
                  - subscribe
                  - unsubscribe
                required: true
              - name: topic
                type: string
                enumValues:
                  - solana.dex.prices
                  - solana.dex.swaps
                  - solana.dex.trades
                  - solana.dex.pools
                  - solana.dex.profiles.wallet
                  - solana.dex.profiles.token
                  - solana.dex.profiles.position
                  - solana.assets.transfers
                  - solana.assets.balance-changes
                required: true
              - name: params
                type: object
                required: true
                properties:
                  - name: owner_addresses
                    type: array
                    required: false
                    properties:
                      - name: item
                        type: string
                        required: false
                  - name: token_addresses
                    type: array
                    required: false
                    properties:
                      - name: item
                        type: string
                        required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - method
            - topic
            - params
          properties:
            method:
              x-fern-type-name: SubscriptionMethodEnum
              type: string
              enum:
                - subscribe
                - unsubscribe
              x-parser-schema-id: <anonymous-schema-396>
            topic:
              x-fern-type-name: SubscriptionTopicEnum
              type: string
              enum:
                - solana.dex.prices
                - solana.dex.swaps
                - solana.dex.trades
                - solana.dex.pools
                - solana.dex.profiles.wallet
                - solana.dex.profiles.token
                - solana.dex.profiles.position
                - solana.assets.transfers
                - solana.assets.balance-changes
              x-parser-schema-id: <anonymous-schema-397>
            params:
              type: object
              properties:
                owner_addresses:
                  type: array
                  items:
                    type: string
                    x-parser-schema-id: <anonymous-schema-400>
                  x-parser-schema-id: <anonymous-schema-399>
                token_addresses:
                  type: array
                  items:
                    type: string
                    x-parser-schema-id: <anonymous-schema-402>
                  x-parser-schema-id: <anonymous-schema-401>
              x-parser-schema-id: <anonymous-schema-398>
          x-parser-schema-id: <anonymous-schema-395>
        title: Subscribe Balance Changes
        description: Subscribe to balance change updates.
        example: |-
          {
            "method": "subscribe",
            "topic": "solana.assets.balance-changes",
            "params": {
              "owner_addresses": [
                "13NyGvtCdrBUqRSRHJUfw6yXFLoZ9VBu27RL8fq4daos"
              ],
              "token_addresses": [
                "13NyGvtCdrBUqRSRHJUfw6yXFLoZ9VBu27RL8fq4daos"
              ]
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subscribeBalanceChanges
          - id: x-parser-message-name
            value: subscribeBalanceChanges
      - &ref_4
        id: unsubscribeBalanceChanges
        contentType: application/json
        payload:
          - name: Unsubscribe Balance Changes
            description: Unsubscribe from balance change updates.
            type: object
            properties:
              - name: method
                type: string
                enumValues:
                  - subscribe
                  - unsubscribe
                required: true
              - name: topics
                type: array
                description: >-
                  The topics to unsubscribe from. Leave empty to unsubscribe
                  from all topics.
                required: true
                properties:
                  - name: item
                    type: string
                    enumValues:
                      - solana.dex.prices
                      - solana.dex.swaps
                      - solana.dex.trades
                      - solana.dex.pools
                      - solana.dex.profiles.wallet
                      - solana.dex.profiles.token
                      - solana.dex.profiles.position
                      - solana.assets.transfers
                      - solana.assets.balance-changes
                    required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - method
            - topics
          properties:
            method:
              x-fern-type-name: SubscriptionMethodEnum
              type: string
              enum:
                - subscribe
                - unsubscribe
              x-parser-schema-id: <anonymous-schema-404>
            topics:
              type: array
              description: >-
                The topics to unsubscribe from. Leave empty to unsubscribe from
                all topics.
              items:
                x-fern-type-name: SubscriptionTopicEnum
                type: string
                enum:
                  - solana.dex.prices
                  - solana.dex.swaps
                  - solana.dex.trades
                  - solana.dex.pools
                  - solana.dex.profiles.wallet
                  - solana.dex.profiles.token
                  - solana.dex.profiles.position
                  - solana.assets.transfers
                  - solana.assets.balance-changes
                x-parser-schema-id: <anonymous-schema-406>
              x-parser-schema-id: <anonymous-schema-405>
          x-parser-schema-id: <anonymous-schema-403>
        title: Unsubscribe Balance Changes
        description: Unsubscribe from balance change updates.
        example: |-
          {
            "method": "unsubscribe",
            "topics": [
              "solana.assets.balance-changes"
            ]
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: unsubscribeBalanceChanges
          - id: x-parser-message-name
            value: unsubscribeBalanceChanges
    bindings: []
    extensions: *ref_0
sendOperations:
  - *ref_1
receiveOperations:
  - *ref_2
sendMessages:
  - *ref_3
  - *ref_4
receiveMessages:
  - *ref_5
extensions:
  - id: x-parser-unique-object-id
    value: solanaAssetsBalanceChangesSubscription
securitySchemes:
  - id: WsApiKeyAuth
    name: x-api-key
    type: httpApiKey
    description: >
      Your Prism API key. You can get one for free in the [Prism
      Dashboard](https://dashboard.prismapi.io).

      You must include it in the `x-api-key` query parameter.
    in: query
    extensions: []

````