{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Hibachi API","description":"The first provable exchange","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":""},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"account-websocket-api"},"children":["Account Websocket API"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This websocket endpoint is used to get realtime account updates."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"authorization"},"children":["Authorization"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To use the trade websocket api you must connect with the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Authorization"]}," header set to your ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["apikey"]},"."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"\"Authorization\": \"YOURAPIKEY\"\n"},"children":[]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Connect websocket to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://api.hibachi.xyz/ws/account?accountId={YOUR_ACCOUNT_ID}"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"usage"},"children":["Usage"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You should start with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["stream.start"]},", the server will respond with a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["listen_key"]},", then you need to do ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["stream.ping"]}," with the same ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["listen_key"]}," otherwise it will expire after ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["10 seconds"]},"."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["stream.stop"]}," to stop the stream."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["id"]}," in the packet is your unique identifier for the request, the server will respond with the same ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["id"]},"."]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"the-server-will-send-you-these-updates"},"children":["The server will send you these updates:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Order: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ORDER_CREATED"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ORDER_UPDATED"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ORDER_CANCELED"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Balance: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["balance_update"]}," (deposit, withdrawal and trades)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Trade: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["trade_update"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["position_update"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can see the examples in \"(Events from Server)\" under \"Saved messages\"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Supported Methods"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["stream.start"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["stream.ping"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["stream.stop"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"stream-start"},"children":["Stream Start"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Request Body"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n    \"id\": 123,\n    \"method\": \"stream.start\",\n    \"params\": {\n        \"accountId\": \"<accountId>\"\n    }\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Response Body"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n    \"id\": 123,\n    \"result\": {\n        \"accountSnapshot\": {\n            \"account_id\": 128,\n            \"balance\": \"910.997790\",\n            \"positions\": [\n                {\n                    \"direction\": \"Long\",\n                    \"entryNotional\": \"10.003168\",\n                    \"markPrice\": \"3917.478177\",\n                    \"notionalValue\": \"10.000146\",\n                    \"openPrice\": \"3918.661809\",\n                    \"quantity\": \"0.002552700\",\n                    \"symbol\": \"ETH/USDT-P\",\n                    \"unrealizedFundingPnl\": \"0.000000\",\n                    \"unrealizedTradingPnl\": \"-0.003021\"\n                }\n            ]\n        },\n        \"listenKey\": \"128-di7hdiewgt4symwnfp4tfhodzzn774skyi\"\n    },\n    \"status\": 200\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"stream-ping"},"children":["Stream Ping"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Request Body"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n    \"id\": 123,\n    \"method\": \"stream.ping\",\n    \"params\": {\n        \"accountId\": \"<accountId>\",\n        \"listenKey\": \"<accountId>-zzwuxbp63bfpztkghoradc5blgk7rgumoy\"\n    },\n    \"timestamp\": 1234567\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Response Body"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n    \"id\": 123,\n    \"status\": 200\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"stream-stop"},"children":["Stream Stop"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Request Body"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n    \"id\": 123,\n    \"method\": \"stream.stop\",\n    \"params\": {\n        \"accountId\": \"<accountId>\",\n        \"listenKey\": \"<accountId>-jiqu3ig4ur23ti2lksrgjjoruyuwr73i4u\"\n    },\n    \"timestamp\": 1234567\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Response Body"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n    \"id\": 123,\n    \"status\": 200\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"events"},"children":["Events"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Examples of messages sent by server"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"[\n    {\n        \"account\": \"<accountId>\",\n        \"data\": {\n            \"orderId\": 578745035695106058,\n            \"price\": \"69762.24077\",\n            \"quantity\": \"0.1288935088\",\n            \"side\": \"BID\",\n            \"symbol\": \"BTC/USDT-P\",\n            \"timestamp\": 1712781049,\n            \"nonce\": 1714701600000000\n        },\n        \"event\": \"order_creation\"\n    },\n    {\n        \"account\": \"<accountId>\",\n        \"data\": {\n            \"orderId\": 578745035695106058,\n            \"price\": \"69762.24077\",\n            \"quantity\": \"0.1288935088\",\n            \"side\": \"BID\",\n            \"symbol\": \"BTC/USDT-P\",\n            \"timestamp\": 1712781049,\n            \"executed_quantity\": \"0.096987527\"\n        },\n        \"event\": \"order_update\"\n    },\n    {\n        \"account\": \"<accountId>\",\n        \"data\": {\n            \"orderId\": 578745034376521742,\n            \"side\": \"ASK\",\n            \"symbol\": \"DDNG/USDT-P\",\n            \"timestamp\": 1712781045\n        },\n        \"event\": \"order_cancellation\"\n    },\n    {\n        \"account\": \"<accountId>\",\n        \"data\": {\n            \"depositQuantity\": \"123.000000\"\n        },\n        \"event\": \"balance_update\"\n    },\n    {\n        \"account\": \"<accountId>\",\n        \"data\": {\n            \"withdrawQuantity\": \"123.000000\"\n        },\n        \"event\": \"balance_update\"\n    },\n    {\n        \"account\": \"<accountId>\",\n        \"data\": {\n            \"updatedCollateralBalance\": \"1234.000000\"\n        },\n        \"event\": \"balance_update\"\n    },\n    {\n        \"account\": \"<accountId>\",\n        \"data\": {\n            \"isTaker\": true,\n            \"orderId\": \"582871374158365696\",\n            \"orderType\": \"Limit\",\n            \"price\": \"2345.000000\",\n            \"quantity\": \"0.000421590\",\n            \"realizedPnl\": \"0.022107\",\n            \"side\": \"BID\",\n            \"symbol\": \"ETH/USDT-P\",\n            \"timestamp\": 1728526563\n        },\n        \"event\": \"trade_update\"\n    },\n    {\n        \"account\": \"<accountId>\",\n        \"data\": {\n            \"symbol\": \"BTC/USDT-P\",\n            \"updatedPosition\": {\n                \"direction\": \"Closed\",\n                \"entryNotional\": \"0.000000\",\n                \"quantity\": \"0.000000\"\n            }\n        },\n        \"event\": \"position_update\"\n    },\n    {\n        \"account\": \"<accountId>\",\n        \"data\": {\n            \"symbol\": \"HFT/USDT-P\",\n            \"updatedPosition\": {\n                \"direction\": \"Long\",\n                \"entryNotional\": \"11926.363515\",\n                \"quantity\": \"28179.202190\"\n            }\n        },\n        \"event\": \"position_update\"\n    },\n    {\n        \"account\": \"<accountId>\",\n        \"data\": {\n            \"indexPrice\": \"61097.00801\",\n            \"quantity\": \"0.5580484584\",\n            \"settledAmount\": \"0.8618780736305764\",\n            \"side\": \"Buy\",\n            \"symbol\": \"BTC/USDT-P\",\n            \"timestamp\": 1719446400,\n            \"unrealizedFunding\": \"-734.608435\"\n        },\n        \"event\": \"funding_settlement\"\n    },\n    {\n        \"account\": \"<accountId>\",\n        \"event\": \"account_created\",\n        \"data\": {\n            \"ledgerAccountId\": 123,\n            \"timestamp\": 123456789\n        }\n    },\n    {\n        \"event\": \"deposit_status_update\",\n        \"account\": \"<accountId>\",\n        \"data\": {\n            \"depositQuantity\": 1234,\n            \"depositTxnHash\": \"0xabcdef\",\n            \"etaTsSecond\": 10,\n            \"status\": \"Processing/Accepted/Rejected/Succeeded\",\n            \"note\": \"Note\"\n        }\n    },\n    {\n        \"account\": 2,\n        \"data\": {\n            \"matchedQuantity\": \"0.000000004\",\n            \"orderId\": \"3\",\n            \"orderType\": \"MarketOrder\",\n            \"remainingQuantity\": \"0.000000005\",\n            \"symbol\": \"ETH/USDT-P\",\n            \"timestamp\": 123456789\n        },\n        \"event\": \"order_not_fully_matched\"\n    },\n    {\n        \"event\": \"order_request_rejected\",\n        \"account\": \"<accountId>\",\n        \"data\": {\n            \"orderId\": 1234,\n            \"error\": \"RiskLimitExceeded\",\n            \"requestType\": \"Update/New\"\n        }\n    },\n    {\n        \"event\": \"stream_expired\",\n        \"account\": \"<accountId>\",\n        \"params\": {\n            \"listenKey\": \"123\",\n            \"timestampMs\": 123456789\n        }\n    },\n    {\n        \"event\": \"transfer_status_update\",\n        \"sourceAccountId\": \"<accountId>\",\n        \"data\": {\n            \"transferQuantity\": \"1234\",\n            \"destAccountPublicKey\": \"0xabcdef\",\n            \"status\": \"Processing/Accepted/Rejected/Succeeded\",\n            \"isInstantWithdrawal\": true,\n            \"note\": \"Note\"\n        }\n    },\n    {\n        \"event\": \"withdraw_rejection\",\n        \"account\": \"<accountId>\",\n        \"data\": {\n            \"withdraw_quantity\": 1234,\n            \"timestamp\": 123456789\n        }\n    },\n    {\n        \"event\": \"withdraw_status_update\",\n        \"account\": \"<accountId>\",\n        \"data\": {\n            \"withdrawQuantity\": 1234,\n            \"withdrawAddress\": \"0xabcdef\",\n            \"etaTsSecond\": 10,\n            \"status\": \"Processing/Accepted/Rejected/Succeeded\",\n            \"note\": \"Note\"\n        }\n    },\n    {\n        \"event\": \"order_matched\",\n        \"account\": \"<accountId>\",\n        \"data\": {\n            \"orderId\": 1234,\n            \"symbol\": \"ETH/USDT-P\",\n            \"orderType\": \"LIMIT\",\n            \"matchedQuantity\": \"1234\",\n            \"remainingQuantity\": \"1234\",\n            \"timestamp\": 123456789,\n            \"nonce\": 1714701600000000\n        }\n    },\n    {\n        \"event\": \"trade_rejected\",\n        \"account\": \"<accountId>\",\n        \"data\": {\n            \"symbol\": \"ETH/USDT-P\",\n            \"orderId\": 1234,\n            \"quantity\": \"1234\",\n            \"timestamp\": 123456789\n        }\n    }\n]\n","lang":"json"},"children":[]}]},"headings":[{"value":"","id":null,"depth":1},{"value":"Account Websocket API","id":"account-websocket-api","depth":1},{"value":"Authorization","id":"authorization","depth":2},{"value":"Usage","id":"usage","depth":2},{"value":"The server will send you these updates:","id":"the-server-will-send-you-these-updates","depth":4},{"value":"Stream Start","id":"stream-start","depth":1},{"value":"Stream Ping","id":"stream-ping","depth":1},{"value":"Stream Stop","id":"stream-stop","depth":1},{"value":"Events","id":"events","depth":1}],"frontmatter":{"seo":{"title":""}},"lastModified":"2025-05-16T08:32:47.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/wsapi/account","userData":{"isAuthenticated":false,"teams":["anonymous"]}}