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

# Market Pair Stream (Legacy)

> Real-time WebSocket stream for pair statistics and onchain trades (deprecated, use Market Details Stream)

<Tip> This endpoint is only available to Growth and Enterprise plans. </Tip>

### Endpoint details

* URL: wss\://api.mobula.io
* Message (string):

<Note>
  This endpoint counts toward the shared tracked market limit enforced per organization, or per customer when no organization is attached. Across eligible WebSocket payloads, a single organization/customer can track at most **50 unique markets**. If you need a higher limit, reach out to the Mobula team.
</Note>

```json theme={null}
{
  "type": "pair",
  "authorization": "YOUR-API-KEY",
  "payload": {
    "address": "0x059fd118aa8988f5e97b66fcd489765111e069c9",
    "blockchain": "1",
  }
}
```

Parameters:

* `address`: the address of the pair
* `blockchain`: the blockchain of the pair (blockchain ID or name)
* `asset`: you can also query via the asset pattern (asset name or contract) instead of the address - it will use the largest trading pair of the asset (by volume & liquidity)
* `subscriptionId (optional)`: A unique ID for your WebSocket connection. If not provided, it is automatically generated by the server.
* `subscriptionTracking (optional, default: false)`: Set this to true to include the subscriptionId and additional connection details in the response logs. Helpful for debugging and managing multiple active streams.

### Data model

Data reponses includes:

