About
Multi market data is a public API which allows for multiple symbols to be streamed via a single endpoint.
The initial response message will show the existing state of the order books requested. Subsequent messages will show all executed trades, as well as all other changes to the order books from orders placed or canceled.
WebSocket Request
wss://api.gemini.com/v1/multimarketdata?symbols=BTCUSD,ETHUSD
URL Parameters
Parameter | Required | Default | Description |
---|---|---|---|
| Yes | false | required. Will stream market data for symbols provided. Can provide data for multiple symbols on the same stream. |
| No | false | Optionally add this parameter and set to |
| No | false | If absent or |
| No | true | Include bids in |
| No | true | Include asks in |
| No | true | Include |
The semantics of entry type filtering is:
- If any entry type is specified as
true
orfalse
, all of them must be explicitly flaggedtrue
to show up in the response - If no entry types filtering parameters are included in the url, then all entry types will appear in the response
Note: top_of_book
has no meaning and initial book events are empty when only trades
is specified
Response
A WebSocket stream that provides multiple symbols with each frame containing a JSON message of the following format:
Field | Type | Description |
---|---|---|
|
| |
| zero-indexed monotonic increasing sequence number attached to each message sent - if there is a gap in this sequence, you have missed a message. If you choose to enable heartbeats, then |
Messages with type heartbeat
have no additional fields.
Messages of type update
have the following additional fields:
Field | Type | Description |
---|---|---|
| A monotonically increasing sequence number indicating when this change occurred. These numbers are persistent and consistent between market data connections. | |
| Either a change to the order book, or the indication that a trade has occurred. | |
| The timestamp in seconds for this group of events (included for compatibility reasons). We recommend using the | |
| The timestamp in milliseconds for this group of events. |
Common fields
All elements of the events
share the following fields:
Field | Type | Description |
---|---|---|
| Either | |
| Will return the order book for which the message type is for. Only symbols provided in the URL parameter will be present in the stream. |
Examples
Multi Market Data Feed - BTCUSD & ETHUSD
import ssl import websocket def on_message(ws, message): print(message) ws = websocket.WebSocketApp( "wss://api.gemini.com/v1/multimarketdata?symbols=BTCUSD,ETHUSD", on_message=on_message) ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE})python
npm install -g wscat wscat --connect wss://api.gemini.com/v1/v1/multimarketdata?symbols=BTCUSD,ETHUSD < {"type":"update","eventId":773797793,"socket_sequence":0,"events":[{"type":"change","reason":"initial","price":"1.00","delta":"236.5","remaining":"236.5","side":"bid","symbol":"BTCUSD"},{"type":"change","reason":"initial","price":"2.00","delta":"176"}, ... {"type":"change","reason":"initial","price":"59137.50","delta":"0.00031","remaining":"0.00031","side":"ask","symbol":"BTCUSD"}]} < {"type":"update","eventId":773797763,"socket_sequence":1,"events":[{"type":"change","reason":"initial","price":"6.95","delta":"9","remaining":"9","side":"bid","symbol":"ETHUSD"}, ... {"type":"change","reason":"initial","price":"1827.84","delta":"14.8","remaining":"14.8","side":"ask","symbol":"ETHUSD"}]} < {"type":"update","eventId":773797906,"timestamp":1617045817,"timestampms":1617045817599,"socket_sequence":2,"events":[{"type":"trade","tid":773797906,"price":"57734.10","amount":"0.002","makerSide":"bid","symbol":"BTCUSD"},{"type":"change","side":"bid","price":"57734.10","remaining":"0.0107803","delta":"-0.002","reason":"trade","symbol":"BTCUSD"}]}shell
Initial JSON response messages for BTCUSD and ETHUSD
{ "type":"update", "eventId":773797793,"socket_sequence":0, "events":[ { "type":"change", "reason":"initial", "price":"1.00", "delta":"236.5", "remaining":"236.5", "side":"bid", "symbol":"BTCUSD" }, ... { "type":"change", "reason":"initial", "price":"59137.50", "delta":"0.00031", "remaining":"0.00031", "side":"ask", "symbol":"BTCUSD" } ] } { "type":"update", "eventId":773797763,"socket_sequence":1, "events":[ { "type":"change", "reason":"initial", "price":"6.95", "delta":"9", "remaining":"9", "side":"bid", "symbol":"ETHUSD" }, ... { "type":"change", "reason":"initial", "price":"1827.84", "delta":"14.8", "remaining":"14.8", "side":"ask", "symbol":"ETHUSD" } ] }json