Institutions Pro traders Mobile app Bitstamp earn Markets Blog Tradeview Log in Get started HTTP API Websocket API v2 FIX Websocket API v2 WHAT IS WEBSOCKET? WebSocket is a protocol providing full-duplex communications channels over a single TCP connection. The WebSocket protocol was standardized by the IETF as RFC 6455 in 2011, and the WebSocket API in Web IDL is being standardized by the W3C. CONNECTION Bitstamp uses its implementation of websocket server for real time data streaming. Server is accessible on the following address: wss://ws.bitstamp.net. Documentation about websocket protocol can be found on the following link: https://websockets.readthedocs.io/en/stable/. Once you open a connection via websocket handshake (using HTTP upgrade header), you can subscribe to desired channels. After this is accomplished, you will start to receive a stream of live events for every channel you are subscribed to. SUBSCRIPTIONS Public channels To subscribe to a channel, JSON message must be sent to the server. It should have a following structure: JSON { "event": "bts:subscribe", "data": { "channel": "[channel_name]" } } Private channels For private Websocket access, please contact support. To subscribe to a channel, JSON message must be sent to the server. It should have a following structure: JSON { "event": "bts:subscribe", "data": { "channel": "[channel_name]-[user-id]", "auth": "[token]" } } User ID will be provided by support. Token value is generated via HTTP API. See Websockets token section of HTTP API documentation here. UNSUBSCRIPTIONS You can also unsubscribe from the channel if you no longer need its stream. Again, you need to send a message to the server. Its structure is nearly identical to the subscription JSON: JSON { "event": "bts:unsubscribe", "data": { "channel": "[channel_name]" } } Note: Messages described and defined in this article are the only ones that will be processed by the server. Any other form of message or correct form of message with unexpected content will result in an error response. CHANNELS Currency pairs: btcusd, btceur, btcgbp, btcpax, btcusdt, btcusdc, gbpusd, gbpeur, eurusd, ethusd, etheur, ethbtc, ethgbp, ethpax, ethusdt, ethusdc, adausd, adaeur, adabtc, xrpusd, xrpeur, xrpbtc, xrpgbp, xrppax, xrpusdt, uniusd, unieur, unibtc, ltcusd, ltceur, ltcbtc, ltcgbp, linkusd, linkeur, linkbtc, linkgbp, linketh, maticusd, maticeur, xlmusd, xlmeur, xlmbtc, xlmgbp, fttusd, ftteur, bchusd, bcheur, bchbtc, bchgbp, aaveusd, aaveeur, aavebtc, axsusd, axseur, algousd, algoeur, algobtc, compusd, compeur, compbtc, snxusd, snxeur, snxbtc, hbarusd, hbareur, chzusd, chzeur, celusd, celeur, enjusd, enjeur, batusd, bateur, batbtc, mkrusd, mkreur, mkrbtc, zrxusd, zrxeur, zrxbtc, audiousd, audioeur, audiobtc, sklusd, skleur, yfiusd, yfieur, yfibtc, sushiusd, sushieur, alphausd, alphaeur, storjusd, storjeur, sxpusd, sxpeur, grtusd, grteur, umausd, umaeur, umabtc, omgusd, omgeur, omgbtc, omggbp, kncusd, knceur, kncbtc, crvusd, crveur, crvbtc, sandusd, sandeur, fetusd, feteur, rgtusd, rgteur, slpusd, slpeur, eurtusd, eurteur, usdtusd, usdteur, usdcusd, usdceur, usdcusdt, daiusd, paxusd, paxeur, paxgbp, eth2eth, gusdusd Below tables include definitions of all existing channels you can subscribe to. Replacing [channel_name] placeholder in one of JSON messages defined in previous paragraphs will subscribe or unsubscribe you to a channel. You also need to replace [currency_pair] placeholder with one of pairs defined at the beginning of this paragraph. Public channels Name Event Channel Live ticker trade live_trades_[currency_pair] Live orders order_created, order_changed or order_deleted live_orders_[currency_pair] Live order book data order_book_[currency_pair] Live detail order book data detail_order_book_[currency_pair] Live full order book data diff_order_book_[currency_pair] Private channels Name Event Channel Live ticker order_created, order_changed or order_deleted private-my_orders_[currency_pair] Live orders trade private-my_trades_[currency_pair] CHANNEL JSON STRUCTURE Live ticker - JavaScript example: live_trades_v2.html Property Description id Trade unique ID. amount Trade amount. amount_str Trade amount represented in string format. price Trade price. price_str Trade price represented in string format. type Trade type (0 - buy; 1 - sell). timestamp Trade timestamp. microtimestamp Trade microtimestamp. buy_order_id Trade buy order ID. sell_order_id Trade sell order ID. Live order book - JavaScript example: order_book_v2.html Property Description bids List of top 100 bids. asks List of top 100 asks. timestamp Order book timestamp. microtimestamp Order book microtimestamp. Live detail order book Property Description bids List of top 100 bids [price, amount, order id]. asks List of top 100 asks [price, amount, order id]. timestamp Order book timestamp. microtimestamp Order book microtimestamp. Live full order book - JavaScript example: diff_order_book_v2.html Property Description bids List of changed bids since last broadcast. asks List of changed asks since last broadcast. timestamp Order book timestamp. microtimestamp Order book microtimestamp. Live orders - JavaScript example: live_orders_v2.html Property Description id Order ID. amount Order amount. amount_str Order amount represented in string format. price Order price. price_str Order price represented in string format. order_type Order type (0 - buy; 1 - sell). datetime Order datetime. microtimestamp Order action timestamp represented in microseconds. Private My Orders Property Description id Order ID. id_str Order ID represented in string format. client_order_id Client order ID (if used when placing order). amount Order amount. amount_str Order amount represented in string format. price Order price. price_str Order price represented in string format. order_type Order type (0 - buy, 1 - sell). datetime Order datetime. microtimestamp Order action timestamp represented in microseconds. Private My Trades Property Description id Trade ID. order_id Order ID associated with the trade. client_order_id Client order ID associated with the trade. amount Trade amount. price Trade price. fee Trade fee. order_type Order type (0 - buy, 1 - sell). microtimestamp Trade timestamp represented in microseconds. OTHER TECHNICAL INFORMATION 1. Heartbeat If you wish to determine that websocket server is responsive, you should do so by websocket heartbeat. This is a form of control message or "PING / PONG" communication. You can do so by sending the following JSON message to the server: JSON { "event": "bts:heartbeat" } 2. Forced reconnection In case of websocket server you are currently connected to is to go under maintenance, you will receive a warning message asking you to reconnect. Such a message will look like this: JSON { "event": "bts:request_reconnect", "channel": "", "data": "" } After you receive this request, you will have a few seconds to reconnect. Without doing so, you will automatically be disconnected. If you send reconnection request, you will be placed to a new server. Consequentially, you can continue without any message loss. 3. Maximum connection age Maximum connection age is 90 days from the time the connection is established. When that period of time elapses, you will be automatically disconnected and will need to re-connect. ABOUT Who We Are Careers Legal & Privacy Fee Schedule FAQ PRODUCTS Mobile App Tradeview Bitstamp Earn SERVICES Institutions & Partners Crypto-as-a-Service Pro Traders RESOURCES API Documentation PGP Key Lightning Network ADDRESS Bitstamp Ltd 5 New Street Square London EC4A 3TW United Kingdom CONTACT info@bitstamp.net press@bitstamp.net support@bitstamp.net complaints@bitstamp.net +44 20 3868 9628 +1 800 712 5702 +352 20 88 10 96 All rights reserved © 2021 Bitstamp. NMLS #1905429 We use cookies and similar technologies to operate core site features, customize core services, analyze our traffic, and for security and marketing. Accept all cookies, customize your settings or read our full Cookie Policy. Customize Enable all