```json theme={null}
{
    "pair": "0xd7efdee04e508502bdc666f67f3d9b006c20318d",
    "date": 1742777351000,
    "token_price": 0.022998242791244194,
    "token_price_vs": 623.3316960282402,
    "token_amount": 3467.7781520526946,
    "token_amount_vs": 0.1280676197032033,
    "token_amount_usd": 79.6432911989217,
    "type": "buy",
    "operation": "regular",
    "blockchain": "BNB Smart Chain (BEP20)",
    "hash": "0xa06d71d5d46544e74f870147120ac2706d5c70ff893c993e689c5e713434ca54",
    "sender": "0x74bf7407dd5fa033e51120f87246ace3b75b32d0",
    "token_amount_raw": "3467778152052694767214",
    "token_amount_raw_vs": "128067619703203291",
    "labels": ["proTrader"],
    "walletMetadata": {
        "entityName": "Wintermute",
        "entityLogo": "https://example.com/wintermute.png",
        "entityLabels": ["market-maker"],
        "entityType": "market_maker",
        "entityDescription": "Wintermute is a leading global algorithmic trading firm",
        "entityTwitter": "https://twitter.com/wintermute_t",
        "entityWebsite": "https://wintermute.com",
        "entityGithub": null,
        "entityDiscord": null,
        "entityTelegram": null
    },
    "preBalanceBaseToken": "5000000000000000000000",
    "preBalanceQuoteToken": "2000000000000000000",
    "postBalanceBaseToken": "4000000000000000000000",
    "postBalanceQuoteToken": "2400000000000000000",
    "swapRecipient": null,
    "platform": "axiom",
    "platformMetadata": {
        "id": "axiom",
        "name": "Axiom",
        "logo": "https://example.com/axiom.png"
    },
    "pairData": {
        "token0": {
            "address": "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",
            "price": 624.6568794710992,
            "priceToken": 27140.717120413887,
            "priceTokenString": "27140.71712041388673242181539535522461",
            "approximateReserveUSD": 446918.91533437266,
            "approximateReserveTokenRaw": "715463048630444359680",
            "approximateReserveToken": 715.4630486304444,
            "symbol": "BNB",
            "name": "BNB",
            "id": 100001566,
            "decimals": 18,
            "totalSupply": 145887575.79,
            "circulatingSupply": 146085867,
            "logo": "https://coin-images.coingecko.com/coins/images/825/large/bnb-icon2_2x.png?1696501970",
            "chainId": "evm:56"
        },
        "token1": {
            "address": "0xcaae2a2f939f51d97cdfa9a86e79e3f085b799f3",
            "price": 0.023019431518665583,
            "priceToken": 0.00003684501023179856,
            "priceTokenString": "0.00003684501023179855976356564251",
            "approximateReserveUSD": 446995.46962998016,
            "approximateReserveTokenRaw": "19418180212987818403692544",
            "approximateReserveToken": 19418180.212987818,
            "symbol": "TUT",
            "name": "Tutorial",
            "logo": "https://mobulastorage.blob.core.windows.net/mobula-assets/assets/logos/a7c7ace09385c833f553c4c488cd86c47368d27d5d31b79b5ae319bb9779f371.png",
            "id": 102503533,
            "decimals": 18,
            "totalSupply": 949999985.5435216,
            "circulatingSupply": 954616549,
            "chainId": "evm:56"
        },
        "volume24h": 1728384.3736568224,
        "liquidity": 893914.3849643528,
        "blockchain": "BNB Smart Chain (BEP20)",
        "address": "0xd7efdee04e508502bdc666f67f3d9b006c20318d",
        "createdAt": "2025-02-10T00:28:09.000Z",
        "type": "uniswap-v2",
        "baseToken": "token1",
        "exchange": {
            "name": "Unknown",
            "logo": "https://unknown.png"
        },
        "factory": "0xca143ce32fe78f1f7019d7d551a6402fc5350c73",
        "quoteToken": "token0",
        "price": 0.023019431518665583,
        "priceToken": 0.00003684501023179856,
        "priceTokenString": "0.00003684501023179855976356564251",
        "trades_1min": 8,
        "buys_1min": 3,
        "sells_1min": 5,
        "volume_1min": 2619.8813929843805,
        "buy_volume_1min": 150.36904615686325,
        "sell_volume_1min": 2469.512346827517,
        "sellers_1min": 5,
        "buyers_1min": 2,
        "traders_1min": 7,
        "trades_5min": 53,
        "buys_5min": 28,
        "sells_5min": 25,
        "volume_5min": 29378.288306102957,
        "buy_volume_5min": 14069.32399601281,
        "sell_volume_5min": 15308.96431009015,
        "sellers_5min": 19,
        "buyers_5min": 23,
        "traders_5min": 40,
        "trades_15min": 108,
        "buys_15min": 63,
        "sells_15min": 45,
        "volume_15min": 45378.73180595561,
        "buy_volume_15min": 23127.93650312149,
        "sell_volume_15min": 22250.79530283417,
        "traders_15min": 59,
        "buyers_15min": 35,
        "sellers_15min": 31,
        "trades_1h": 384,
        "buys_1h": 205,
        "sells_1h": 179,
        "buyers_1h": 87,
        "sellers_1h": 91,
        "traders_1h": 154,
        "volume_1h": 143670.0329625482,
        "buy_volume_1h": 66490.87256288968,
        "sell_volume_1h": 77179.16039965858,
        "trades_4h": 1098,
        "buys_4h": 552,
        "sells_4h": 546,
        "buyers_4h": 221,
        "sellers_4h": 214,
        "traders_4h": 349,
        "volume_4h": 426118.2646660652,
        "buy_volume_4h": 205326.35989735243,
        "sell_volume_4h": 220791.90476871288,
        "volume_12h": 1877912.2929574074,
        "buy_volume_12h": 942733.4245817509,
        "sell_volume_12h": 935178.8683756567,
        "traders_12h": 1110,
        "buyers_12h": 767,
        "sellers_12h": 670,
        "trades_12h": 4045,
        "buys_12h": 2058,
        "sells_12h": 1983,
        "trades_24h": 8093,
        "buys_24h": 4112,
        "sells_24h": 3975,
        "volume_24h": 4020063.8406410096,
        "buy_volume_24h": 2004959.2103884632,
        "sell_volume_24h": 2015104.6302525462,
        "traders_24h": 1901,
        "buyers_24h": 1259,
        "sellers_24h": 1226,
        "pool_addr": 1.2327823090843993e+48,
        "price_change_1min": 0.2828894379890179,
        "price_change_5min": 0.3531336244666691,
        "price_change_1h": -3.4947089305239842,
        "price_change_4h": -7.046475968298424,
        "price_change_12h": 4.617155205058722,
        "price_change_24h": -4.426061897594044,
        "largestPool": {
            "chainId": "evm:56",
            "address": "0xd7efdee04e508502bdc666f67f3d9b006c20318d",
            "marketDepth": {
                "token0Up": 3.5507070221341768,
                "token1Up": 96849.37991601102,
                "token0Down": 3.60437066379286,
                "token1Down": 97334.84959259078
            },
            "type": "uniswap-v2",
            "factory": "0xca143ce32fe78f1f7019d7d551a6402fc5350c73",
            "token0": "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",
            "token1": "0xcaae2a2f939f51d97cdfa9a86e79e3f085b799f3",
            "reserve0": "715463048630444434378",
            "reserve1": "19418180212987816026732272",
            "price": 27140.717120413887,
            "volume24hUSD": 1728384.3736568224,
            "totalVolumeUSD": 30728416.145732835,
            "createdAt": 1739147289000,
            "extra": {
                "isStable": false
            }
        },
        "lastStatsFetchTime": 1742777351721
    }
}
```

