{"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":"market-websocket-api"},"children":["Market Websocket API"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Connect websocket to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://data-api.hibachi.xyz/ws/market"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Please note no authorization header is needed to use the market api."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"usage"},"children":["Usage"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This websocket endpoint is used to get realtime market data."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You should start with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["subscribe"]}," with a few symbols and topics. You can subscribe to multiple symbol and topics at the same time."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"supported-topics"},"children":["Supported topics"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Price: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["mark_price"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["spot_price"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ask_bid_price"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["funding_rate_estimation"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Trade: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["trades"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Klines: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["klines"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Orderbook: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["orderbook"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"supported-methods"},"children":["Supported Methods"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"/wsapi/market#subscribe"},"children":["subscribe"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"/wsapi/market#unsubscribe"},"children":["unsubscribe"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"/wsapi/market#list-subscriptions"},"children":["list_subscriptions"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For orderbook you can specify optional parameter ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["granularity"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["depth"]},". See the ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"/marketapi/market/orderbook"},"children":["REST API /market/data/orderbook"]}," for the details. You can only subscribe to one set of parameters. If you subscribe with different parameters it will unsubscribe the previous subscription automatically."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["After that the server will send you events."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["unsubscribe"]}," to unsubscribe all or a subset of topics. You don't need to specify parameters in this case."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["list_subscription"]}," to know all subscriptions."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"notes-for-orderbook-events"},"children":["Notes for orderbook events"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When you first subscribe it should send you one message with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["\"messageType\": \"Snapshot\""]}," immediately, it contains all price levels.",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},"After that you will receive message with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["\"messageType\": \"Update\""]}," periodically and you should update your state in this way for both sides:"]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["If it is ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["null"]}," then remove all price levels."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Remove all price levels outside ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["startPrice"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["endPrice"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["For each level in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["levels"]},", if the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["quantity"]}," is ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["zero"]}," then remove it."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Otherwise create or update the price level accordingly."]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"subscribe"},"children":["Subscribe"]},{"$$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    \"method\": \"subscribe\",\n    \"parameters\": {\n        \"subscriptions\": [\n            {\n                \"symbol\": \"ETH/USDT-P\",\n                \"topic\": \"mark_price\"\n            },\n            {\n                \"symbol\": \"ETH/USDT-P\",\n                \"topic\": \"spot_price\"\n            },\n            {\n                \"symbol\": \"ETH/USDT-P\",\n                \"topic\": \"funding_rate_estimation\"\n            },\n            {\n                \"symbol\": \"ETH/USDT-P\",\n                \"topic\": \"trades\"\n            },\n            {\n                \"symbol\": \"ETH/USDT-P\",\n                \"topic\": \"klines\"\n            },\n            {\n                \"symbol\": \"ETH/USDT-P\",\n                \"topic\": \"orderbook\"\n            },\n            {\n                \"symbol\": \"ETH/USDT-P\",\n                \"topic\": \"ask_bid_price\"\n            }\n        ]\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":"no response\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"unsubscribe"},"children":["Unsubscribe"]},{"$$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    \"method\": \"unsubscribe\",\n    \"parameters\": {\n        \"subscriptions\": [\n            {\n                \"symbol\": \"ETH/USDT-P\",\n                \"topic\": \"mark_price\"\n            },\n            {\n                \"symbol\": \"ETH/USDT-P\",\n                \"topic\": \"spot_price\"\n            },\n            {\n                \"symbol\": \"ETH/USDT-P\",\n                \"topic\": \"funding_rate_estimation\"\n            },\n            {\n                \"symbol\": \"ETH/USDT-P\",\n                \"topic\": \"trades\"\n            },\n            {\n                \"symbol\": \"ETH/USDT-P\",\n                \"topic\": \"klines\"\n            },\n            {\n                \"symbol\": \"ETH/USDT-P\",\n                \"topic\": \"orderbook\"\n            },\n            {\n                \"symbol\": \"ETH/USDT-P\",\n                \"topic\": \"ask_bid_price\"\n            }\n        ]\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    \"status\": 200\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"list-subscriptions"},"children":["List subscriptions"]},{"$$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":"{ \"method\": \"list_subscriptions\" }\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    \"subscriptions\": [\n        {\n            \"symbol\": \"ETH/USDT-P\",\n            \"topic\": \"markPrice\"\n        },\n        {\n            \"symbol\": \"ETH/USDT-P\",\n            \"topic\": \"spotPrice\"\n        },\n        {\n            \"symbol\": \"ETH/USDT-P\",\n            \"topic\": \"askBidPrice\"\n        },\n        {\n            \"symbol\": \"ETH/USDT-P\",\n            \"topic\": \"fundingRateEstimation\"\n        },\n        {\n            \"symbol\": \"ETH/USDT-P\",\n            \"topic\": \"trades\"\n        },\n        {\n            \"symbol\": \"ETH/USDT-P\",\n            \"topic\": \"klines\"\n        },\n        {\n            \"symbol\": \"ETH/USDT-P\",\n            \"topic\": \"orderbook\"\n        }\n    ]\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"events"},"children":["Events"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"// Those are examples of message send by server\n[\n    {\n        \"data\": {\n            \"markPrice\": \"3513.365000\"\n        },\n        \"symbol\": \"ETH/USDT-P\",\n        \"topic\": \"mark_price\"\n    },\n    {\n        \"data\": {\n            \"spotPrice\": \"3513.365000\"\n        },\n        \"symbol\": \"ETH/USDT-P\",\n        \"topic\": \"spot_price\"\n    },\n    {\n        \"data\": {\n            \"askPrice\": \"3513.716336\",\n            \"bidPrice\": \"3513.013663\"\n        },\n        \"symbol\": \"ETH/USDT-P\",\n        \"topic\": \"ask_bid_price\"\n    },\n    {\n        \"data\": {\n            \"fundingRateEstimation\": {\n                \"estimatedFundingRate\": \"-0.000040\",\n                \"nextFundingTimestamp\": 1712793600\n            }\n        },\n        \"symbol\": \"ETH/USDT-P\",\n        \"topic\": \"funding_rate_estimation\"\n    },\n    {\n        \"data\": {\n            \"trade\": {\n                \"price\": \"3514.370559\",\n                \"quantity\": \"0.284517521\",\n                \"takerSide\": \"Sell\",\n                \"timestamp\": 1712782611\n            }\n        },\n        \"symbol\": \"ETH/USDT-P\",\n        \"topic\": \"trades\"\n    },\n    {\n        \"data\": {\n            \"close\": \"3512.964670\",\n            \"high\": \"3517.318806\",\n            \"interval\": \"1h\",\n            \"low\": \"3511.145033\",\n            \"open\": \"3512.659268\",\n            \"timestamp\": 1712779200,\n            \"volumeNotional\": \"320479.592130\"\n        },\n        \"symbol\": \"ETH/USDT-P\",\n        \"topic\": \"klines\"\n    },\n    {\n        \"data\": {\n            \"ask\": {\n                \"endPrice\": \"3518.25\",\n                \"levels\": [\n                    {\n                        \"price\": \"3515.09\",\n                        \"quantity\": \"0.284516833\"\n                    },\n                    {\n                        \"price\": \"3515.34\",\n                        \"quantity\": \"0.000000000\"\n                    }\n                ],\n                \"startPrice\": \"3515.09\"\n            },\n            \"bid\": null\n        },\n        \"depth\": 10,\n        \"granularity\": \"0.01\",\n        \"messageType\": \"Update\",\n        \"symbol\": \"ETH/USDT-P\",\n        \"topic\": \"orderbook\"\n    }\n]\n","lang":"json"},"children":[]}]},"headings":[{"value":"","id":null,"depth":1},{"value":"Market Websocket API","id":"market-websocket-api","depth":1},{"value":"Usage","id":"usage","depth":2},{"value":"Supported topics","id":"supported-topics","depth":3},{"value":"Supported Methods","id":"supported-methods","depth":2},{"value":"Notes for orderbook events","id":"notes-for-orderbook-events","depth":2},{"value":"Subscribe","id":"subscribe","depth":1},{"value":"Unsubscribe","id":"unsubscribe","depth":1},{"value":"List subscriptions","id":"list-subscriptions","depth":1},{"value":"Events","id":"events","depth":1}],"frontmatter":{"seo":{"title":""}},"lastModified":"2025-05-16T08:32:47.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/wsapi/market","userData":{"isAuthenticated":false,"teams":["anonymous"]}}