create account

Programming a Crypto Tracking Bot by makerhacks

View this thread on: hive.blogpeakd.comecency.com
· @makerhacks ·
$0.52
Programming a Crypto Tracking Bot
![Fullscreen.png](https://steemitimages.com/DQmUbUTG17gLehdcmuve14aVJgBtuHCYzkPVViG4Kve1q3f/Fullscreen.png)

[In my earlier post I wrote about my annoying but fun Bitcoin price bot](https://steemit.com/cryptocurrency/@makerhacks/i-made-a-robot-read-out-the-bitcoin-price-and-i-made-a-terrible-mistake). After my video appeared a couple of people have asked me how I did it.

First of all, it was a bit of fun - ideally you wouldn't have the price read out constantly because that is a good way to enrage yourself rather than inform yourself :)

Second, for this I used EZ-Robots platform, because the eventual plan is to build a full astromech droid. Your computer, Raspberry Pi, or even ESP8266 are entirely sufficient for this purpose.

## Bitcoin API

There are many, many APIs out there tracking crypto prices. 

I wanted the one I used to be ...

* Free
* Public, not protected
* Relatively up to date and accurate
* Available
* Responsive
* Easy

Ideally I didn't want to have to install libraries either. Folks think that makes things easier, but for me the easiest thing is to have access to a URL and get JSON back, especially as the EZ-Robot scripting environment was unlikely to be supported.

## Talking to APIs

As mentioned above, I like to GET a URL and get JSON back. What does this mean?

A GET is very much like clicking a link or entering a web address in your browser. You are asking your machine to go fetch that location and return the text of whatever it finds.

The text we get back ends up formatted in a data format so that the information can be easily interpreted. Some use XML, but I prefer JSON. This is what the data from our chosen API, Coindesk, looks like when supplied the information that we want USD data in JSON format.

![Chris — root@makerhacksbots_ ~ — -bash — 80×24.png](https://steemitimages.com/DQmeJpLcLxHhKxPbnZVNDkY9hfcWNebKUnSHC3zAsMQNHBH/Chris%20%E2%80%94%20root%40makerhacksbots_%20~%20%E2%80%94%20-bash%20%E2%80%94%2080%C3%9724.png)

## Extracting the Price

If you are working in a modern development environment then your tool of choice might well just slurp in JSON and understand what all the delimiters are for. You might alternatively have easy access to libraries that take the heavy lifting for you.

With EZ-Robot, it appears in the forums people have successfully processed JSON (the platform is based off the Microsoft .NET framework), but it seemed too much effort to go digging through how to do that when I just wanted the price out of this returned text string.

So I did a hacky string manipulation instead.

Seeing as the data is always returned in the same format, I look for a certain : character, and then a period. The number before the period is the digits I am looking for.

After that, I simply asked my robot to say the number out loud.

In the real world use of this you would want to 

1. display the number 
1. make it only read out loud if the number was significantly different
1. not check and read out every second!

## Next steps

The implementation was annoying but the idea of updating myself when the BTC rises or falls was surprisingly useful to me, so I will create a new non-annoying version, with more utility - check back!

**What do you think would be useful? Please let me know in the comments**
👍  , , , ,
properties (23)
authormakerhacks
permlinkprogramming-a-crypto-tracking-bot
categoryprogramming
json_metadata{"tags":["programming","cryptocurrency","bitcoin","electronics","arduino"],"image":["https://steemitimages.com/DQmUbUTG17gLehdcmuve14aVJgBtuHCYzkPVViG4Kve1q3f/Fullscreen.png","https://steemitimages.com/DQmeJpLcLxHhKxPbnZVNDkY9hfcWNebKUnSHC3zAsMQNHBH/Chris%20%E2%80%94%20root%40makerhacksbots_%20~%20%E2%80%94%20-bash%20%E2%80%94%2080%C3%9724.png"],"links":["https://steemit.com/cryptocurrency/@makerhacks/i-made-a-robot-read-out-the-bitcoin-price-and-i-made-a-terrible-mistake"],"app":"steemit/0.1","format":"markdown"}
created2017-12-15 23:23:57
last_update2017-12-15 23:23:57
depth0
children3
last_payout2017-12-22 23:23:57
cashout_time1969-12-31 23:59:59
total_payout_value0.423 HBD
curator_payout_value0.099 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length3,289
author_reputation156,478,962,956,499
root_title"Programming a Crypto Tracking Bot"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id23,682,558
net_rshares85,469,849,200
author_curate_reward""
vote details (5)
@dianadsouza ·
[Crypto Tracker Bot](https://coinpedia.org/crypto-tracking-tools/crypto-tracker-bot-review/) is an iOS and Android app that provides real-time push notifications for cryptocurrencies that list on the most influential crypto exchanges.

Thus, you are able to stay ahead of price and market information and take necessary actions and decisions before everyone else does.
👎  ,
properties (23)
authordianadsouza
permlinkre-makerhacks-programming-a-crypto-tracking-bot-20180721t105552501z
categoryprogramming
json_metadata{"tags":["programming"],"links":["https://coinpedia.org/crypto-tracking-tools/crypto-tracker-bot-review/"],"app":"steemit/0.1"}
created2018-07-21 10:55:39
last_update2018-07-21 10:55:39
depth1
children0
last_payout2018-07-28 10:55:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length368
author_reputation-10,590,734,684
root_title"Programming a Crypto Tracking Bot"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id65,464,811
net_rshares-172,778,443,784
author_curate_reward""
vote details (2)
@maxg ·
$0.06
It might be cool to hit up multiple APIs and take an average of them. I know CoinMarketCap, CoinDesk,  and CoinBase are usually a little bit off from each other. They all have pretty similar JSON APIs.
👍  
properties (23)
authormaxg
permlinkre-makerhacks-programming-a-crypto-tracking-bot-20171216t051005787z
categoryprogramming
json_metadata{"tags":["programming"],"app":"steemit/0.1"}
created2017-12-16 05:10:06
last_update2017-12-16 05:10:06
depth1
children1
last_payout2017-12-23 05:10:06
cashout_time1969-12-31 23:59:59
total_payout_value0.045 HBD
curator_payout_value0.012 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length201
author_reputation5,859,582,764,121
root_title"Programming a Crypto Tracking Bot"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id23,708,297
net_rshares9,835,369,969
author_curate_reward""
vote details (1)
@makerhacks ·
Good idea :)
properties (22)
authormakerhacks
permlinkre-maxg-re-makerhacks-programming-a-crypto-tracking-bot-20171216t063506694z
categoryprogramming
json_metadata{"tags":["programming"],"app":"steemit/0.1"}
created2017-12-16 06:35:06
last_update2017-12-16 06:35:06
depth2
children0
last_payout2017-12-23 06:35:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length12
author_reputation156,478,962,956,499
root_title"Programming a Crypto Tracking Bot"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id23,715,233
net_rshares0