Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Websocket event type #189

Open
MelchiSalins opened this issue Jun 9, 2020 · 3 comments
Open

Websocket event type #189

MelchiSalins opened this issue Jun 9, 2020 · 3 comments

Comments

@MelchiSalins
Copy link

MelchiSalins commented Jun 9, 2020

Would be great if socket data looked something like this:

{
    "Event":"NewOrder",
    "Channel":"orderbook-xbt-aud",
    "Data":{
        "OrderGuid":"fa091562-4101-46de-8d66-aeddbeb8795b",
        "Pair":"xbt-aud",
        "Price":10270.31,
        "OrderType":"LimitBid",
        "Volume":1.0
        }
}

All the channels subscribed should have an Event field to denote the type of message it is. Currently its completely up to the consumer to make sense of the data returned which is not efficient at all.

@martin-nginio
Copy link
Contributor

Hi @MelchiSalins

Thanks for your feedback.

I think you are referring to our old WebSocket API.

If you are starting to develop please can you use the latest version below:
https://api.btcmarkets.net/doc/v3#tag/WS_Overview

Thanks.

Regards,
Martin

@MelchiSalins
Copy link
Author

I'm developing on v3 as well. The body looks something like this.

{
"marketId": "XLM-AUD",
"timestamp": "2020-06-10T00:17:26.987Z",
"bestBid": "0.1119",
"bestAsk": "0.1133",
"lastPrice": "0.1118",
"volume24h": "83174.81793818",
"messageType": "tick",
"price24h": "-0.0031",
"low24h": "0.1115",
"high24h": "0.1159",
"snapshotId": 1591748246987000
}

Would be great if it would look something like this

>{
       "messageType":"tick",
       "timestamp": "2020-06-10T00:17:26.987Z",
       snapshotId": 1591748246987000,
       "data":{
               "marketId": "XLM-AUD",
               "bestBid": "0.1119",
               "bestAsk": "0.1133",
	       "price24h": "-0.0031",
	       "low24h": "0.1115",
	       "high24h": "0.1159",
               }
}

This makes it more efficient to work with strongly typed languages such as Golang. Casting the incoming message to the right struct currently is extremely inefficient because of the body structure. Probably something to keep in mind for the v4?

@martin-nginio
Copy link
Contributor

We try to design WebSocket messages to be as similar as possible to REST API responses hence where possible we will keep the same flat json structure.

I'm hoping every programming language offers efficient deserialization of the flat json structure for the WebSocket (and also REST API ) messages/responses.

Thanks for the suggestion anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants