BTCMarkets / API

API
120 stars 30 forks source link

Orderbook snapshotId is always zero #181

Closed nickchr closed 4 years ago

nickchr commented 4 years ago

snapshotId is always zero on the orderbook endpoint e.g. https://api.btcmarkets.net/v3/markets/BTC-AUD/orderbook?level=1

snapshotId used to be a timestamp that could be used for knowing the age of the orderbook snapshot. is it possible to bring back the timestamp?...

martin-nginio commented 4 years ago

Thanks @nickchr for your feedback.

snapshotId represents a unique incremental number for every change made to the orderbook and is useful in many situations including WebSocket endpoints (e.g. orderbook update events). This was removed by mistake from the API endpoint some time ago and it's been re-added to the orderbook API endpoint again.

Thanks again for reporting the issue.

Regards, Martin

nickchr commented 4 years ago

Thanks Martin, I see that it works now. If the snapshotId is consistent between the WS and this Orderbook endpoint, can this be used reliably to confirm my orderbook maintained through WS OrderbookUpdate events is still in sync and no events have been missed? i.e. comparing my local orderbook copy maintained through the WS, against the orderbook snapshot, for a given snapshotId, the two should be the same.

martin-nginio commented 4 years ago

Hi @nickchr .

The snapshotId is produced by the matching engine and is the same number broadcasted by WebSocket and also returned by API so you should be fine to use it for maintaining your local orderbook.

Please refer to the following document about maintaining a local orderbook using WebSocket; https://api.btcmarkets.net/doc/v3/#section/OrderbookUpdate-event

Thanks.

Regards, Martin