Question

I am wondering how to auto-save API data from http://api.bitcoinaverage.com/ticker/USD and https://crypto-trade.com/api/1/ticker/dvc_btc to create a chart using jqplot.

How can I make automated calls to each of the sites every 10 minutes and save data, and not have the data be overwritten by future calls?

Something like the chart here: vircurex.com/

Was it helpful?

Solution

You will need to use a combination of Database , Cache and a Cron (Scheduled Job) on your server to achieve what you want to do.

A high level approach would be: 1) Run a Backend Cron Job every 10 minutes. This will make a call to your Data Source i.e. HTTP Services and save the data in the database.

2) When the front-end makes a call, you should check if the results are present in the Cache. If they are present, return from the Cache itself so that Database calls (expensive) are avoided. If the results are not present in the Cache, retrieve from Database, put in Cache and return the data.

You might want to design your Cache and the items as per your requirements. Depending on the Caching libraries that you use, you could look for features like auto-expiring the cache items, reloading them automatically, etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top