{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["tabs","tab","admonition"]},"type":"markdown"},"seo":{"title":"Listening to real-time position and order updates using Websockets","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"listening-to-real-time-position-and-order-updates-using-websockets","__idx":0},"children":["Listening to real-time position and order updates using Websockets"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"overview","__idx":1},"children":["Overview"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This WebSocket API allows you to get real-time updates about your trading orders and positions. Think of it like a live notification system - whenever something happens with your trades (like an order getting filled or a position being created), you'll get instant updates."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"prerequisites","__idx":2},"children":["Prerequisites"]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"syncId":"programming-language","size":"medium"},"children":[{"$$mdtype":"Tag","name":"div","attributes":{"label":"JavaScript","disable":false},"children":[{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Node.js"]}," (version 16 or higher) - Download from ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://nodejs.org/"},"children":["nodejs.org"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["npm"]}," or ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["yarn"]}," (comes with Node.js)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["A code editor like ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["VS Code"]}]}]}]},{"$$mdtype":"Tag","name":"div","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Python"]}," (version 3.7 or higher) - Download from ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://python.org/"},"children":["python.org"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["pip"]}," (comes with Python)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["A code editor like ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["VS Code"]}," or ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["PyCharm"]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"how-websockets-work","__idx":3},"children":["How WebSockets Work"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["WebSockets create a persistent connection between your application and our server. Unlike regular HTTP requests that you send and forget, WebSockets keep the connection open so the server can send you updates instantly when something happens."]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"Phone Call vs Letters"},"children":[{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["HTTP requests"]}," = Sending letters (you send, wait for response, send again)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["WebSockets"]}," = Phone call (continuous two-way communication)"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"quick-start","__idx":4},"children":["Quick Start"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"installation","__idx":5},"children":["Installation"]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"syncId":"programming-language","size":"medium"},"children":[{"$$mdtype":"Tag","name":"div","attributes":{"label":"JavaScript","disable":false},"children":[{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Create a new project folder:"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"mkdir trading-bot-client\ncd trading-bot-client\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"ol","attributes":{"start":2},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Initialize a new Node.js project:"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"npm init -y\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"ol","attributes":{"start":3},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Install required packages:"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"npm install socket.io-client\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"ol","attributes":{"start":4},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Create your main file:"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"touch index.js\n","lang":"bash"},"children":[]}]},{"$$mdtype":"Tag","name":"div","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Create a new project folder:"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"mkdir trading-bot-client\ncd trading-bot-client\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"ol","attributes":{"start":2},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Install required packages:"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"pip install python-socketio aiohttp\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"ol","attributes":{"start":3},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Create your main file:"]}]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"touch main.py\n","lang":"bash"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"configuration","__idx":6},"children":["Configuration"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"base-url","__idx":7},"children":["Base URL"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"wss://api.sniperoo.app\n"},"children":[]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"warning","name":"API Key Required"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You'll need an ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["API Key"]}," to connect. This is like a password that identifies your account. You should have received this when you signed up."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"complete-working-examples","__idx":8},"children":["Complete Working Examples"]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"syncId":"programming-language","size":"medium"},"children":[{"$$mdtype":"Tag","name":"div","attributes":{"label":"JavaScript","disable":false},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Create a file called ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["index.js"]},":"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const { io } = require('socket.io-client');\n\n// Your configuration\nconst API_KEY = 'YOUR_API_KEY'; // Replace with your actual API key\n\nconst SERVER_URL = 'wss://api.sniperoo.app';\n\n// Create connections to both orders and positions\nconst ordersSocket = io(`${SERVER_URL}/orders`, {\n    transports: ['websocket']\n});\n\nconst positionsSocket = io(`${SERVER_URL}/positions`, {\n    transports: ['websocket']\n});\n\n// Function to start listening for orders\nasync function subscribeToOrders() {\n    console.log('🔄 Subscribing to orders...');\n\n    const activeOrders =  await ordersSocket.emitWithAck('subscribe_orders_api', {\n        apiKey: API_KEY\n    });\n\n    console.log(`Received ${activeOrders['orders'].length} active orders`);\n    // Uncomment the line below to log the active orders\n    // console.log(JSON.stringify(activeOrders));\n\n}\n\n// Function to start listening for positions\nasync function subscribeToPositions() {\n    console.log('🔄 Subscribing to positions...');\n\n    const res = await positionsSocket.emitWithAck('subscribe_positions_api', {\n        apiKey: API_KEY\n    });\n    \n    console.log(`Received ${res['openPositions'].length} open positions`);\n    // Uncomment the line below to log the open positions\n    // console.log(JSON.stringify(res['openPositions']));\n}\n\n// Handle successful connections\nordersSocket.on('connect', () => {\n    console.log('✅ Connected to orders!');\n    subscribeToOrders();\n});\n\npositionsSocket.on('connect', () => {\n    console.log('✅ Connected to positions!');\n    subscribeToPositions();\n});\n\n// Listen for real-time order events\nordersSocket.on('order_created', (data) => {\n    const order = data.order.order;\n    console.log('🆕 New order created!');\n    console.log(`  Order #${order.id}: ${order.orderType} ${data.order.tokenExtraInfo.tokenSymbol}`);\n});\n\nordersSocket.on('order_executed', (data) => {\n    console.log('✅ Order executed!');\n    console.log(`  Order #${data.order.id} has been filled`);\n});\n\nordersSocket.on('order_cancelled', (data) => {\n    console.log('❌ Order cancelled');\n    console.log(`  Order #${data.order.id} was cancelled`);\n});\n\nordersSocket.on('order_failed', (data) => {\n    console.log('💥 Order failed');\n    console.log(`  Order #${data.order.id} failed to execute`);\n});\n\nordersSocket.on('order_expire', (data) => {\n    console.log('⏰ Order expired');\n    console.log(`  Order #${data.order.id} has expired`);\n});\n\n// Listen for real-time position events\npositionsSocket.on('position_created', (data) => {\n    const position = data.positionWithTransactions;\n    console.log('🆕 New position created!');\n    console.log(`  Position #${position.id}: ${position.tokenExtraInfo.tokenSymbol}`);\n    if (position.toastFrontendId) {\n        console.log(`  Frontend Toast ID: ${position.toastFrontendId}`);\n    }\n});\n\npositionsSocket.on('position_updated', (data) => {\n    console.log('📈 Position updated!');\n    console.log(`  Position #${data.position.id} - Type: ${data.type}`);\n    if (data.position.toastFrontendId) {\n        console.log(`  Frontend Toast ID: ${data.position.toastFrontendId}`);\n    }\n});\n\npositionsSocket.on('position_transaction_added', (data) => {\n    console.log('💰 New transaction in position!');\n    console.log(`  Position #${data.positionTransaction.positionId} - added new transaction with ID: ${data.positionTransaction.transactionId}`);\n    if (data.toastFrontendId) {\n        console.log(`  Frontend Toast ID: ${data.toastFrontendId}`);\n    }\n});\n\n// Handle disconnections\nordersSocket.on('disconnect', () => {\n    console.log('❌ Disconnected from orders');\n});\n\npositionsSocket.on('disconnect', () => {\n    console.log('❌ Disconnected from positions');\n});\n\n// Graceful shutdown\nprocess.on('SIGINT', () => {\n    console.log('\\n👋 Shutting down...');\n    ordersSocket.disconnect();\n    positionsSocket.disconnect();\n    process.exit();\n});\n\nconsole.log('🚀 Starting trading bot client...');\n\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["To run this:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"node index.js\n","lang":"bash"},"children":[]}]},{"$$mdtype":"Tag","name":"div","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Create a file called ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["main.py"]},":"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"import socketio\nimport asyncio\nimport signal\nimport sys\n\nAPI_KEY = 'YOUR_API_KEY'  # Replace with your actual API key\nSERVER_URL = 'wss://api.sniperoo.app'\n\npositions_sio = socketio.AsyncClient()\n\ndef subscribe_callback(data):\n    \"\"\"Callback for subscription confirmation which returns all open positions\"\"\"\n    print('📬 Subscription confirmed!')\n    print(f'  Received {len(data[\"openPositions\"])} open positions.')\n    # Uncomment the next line to print all open positions\n    # print(data['openPositions'])\n    for position in data['openPositions']:\n        token_info = position['tokenExtraInfo']\n        print(f'  Position #{position[\"id\"]}: {token_info[\"tokenSymbol\"]}')\n\nasync def subscribe_to_positions():\n    print('🔄 Subscribing to positions...')\n    await positions_sio.emit('subscribe_positions_api', {\n        'apiKey': API_KEY\n    }, namespace='/positions', callback=subscribe_callback)\n\n\n# Positions event handlers\n@positions_sio.event(namespace='/positions')\nasync def connect():\n    print('✅ Connected to positions!')\n    await subscribe_to_positions()\n\n\n@positions_sio.event(namespace='/positions')\nasync def disconnect():\n    print('❌ Disconnected from positions')\n\n\n@positions_sio.on('position_created', namespace='/positions')\nasync def on_position_created(data):\n    position = data['positionWithTransactions']\n    token_info = position['tokenExtraInfo']\n    print('🆕 New position created!')\n    print(f'  Position #{position[\"id\"]}: {token_info[\"tokenSymbol\"]}')\n\n\n@positions_sio.on('position_updated', namespace='/positions')\nasync def on_position_updated(data):\n    print('📈 Position updated!')\n    print(f'  Position #{data[\"position\"][\"id\"]} - Type: {data[\"type\"]}')\n\n\n@positions_sio.on('position_transaction_added', namespace='/positions')\nasync def on_position_transaction_added(data):\n    print('💰 New transaction in position!')\n    transaction = data['positionTransaction']\n    print(f'  Position #{transaction[\"positionId\"]} - added new transaction with ID: {transaction[\"transactionId\"]}')\n\n\nasync def main():\n    \"\"\"Main function to run the client\"\"\"\n    try:\n        print('🚀 Starting trading bot client...')\n\n        await positions_sio.connect(SERVER_URL)\n        await positions_sio.wait()\n\n    except Exception as e:\n        print(f'❌ Error: {e}')\n    finally:\n        await cleanup()\n\n\nasync def cleanup():\n    \"\"\"Clean shutdown\"\"\"\n    print('\\n👋 Shutting down...')\n    await positions_sio.disconnect()\n\n\ndef signal_handler(sig, frame):\n    \"\"\"Handle Ctrl+C gracefully\"\"\"\n    print('\\n👋 Received shutdown signal...')\n    asyncio.create_task(cleanup())\n    sys.exit(0)\n\n\nif __name__ == '__main__':\n    # Register signal handler for graceful shutdown\n    signal.signal(signal.SIGINT, signal_handler)\n    signal.signal(signal.SIGTERM, signal_handler)\n\n    # Run the main function\n    asyncio.run(main())\n\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["To run this:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"python main.py\n","lang":"bash"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"api-reference","__idx":9},"children":["API Reference"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"namespaces","__idx":10},"children":["Namespaces"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The WebSocket API is organized into two main namespaces:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Namespace"},"children":["Namespace"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Methods & Events"},"children":["Methods & Events"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/orders"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["For order-related updates"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/websockets/order-subscribtion"},"children":["Link"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/positions"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["For position-related updates"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/websockets/order-subscribtion"},"children":["Link"]}]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"authentication","__idx":11},"children":["Authentication"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["All API subscriptions require a valid API key included in the subscription payload."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"troubleshooting","__idx":12},"children":["Troubleshooting"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Connection Issues"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["\"Connection refused\""]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Check your server URL is correct"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Make sure the server is running"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Verify you're using the right protocol (ws:// or wss://)"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Authentication Issues"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["\"please_refresh\" message"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Your client is outdated, restart your application"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Make sure you're sending the correct payload format with apiKey"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["No events received"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Check your API key is valid"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Verify you're subscribed to the right namespace"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Make sure your account has orders/positions"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Environment Issues"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Python: \"Module not found\""]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Run ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["pip install python-socketio aiohttp"]}," if you haven't installed the packages yet"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["JavaScript: \"Cannot find module\""]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Run ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["npm install socket.io-client"]}," in your project folder"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"next-steps","__idx":13},"children":["Next Steps"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Start Simple"]},": Run the basic examples first to see if you get connected"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Add Your Logic"]},": Once connected, add your own code to handle the events"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Error Handling"]},": Add proper error handling for production use"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Logging"]},": Consider adding file logging to track what happens"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Database"]},": Store the events in a database for analysis"]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"Remember"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Replace the placeholder values (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["API_KEY"]},") with your actual value before running the examples."]}]}]},"headings":[{"value":"Listening to real-time position and order updates using Websockets","id":"listening-to-real-time-position-and-order-updates-using-websockets","depth":1},{"value":"Overview","id":"overview","depth":2},{"value":"Prerequisites","id":"prerequisites","depth":2},{"value":"How WebSockets Work","id":"how-websockets-work","depth":2},{"value":"Quick Start","id":"quick-start","depth":2},{"value":"Installation","id":"installation","depth":3},{"value":"Configuration","id":"configuration","depth":3},{"value":"Base URL","id":"base-url","depth":4},{"value":"Complete Working Examples","id":"complete-working-examples","depth":2},{"value":"API Reference","id":"api-reference","depth":2},{"value":"Namespaces","id":"namespaces","depth":3},{"value":"Authentication","id":"authentication","depth":3},{"value":"Troubleshooting","id":"troubleshooting","depth":3},{"value":"Next Steps","id":"next-steps","depth":2}],"frontmatter":{"seo":{"title":"Listening to real-time position and order updates using Websockets"}},"lastModified":"2026-01-18T19:18:00.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/websocket","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}