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

> Subscribe to real-time wallet swaps.

<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 solanaDexSwapsSubscription
id: solanaDexSwapsSubscription
title: Swaps Subscription
description: Subscribe to real-time swap updates.
servers:
  - id: production
    protocol: wss
    host: refract.prismapi.io
    bindings: []
    variables: []
address: /v1/ws
parameters: []
bindings: []
operations:
  - &ref_2
    id: receiveSolanaDexSwapsSubscription
    title: Receive solana dex swaps subscription
    type: send
    messages:
      - &ref_5
        id: swapsSubscriptionMessage
        contentType: application/json
        payload:
          - name: Wallet Swap Message
            description: Message containing the swap data for the subscribed wallets.
            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: swap_type
                    type: string
                    enumValues:
                      - quote_token
                      - token_quote
                      - token_token
                      - quote_quote
                    required: false
                  - name: protocol
                    type: string
                    description: >-
                      Refer to [Data
                      Sources](/documentation/solana/dex/overview#data-sources)
                      for the list of supported protocols.
                    required: false
                  - name: wallet_address
                    type: string
                    required: false
                  - name: pool_address
                    type: string
                    required: false
                  - name: token_address_in
                    type: string
                    required: false
                  - name: token_address_out
                    type: string
                    required: false
                  - name: token_amount_in
                    type: number
                    required: false
                  - name: token_amount_out
                    type: number
                    required: false
                  - name: token_price_in
                    type: number
                    required: false
                  - name: token_price_out
                    type: number
                    required: false
                  - name: pre_token_balance_in
                    type: number
                    required: false
                  - name: pre_token_balance_out
                    type: number
                    required: false
                  - name: post_token_balance_in
                    type: number
                    required: false
                  - name: post_token_balance_out
                    type: number
                    required: false
                  - name: usd_amount_in
                    type: number
                    required: false
                  - name: usd_amount_out
                    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-22>
            data:
              x-fern-type-name: SolanaDexSwapMessage
              type: object
              properties:
                id:
                  type: integer
                  x-parser-schema-id: <anonymous-schema-24>
                swap_type:
                  x-fern-type-name: SolanaDexSwapTypeEnum
                  type: string
                  enum:
                    - quote_token
                    - token_quote
                    - token_token
                    - quote_quote
                  x-enum-descriptions:
                    - Quote (sell) to token (buy) swap
                    - Token (sell) to quote (buy) swap
                    - Token (sell) to token (buy) swap
                    - Quote (sell) to quote (buy) swap
                  x-parser-schema-id: <anonymous-schema-25>
                protocol:
                  x-fern-type-name: SolanaDexProtocolField
                  type: string
                  description: >-
                    Refer to [Data
                    Sources](/documentation/solana/dex/overview#data-sources)
                    for the list of supported protocols.
                  x-parser-schema-id: <anonymous-schema-26>
                wallet_address:
                  type: string
                  x-parser-schema-id: <anonymous-schema-27>
                pool_address:
                  type: string
                  x-parser-schema-id: <anonymous-schema-28>
                token_address_in:
                  type: string
                  x-parser-schema-id: <anonymous-schema-29>
                token_address_out:
                  type: string
                  x-parser-schema-id: <anonymous-schema-30>
                token_amount_in:
                  type: number
                  x-parser-schema-id: <anonymous-schema-31>
                token_amount_out:
                  type: number
                  x-parser-schema-id: <anonymous-schema-32>
                token_price_in:
                  type: number
                  x-parser-schema-id: <anonymous-schema-33>
                token_price_out:
                  type: number
                  x-parser-schema-id: <anonymous-schema-34>
                pre_token_balance_in:
                  type: number
                  x-parser-schema-id: <anonymous-schema-35>
                pre_token_balance_out:
                  type: number
                  x-parser-schema-id: <anonymous-schema-36>
                post_token_balance_in:
                  type: number
                  x-parser-schema-id: <anonymous-schema-37>
                post_token_balance_out:
                  type: number
                  x-parser-schema-id: <anonymous-schema-38>
                usd_amount_in:
                  type: number
                  x-parser-schema-id: <anonymous-schema-39>
                usd_amount_out:
                  type: number
                  x-parser-schema-id: <anonymous-schema-40>
                block_slot:
                  type: integer
                  x-parser-schema-id: <anonymous-schema-41>
                block_time:
                  type: string
                  format: date-time
                  x-parser-schema-id: <anonymous-schema-42>
                tx_hash:
                  type: string
                  x-parser-schema-id: <anonymous-schema-43>
              x-parser-schema-id: <anonymous-schema-23>
          x-parser-schema-id: <anonymous-schema-21>
        title: Wallet Swap Message
        description: Message containing the swap data for the subscribed wallets.
        example: |-
          {
            "topic": "solana.dex.swaps",
            "data": {
              "id": 1,
              "swap_type": "token_quote",
              "protocol": "orca-whirl",
              "wallet_address": "CsVdJ8WH8Q9eHSTRpwtwN3TYApm24QnLKYUMNxJ3DaED",
              "pool_address": "9wFFyRfZBdaj2EcWNxUkt4GAg6Ct8N29pbh66ziNhbn",
              "token_in": "J6pQQ3FAcJQeWPPGppWRb4nM8jU3wLyYbRrLh7feMfvd",
              "token_out": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
              "token_symbol_in": "2Z",
              "token_symbol_out": "USDC",
              "token_amount_in": 256.4115815,
              "token_amount_out": 35.323303,
              "token_price_in": 0.13773953743547926,
              "token_price_out": 0.99985023,
              "pre_token_balance_in": 2247.98704231,
              "pre_token_balance_out": 941487.708419,
              "post_token_balance_in": 1991.57546081,
              "post_token_balance_out": 941523.031722,
              "usd_amount_in": 35.31801262890969,
              "usd_amount_out": 35.323303,
              "block_slot": 382423380,
              "block_time": "2026-05-28T12:00:00Z",
              "tx_hash": "3gg6eQPa2PJ4LkGnd12EoEBHmSB3R3fr9h6MYUaaDAjeZBL5bb9paUxn521Z9d3ScWES4cVKLsexwEvo3dUoqhEs"
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: swapsSubscriptionMessage
          - id: x-parser-message-name
            value: swapsSubscriptionMessage
    bindings: []
    extensions: &ref_0
      - id: x-parser-unique-object-id
        value: solanaDexSwapsSubscription
  - &ref_1
    id: sendSolanaDexSwapsSubscription
    title: Send solana dex swaps subscription
    type: receive
    messages:
      - &ref_3
        id: subscribeSwaps
        contentType: application/json
        payload:
          - name: Subscribe Swaps
            description: Subscribe to swap 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: token_addresses
                    type: array
                    required: false
                    properties:
                      - name: item
                        type: string
                        required: false
                  - name: wallet_addresses
                    type: array
                    required: false
                    properties:
                      - name: item
                        type: string
                        required: false
                  - name: pool_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-45>
            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-46>
            params:
              type: object
              properties:
                token_addresses:
                  type: array
                  items:
                    type: string
                    x-parser-schema-id: <anonymous-schema-49>
                  x-parser-schema-id: <anonymous-schema-48>
                wallet_addresses:
                  type: array
                  items:
                    type: string
                    x-parser-schema-id: <anonymous-schema-51>
                  x-parser-schema-id: <anonymous-schema-50>
                pool_addresses:
                  type: array
                  items:
                    type: string
                    x-parser-schema-id: <anonymous-schema-53>
                  x-parser-schema-id: <anonymous-schema-52>
              x-parser-schema-id: <anonymous-schema-47>
          x-parser-schema-id: <anonymous-schema-44>
        title: Subscribe Swaps
        description: Subscribe to swap updates.
        example: |-
          {
            "method": "subscribe",
            "topic": "solana.dex.swaps",
            "params": {
              "token_addresses": [
                "J6pQQ3FAcJQeWPPGppWRb4nM8jU3wLyYbRrLh7feMfvd"
              ],
              "wallet_addresses": [
                "CsVdJ8WH8Q9eHSTRpwtwN3TYApm24QnLKYUMNxJ3DaED"
              ],
              "pool_addresses": [
                "9wFFyRfZBdaj2EcWNxUkt4GAg6Ct8N29pbh66ziNhbn"
              ]
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subscribeSwaps
          - id: x-parser-message-name
            value: subscribeSwaps
      - &ref_4
        id: unsubscribeSwaps
        contentType: application/json
        payload:
          - name: Unsubscribe Swaps
            description: Unsubscribe from swap 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-55>
            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-57>
              x-parser-schema-id: <anonymous-schema-56>
          x-parser-schema-id: <anonymous-schema-54>
        title: Unsubscribe Swaps
        description: Unsubscribe from swap updates.
        example: |-
          {
            "method": "unsubscribe",
            "topics": [
              "solana.dex.swaps"
            ]
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: unsubscribeSwaps
          - id: x-parser-message-name
            value: unsubscribeSwaps
    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: solanaDexSwapsSubscription
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: []

````