currencybot / open-exchange-rates

Open Exchange Rates API - free / open source hourly-updated currency data for everybody
http://josscrowcroft.github.com/open-exchange-rates/
190 stars 19 forks source link

Add index file with list of available dates #29

Open wjcrowcroft opened 12 years ago

wjcrowcroft commented 12 years ago

Planned with next version updates: the repo will soon include an index file (possibly 'available.json') which you can access, to find out which dates are available.

Just gotta figure out the best format for this JSON file. Any ideas?

kgilmer commented 12 years ago

In my application, I calculate the set of dates backwards in time from the current day, and skip weekend days. For me, a simple way would be to pass you a date range and you return the days that have data. Then I could just keep counting back until I had the required number of days. This would keep the response size small (my widget requires only ~10 days of data), and allow me to cache the data for multiple widget instances.

Is the full set of currency data consistently available or can it also vary by quote currency? If so, specifying that in the request would also be helpful.

wjcrowcroft commented 12 years ago

Currently the static JSON are cached on openexchangerates.org directly from the github repository - I'm working on dynamic queries and a more API-like architecture, will keep you posted.

For now though, this available.json file will solve some of the issues. Any thoughts on the format/structure of the index file that would be most useful?

kgilmer commented 12 years ago

Hmm, in these terms I guess what I'm most concerned about is the size of the response (since smaller is faster). As there are more days with data than with not, a list of dates descending that do not have data and that are not weekend days (since I can calculate that myself) would be nice.

kgilmer commented 12 years ago

However I would add that my suggestion is highly optimized for my specific use case and probably not the most simple, general approach... :)

wjcrowcroft commented 12 years ago

I'd prefer to keep it as a list of available dates, but you're right about filesize. I'll have a play around with the data and see how small I can make it.