### Optional Fields Behavior

<Warning>
  **Fields may be entirely absent, not `null`**: The `labels` and `walletMetadata` fields are **conditionally included** — when there is no data, the field is **completely omitted** from the JSON payload rather than being set to `null` or an empty value.

  Always use optional chaining or check for field existence:

  ```typescript theme={null}
  const labels = data.labels ?? [];
  const entityName = data.walletMetadata?.entityName ?? null;
  ```
</Warning>

### Connection Keepalive (Ping/Pong)

To maintain active WebSocket connections and prevent timeouts, you can use the ping/pong mechanism:

**Send ping:**

```json theme={null}
{"event":"ping"}
```

**Receive pong:**
The server will respond with a pong message to confirm the connection is active.

<Tip>Use ping messages periodically (every 30-60 seconds) to keep long-lived connections alive.</Tip>

### Unsubscribing from the stream

You can unsubscribe from the stream by sending an unsubscribe message:

* Unsubscribe from all active streams:
  Send an empty payload as shown above.
  This will terminate all active subscriptions associated with the current WebSocket connection.

```typescript theme={null}

{
  "type": "unsubscribe", 
  "authorization": "API-KEY",
  "payload": {},
};
 
```

* Unsubscribe from a specific subscriptionId:
  Include the relevant subscriptionId in the payload:

```typescript theme={null}

{
  "type": "unsubscribe",
  "authorization": "API-KEY",
  "payload": {
	  "subscriptionId": "your-subscription-id"
  }
};
```

<Note>If you did not provide a subscriptionId when subscribing, one is generated automatically. To retrieve it, set **"subscriptionTracking": "true"** in the subscription payload. Otherwise, it will not be returned in the response.</Note>

* Unsubscribe from a specific stream type:
  To unsubscribe all streams of a given type (e.g., all "pair", "market" streams):

```typescript theme={null}
{
  "type": "unsubscribe",
  "authorization": "API-KEY",
  "payload": {
    "type": "pair"
  }
}
```

<CardGroup>
  <Card title="Support" icon="Telegram" href="https://t.me/mobuladevelopers?start=Mobula_API_Support_Key">
    Telegram
  </Card>

  <Card title="Support" icon="Slack" href="https://join.slack.com/t/mobulaapi/shared_invite/zt-29zrrpjnl-I0tyD73sy7zKy8q~KLL3Ug">
    Slack
  </Card>

  <Card title="Need help?" icon="envelope" href="mailto:contact@mobulalabs.org">
    Email
  </Card>
</CardGroup>
