Websockets for Order Data (DRAFT)

Subscribe to real-time market data and order updates via websockets.

⚠️

DRAFT

The websocket feature is currently in beta and the implementation may change.

Dinari's Websocket API provides real-time market data and order updates, allowing you to receive instant pricing and quotes as well as notifications about order status changes, fulfillments, and other order-related events without polling the REST API.

Key Features

  • Real-time Updates: Receive order status changes as they happen
  • Efficient: Eliminate the need for constant polling of the REST API
  • Scalable: Handle multiple subscriptions per connection
  • Reliable: Automatic reconnection and message acknowledgments

Usage

EnvironmentHostname
Productionwss://ws.api.dinari.com
Sandboxwss://ws.api.sandbox.dinari.com (coming soon)

Authentication

WebSocket connections require authentication using your API credentials. Please use the correct credentials for your environment (sandbox or production).

Authentication Request

{
  "command": "authenticate",
  "data": {
    "api_key": "your api key",
    "api_secret": "your api key secret"
  }
}

Response

{
  "event_type": "authentication",
  "data": {
    "status": "authenticated",
    "entity_id": "0197422f-d3cb-7050-ae5f-e5b9473f067b"
  }
}

Market Data

Available Data TypesDescription
stock_dfn_l2DFN Level 2 order book data
stock_dfn_quotesDFN top-of-book quotes

Subscription

Subscribe to market data with the market_data_subscribe command. This command may be reissued at anytime to update the subscription. All requested stock_ids must be listed.

stock_ids can be fetched from the 🔗 Get Stocks API endpoint.

{
  "command": "market_data_subscribe",
  "data": {
    "stock_dfn_l2": ["stock_id or * for all"], 
    "stock_dfn_quotes": ["stock_id or * for all"]
  }
}

Data Types

Level 2 Data

{
  "event_type": "market_data:l2_data",
  "data": {
    "Symbol": "AAPL",
    "MaxDepth": 30,
    "Bids": [
      {
        "Price": 0.01,
        "Size": 150,
        "Depth": 1,
        "NumOrders": 1
      }
    ],
    "Asks": [],
    "LastMatch": null,
    "Timestamp": "2025-12-12T17:54:44.382483808Z",
    "SchemaVersion": "1.0.0"
  }
}

DFN Quote

{
  "event_type": "market_data:dfn_quote",
  "data": {
    "Symbol": "AAPL",
    "BidExchange": "DFN",
    "BidPrice": 0.01,
    "BidSize": 150,
    "AskExchange": "DFN",
    "AskPrice": 0,
    "AskSize": 0,
    "TimeStamp": "2025-12-11T17:17:54.141119146Z",
    "Conditions": null,
    "Tape": ""
  }
}

Order Data

Use the order_data_subscribe command with an empty data map to subscribe to real-time updates for your customer's orders account.

⚠️

Cursor support coming soon

Subscription Request

{
  "command": "order_data_subscribe",
  "data": {}
}

Response

{
  "event_type": "order_data_subscription",
  "data": {
    "status": "subscribed"
  }
}

Data Types

Order Request

{
  "event_type": "order_data",
  "data": {
    "entity_id": "0197422f-d3cb-7050-ae5f-e5b9473f067b",
    "order_request": {
      "id": "019b1384-2fc9-7485-ab0b-01eefe126151",
      "account_id": "0198862c-61ec-7375-bd98-4e306ab177c9",
      "recipient_account_id": "0198862c-61ec-7375-bd98-4e306ab177c9",
      "status": "QUOTED",
      "order_side": "SELL",
      "order_type": "LIMIT",
      "order_tif": "DAY",
      "order_id": null,
      "created_dt": "2025-12-12T17:03:08.724979Z"
    }
  }
}

Order Data

{
  "event_type": "order_data",
  "data": {
    "entity_id": "0197422f-d3cb-7050-ae5f-e5b9473f067b",
    "order": {
      "id": "019b1385-3b4b-711e-b039-070ac42ea918",
      "status": "SUBMITTED",
      "order_contract_address": "0x1f96D1656a6500e526E92B19EAA894A6A7647ABa",
      "order_transaction_hash": "0x0e36a82c5fe36075f2badc1b787ffc929a317a8ce02200ef4c72a95e46c70e29",
      "cancel_transaction_hash": null,
      "order_side": "SELL",
      "order_type": "LIMIT",
      "order_tif": "DAY",
      "order_request_id": "019b1384-2fc9-7485-ab0b-01eefe126151",
      "stock_id": "0196d545-d8a8-7210-8cd1-a49e82c31e53",
      "asset_token_quantity": 0.001000000000000000,
      "payment_token_quantity": 0,
      "payment_token": "0xd54c40022500D88BbE0262FA9ffdf3D9921B24e8",
      "limit_price": 100.000000000000000000,
      "created_dt": "2025-12-12T17:04:17.223274Z",
      "chain_id": "eip155:202110",
      "asset_token": "0x83EBfbC73e60c45380426acc66725405A4EF7D61",
      "fees": 0
    }
  }
}

Order Fulfillment

{
  "event_type": "order_data",
  "data": {
    "entity_id": "0197422f-d3cb-7050-ae5f-e5b9473f067b",
    "order_fulfillment": {
      "id": "019b1385-3b4b-711e-b039-070ac42ea918",
      "order_id": "019b1385-3b4b-711e-b039-070ac42ea918",
      "chain_id": "eip155:202110",
      "transaction_hash": "0xc488f4fcc8ee5163766935dfba7cf6b50a862b67eeeda7e01b6d5dab59746c2f",
      "transaction_dt": "2025-12-12T17:04:17.223274Z",
      "asset_token_filled": 0,
      "asset_token_spent": 0.001,
      "payment_token_filled": 0.279014000000000000,
      "payment_token_spent": 0,
      "payment_token_fee": 0.201395070000000000
    }
  }
}