Revision | Commit Message | Age | Author | Refs | ||
---|---|---|---|---|---|---|
|
a3cc41a5cfea | 1 year and 1 month ago | Brett Smith | |||
|
3b732505fa62 | 1 year and 1 month ago | Brett Smith | |||
|
cb17033279fb | 1 year and 5 months ago | Brett Smith | |||
|
f7a57ded868c | 1 year and 7 months ago | Brett Smith | |||
|
d0f5f1547ced | 1 year and 7 months ago | Brett Smith | |||
|
b270db02e8d7 | 1 year and 7 months ago | Brett Smith | |||
|
8ab2373ba13e | 1 year and 8 months ago | Brett Smith | |||
|
419f52abe36c | 1 year and 8 months ago | tbm | |||
|
97222c2f7545 | 1 year and 8 months ago | Brett Smith | |||
|
936237eceb32 | 1 year and 8 months ago | Brett Smith |
oxrlib
Introduction
oxrlib provides a Python library and CLI tool to query the Open Exchange Rates API. It emphasizes support for rich data types throughout, and supports caching API results to the filesystem.
It currently only supports OXR's "historical" API.
Getting started with the CLI tool
oxrlib includes an oxrquery tool to access the OXR API directly from the command line. By default, it reads your OXR credentials and other common configuration from ~/.config/oxrlib.ini. Copy oxrlib_example.ini from the source to ~/.config/oxrlib.ini, then edit that file following the instructions in the comments.
Run oxrquery --help for instructions to use the tool.
Getting started with the library
Here's an example of using the Python library, complete with caching results:
from oxrlib import cache, loaders, rate filename_format = '{date}_{base}_rates.json' cache_writer = cache.CacheWriter(DIR_PATH, historical=filename_format) loader = loaders.LoaderChain() loader.add_loader(loaders.FileCache(DIR_PATH, historical=filename_format)) loader.add_loader(loaders.OXRAPIRequest(APP_ID_STRING)) with loader.historical(DATE, BASE_CODE_STRING) as json_response: hist_rate = rate.Rate.from_json_file(json_response) if loader.should_cache(): cache_writer.save_rate(hist_rate) # Rates are available from the hist_rate.rates dict.
Running tests
Run ./setup.py test from your checkout directory.