Crypto coin ticker

I recently decided to get into the world of BitCoins, so I bought some coins. Aside from BitCoins, I also have LiteCoins and FeatherCoins. I wanted to track the prices of all these currencies on a single widget on my screen. While searching on the market, I saw an app that allows me to add various widgets on my screen to track all these currencies, but at a cost of a widget per currency type. I do not want to give up that much real estate on my phone for the data that could be displayed in 1 small widget. So, I set out to build my own using tools like Tasker, Zoom Widget and a REST plugin for Tasker.

Here's what I did to get this system to work.

First, I had to find a place that could give me prices of currencies I need. The one I settled on is Btc-E. As it turns out, they have an API that returns JSON with all the data I need! All I had to do was extract data from JSON and store them as Tasker variables. The API call I ended up using was:

https://btc-e.com/api/3/ticker/btc_usd-ftc_btc-ltc_btc

This call returns 3 values:

  • BTC in USD
  • FTC in BTC
  • LTC in BTC

If you want any other values, simply add "-_". The complete list of currencies can be found on BTC-e website.

Here's a sample JSON that I got from the above API call:

{
    "btc_usd": {
        "avg": 341.04249499999997,
        "buy": 339.71300000000002,
        "high": 346.95999,
        "last": 337.459,
        "low": 335.125,
        "sell": 337.68099999999998,
        "updated": 1418661259,
        "vol": 2188229.6703699999,
        "vol_cur": 6422.3104400000002
    }
}

The values I was interested in are: buy price, sell price, and last updated. To extract those values, I wrote a simple JavaScript script that would parse out values I am interested in, convert them all to USD and return them back to Tasker for further processing. The script I wrote, could be found in my GitHub Repository.

With all the values available, we are now ready to create a Zoom widget that will display our values. This is a how my widget looks:
BTC-e prices widget
I think it is pretty self-explanatory, but it is worth noting the following:

I've downloaded some icons from Google Images and placed them on my External SD card
Currently, values are updated on demand; you need to tap on a widget to update it. This can be easily solved with a Tasker profile

Now that you know what this widget does, here's my task looks like:

Steps 1 and 2 are data acquisition and parsing. I am using a plugin called RESTask (could be found in Google Play Store) to get JSON from BTC-e and then I'm executing my JavaScript code to parse out / convert values I need.
Steps 3 - 8 are responsible for generating variable names (to match those exported by the JavaScript code) and update text in a Zoom widget.

I've also exported both Tasker task and Zoom template so, all you need to do is just import them in the appropriate applications and start using it!

Questions and comments are always welcomed!

AttachmentSize
File Tasker task export5.33 KB
File Zoom widget export9.57 KB

Comments