Build

Using PubNub and Google Dart to Subscribe to a Bitcoin Feed

2 min read Stephen Blum on Jul 18, 2014
Try PubNub Today

Free up to 1MM monthly messages. No credit card required.

Subscribe to our newsletter

By submitting this form, you are agreeing to our Terms and Conditions and Privacy Policy.

Earlier this year we received a question about how to use the PubNub Data Stream Network without an SLA officially supported SDK provided by PubNub. This specific case regarded using Google Dart and P...

Earlier this year we received a question about how to use the PubNub Data Stream Network without an SLA officially supported SDK provided by PubNub. This specific case regarded using Google Dart and PubNub to subscribe to a bitcoin feed.

We don’t recommend doing this, and we recommend using the following method which includes using the standard import 'dart:js' library interop. Details follow, but if you still want to continue with a non-library method, the documentation for the HTTP REST Push API interface is a good starting point.

But now let’s continue onward with the recommended method below to use PubNub and Google Dart to subscribe to a bitcoin feed!

You’ll first need to sign up for a PubNub account. Once you sign up, you can get your unique PubNub keys in the PubNub Developer Portal.

PubNub and Google Dart

Subscribing to a bitcoin feed using Google Dart is rather simple, though a bit confusing at first. Start by setting up your HTML file with the following script tags; and don’t forget the PubNub <div>!

PubNub Google Dart HTML File Example

NOTE: The PubNub <div> includes the bitcoin Subscribe Key paramater.

PubNub Dart Source File and SDK Usage Subscribe Callback Example

Next your Dart app source code will simply open the TCP Socket to the live stream. Note the channel ID is BTC-to-USD-stock-trade-value. This channel name is just an example, but many channel streams are provided by botcoin feeds that allow you to receive Trade/Depth/Ticker signals.

PubNub Dart Source File

The example channel references were for explanation purposes only and for you as a guide in understanding how to implement a quote symbol streaming solution for real-time price and trade events. Want to build a bitcoin exchange or bitcoin streaming app yourself? Take a look at our Bitcoin Solution Kit.

More from PubNub

Top Trends to Engage Your App Users
InsightsSep 27, 20224 min read

Top Trends to Engage Your App Users

Take a look at the top trends that are the most effective in attracting customers and reducing churn, and how you can incorporate...

PubNub Staff

PubNub Staff

Comparing Game Engines: Unity vs Unreal vs the Rest
Real-Time Gaming BlogSep 21, 20225 min read

Comparing Game Engines: Unity vs Unreal vs the Rest

Comparing the major game engines: Unity vs Unreal Engine vs Corona SDK vs GameMaker Studio, including the benefits and cons of...

PubNub Staff

PubNub Staff

Python Socket Programming: Client, Server and Peer Libraries
BuildSep 21, 20226 min read

Python Socket Programming: Client, Server and Peer Libraries

Sockets (aka socket programming) enable programs to send and receive data, bi-directionally, at any given moment. This tutorial...

PubNub Staff

PubNub Staff