From Bitcoin Wiki
Revision as of 18:48, 2 December 2013 by Pubnub (talk | contribs) (added SSL)
Jump to: navigation, search


MtGox is now using the services of PubNub to stream real-time data due to the difficulty to cope with the kind of volumes of data we need to broadcast real-time while keeping a reliable service.

PubNub provides SDK in various languages:

If you already use Socket.IO, you may want to check

Access to public channels

It is possible to subscribe directly to any public channel listed on through that interface.

Subscribe key for MtGox: sub-c-50d56e1e-2fd9-11e3-a041-02ee2ddab7fe (it's the same for everyone who want to use MtGox)

Some sample feeds on the PubNub console:

A very simple sample implementation: (shows trade engine lag in realtime)

Access to private channels

Private channels can be accessed by first calling the api. This API will return details to access the private API (subscribe key, auth key, encryption key, etc).

Private messages are encrypted using PubNub's standard encryption method (AES256 CBC) and a shared secret obtained through the API. This guarantees that PubNub has no knowledge of the private key and as such can't possibly read the private messages unless you access the console (as it's passed as parameter). As long as you don't call the stream/private_get api, no data for your user will be sent to PubNub.

Once the number of seconds specified in "renew" has passed, you should call the API again to renew the auth key and password. If the auth key has changed, you will need to subscribe again to continue getting updates. Once the number of seconds specified in "expires" has passed, no data will be sent anymore unless the API was called again.

If you call that API once every renew, the access data should not change, and you should continue getting updates as long as you're connected. Note that you can pass an extra parameter to this API (renew=1) to force the private key and auth key to change. Change in private key will be handled for all new messages (the old auth key will continue working until its expiration).