LogoLogo
Join DiscordFollow on XBridge FundsLong $BERA
  • Doc Bros v1
    • Overview
    • Key Features
      • Speed & Liquidity is Key
      • Bropetual Markets
      • A Hub for Berachain DeFi
    • Proof-of-Liquidity
      • Reward Vault
    • Power of Points
    • Partners & Integrations
    • Campaigns
      • bro.trade Em Up
  • bullish bros
    • SuperBros NFT
  • Technicals
    • What is Proof-of-Liquidity?
    • One-Click Trading
    • Funding Rates
  • Liquidations & Insurance Fund
  • Vertex Edge Sequencer
  • Fees
  • PnL Settlements
  • Withdrawals
  • Pricing (Oracles)
  • links & resources
    • bro.trade Links
      • Website
      • Trade Bropetuals
      • Discord
      • X (Twitter)
      • Medium
      • Swap on OogaBooga
    • Berachain Links
      • Berachain.com
      • Official Bridge
      • BeraHub
      • Berascan
      • Bera Discord
      • Berachain X (Twitter)
      • Berachain Docs
    • FAQ
  • developer bros
    • API
      • Gateway
        • Executes
          • Place Order
          • Cancel Order
          • Cancel and Place
          • Cancel Product Order
          • Withdraw Colleteral
          • Transfer Quote
          • Liquidate Subaccount
          • Mint LP
          • Burn LP
          • Link Signer
        • Queries
          • All Products
          • Contracts
          • Fee Rates
          • Health Groups
          • Insurance
          • Linked Signer
          • Market Liquidity
          • Market Prices
          • Max Lp Mintable
          • Max Order Size
          • Max Withdrawable
          • Min Deposit Rates
          • Nonces
          • Order
          • Orders
          • Status
          • Subaccount Info
          • Symbols
        • Signing
          • Examples
          • Q A
      • Subscriptions
        • Authentication
        • Streams
        • Events
        • Rate Limits
      • Archive (indexer)
        • Candlesticks
        • Events
        • Funding Rate
        • Interest Funding Payments
        • Linked Signer Rate Limit
        • Liquidation Feed
        • Maker Statistics
        • Market Snapshots
        • Matches
        • Merkle Proofs
        • Oracle Price
        • Orders
        • Perp Prices
        • Product Snapshots
        • Rewards
        • Signatures
        • Subaccounts
        • Summary
        • HONEY Price
      • Trigger
        • Executes
          • Place Order
          • Cancel Orders
          • Cancel Product Orders
        • Queries
          • List Trigger Orders
      • V2
        • Apr
        • Assets
        • Contracts
        • Orderbook
        • Pairs
        • Tickers
        • Trades
      • Rate limits
      • Errors
      • Symbols
      • Depositing
      • Withdrawing (on-chain)
      • Integrate via Smart Contracts
      • Definitions / Formulas
    • On-Chain Contracts
Powered by GitBook
On this page
  • Available Streams
  • Subscribing to a stream
  • Unsubscribing
  • Listing subscribed streams
  1. developer bros
  2. API
  3. Subscriptions

Streams

Available Streams

See below the available streams you can subscribe to:

pub enum StreamSubscription {
    OrderUpdate { product_id: u32, subaccount: H256 },
    Trade { product_id: u32 },
    BestBidOffer { product_id: u32 },
    Fill { product_id: u32, subaccount: H256 },
    PositionChange { product_id: u32, subaccount: H256},
    BookDepth { product_id: u32 },
}

Subscribing to a stream

Connect

WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]

Message

Requires Authentication: Yes.

{
  "method": "subscribe",
  "stream": {
    "type": "order_update",
    "subaccount": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
    "product_id": 1
  },
  "id": 10
}

Connect

WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]

Message

Requires Authentication: No.

{
  "method": "subscribe",
  "stream": {
    "type": "trade",
    "product_id": 0
  },
  "id": 10
}

Connect

WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]

Message

Requires Authentication: No.

{
  "method": "subscribe",
  "stream": {
    "type": "best_bid_offer",
    "product_id": 0
  },
  "id": 10
}

Connect

WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]

Message

Requires Authentication: No.

{
  "method": "subscribe",
  "stream": {
    "type": "fill",
    "product_id": 0,
    "subaccount": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000"
  },
  "id": 10
}

Connect

WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]

Message

Requires Authentication: No.

{
  "method": "subscribe",
  "stream": {
    "type": "position_change",
    "product_id": 0,
    "subaccount": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000"
  },
  "id": 10
}

Connect

WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]

Message

Requires Authentication: No.

{
  "method": "subscribe",
  "stream": {
    "type": "book_depth",
    "product_id": 0
  },
  "id": 10
}

Response

{
  "result": null,
  "id": 10
}

Unsubscribing

Connect

WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]

Message

{
  "method": "unsubscribe",
  "stream": {
    "type": "order_update",
    "subaccount": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
    "product_id": 1
  },
  "id": 10
}

Connect

WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]

Message

{
  "method": "unsubscribe",
  "stream": {
    "type": "trade",
    "product_id": 0
  },
  "id": 10
}

Connect

WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]

Message

{
  "method": "unsubscribe",
  "stream": {
    "type": "best_bid_offer",
    "product_id": 0
  },
  "id": 10
}

Connect

WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]

Message

{
  "method": "unsubscribe",
  "stream": {
    "type": "fill",
    "product_id": 0,
    "subaccount": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000"
  },
  "id": 10
}

Connect

WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]

Message

{
  "method": "unsubscribe",
  "stream": {
    "type": "position_change",
    "product_id": 0,
    "subaccount": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000"
  },
  "id": 10
}

Connect

WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]

Message

{
  "method": "unsubscribe",
  "stream": {
    "type": "book_depth",
    "product_id": 0,
  },
  "id": 10
}

Response

{
  "result": null,
  "id": 10
}

Listing subscribed streams

{
  "method": "list",
  "id": 10
}

Response

{
  "result": [
    {
      "type": "default"
    },
    {
      "type": "trade",
      "product_id": 0
    }
  ],
  "id": 10
}
PreviousAuthenticationNextEvents

Last updated 3 months ago