whitemarket Documentation For Partners

WebSocket

Endpoint

wss://api.white.market/ws_endpoint

Example connect

JavaScript

Use https://github.com/centrifugal/centrifuge-js.

    const token = '<Place here JWT token from auth_token mutation>'

    const centrifuge = new Centrifuge('wss://api.white.market/ws_endpoint', {
        debug: true,
        token: token
    });

    const sub = centrifuge.newSubscription('market_products_updates');

    sub.on('connecting', function (ctx) {
        addResponse(`connecting: ${ctx.code}, ${ctx.reason}`);
    }).on('connected', function (ctx) {
        addResponse(`connected over ${ctx.transport}`);
    }).on('disconnected', function (ctx) {
        addResponse(`disconnected: ${ctx.code}, ${ctx.reason}`);
    }).on('publication', function(ctx) {
        addResponse(JSON.stringify(ctx.data.message)) // ctx.data.message contain JSON encoded string. See format below.
    }).connect();

    sub.subscribe();
    
    centrifuge.connect();

Golang

Use https://github.com/centrifugal/centrifuge-go.

Example to use library https://github.com/centrifugal/centrifuge-go/blob/master/examples/token_subscription/main.go

Dart

Use https://github.com/centrifugal/centrifuge-dart.

Swift

Use https://github.com/centrifugal/centrifuge-swift.

Java

Use https://github.com/centrifugal/centrifuge-java.

Example to use library https://github.com/centrifugal/centrifuge-java/blob/master/example/src/main/java/io/github/centrifugal/centrifuge/example/Main.java

Python

Use https://github.com/centrifugal/centrifuge-python.

Example to use library https://github.com/centrifugal/centrifuge-python/blob/master/example.py

Other

Connect to endpoint and send:

{"connect":{"token":"JWT_TOKEN","name":"js"},"id":1}
{"subscribe":{"channel":"market_products_updates"},"id":2}

You will receive messages like below:

{"push":{"channel":"market_products_updates","pub":{"data":{"message":{"type":"market_product_edited","content":{"id":"1ef8d741-8ae1-6af4-b225-0242ac150002","price":"2.10"}}"}}}}

General format

{
   "channel":"CHANNEL_NAME",
   "pub":{
      "data":{
         "message":"ENCODED_AND_ESCAPED_JSON_CONTENT"
      }
   }
}

When receiving, you need to unescape and json decode to get the data

Example

{
   "channel":"market_products_updates",
   "pub":{
      "data":{
         "message":"{\"type\":\"market_product_added\",\"content\":{\"id\":\"1ef6c2b5-7f94-67c0-8e23-0242ac15000b\",\"app_id\":\"730\",\"asset_id\":\"36857146063\",\"class_id\":\"469440539\",\"instance_id\":\"302028390\",\"price\":\"0.020\",\"name_hash\":\"G3SG1 | Green Apple (Minimal Wear)\",\"inspect_url\":\"steam:\\\/\\\/rungame\\\/730\\\/76561202255233023\\\/+csgo_econ_action_preview%20S76561198283251328A36857146063D14015389653147072601\",\"delivery_type\":\"semi\"}}"
      }
   }
}

Messages

Click here