Skip to content

Periodically send request to https://free.currencyconverterapi.com without exceeding "Requests per Hour" limit and cache the result. Useful for application that don't need realtime and accurate conversion rate.

License

Notifications You must be signed in to change notification settings

suryavip/caching-free.currencyconverterapi.com-python

Repository files navigation

Caching free.currencyconverterapi.com

Periodically send request to https://free.currencyconverterapi.com without exceeding "Requests per Hour" limit and cache the result. Useful for application that don't need realtime and accurate conversion rate.

Setup

  1. Fullfill the pip requirements by doing:

    pip install -r requirements.txt

  2. Make sure you have your own API key from https://free.currencyconverterapi.com
  3. Put your API key into apikey.txt file
  4. Adjust your baseCurrency in config.py
  5. Adjust your numberOfRequests in config.py. This will control how much request to be sent every time create_cache.py run. For example, if I set a cron job to run create_cache.py every 5 minutes, there will be 72 request sent in 1 hour (60 minutes / 5 minutes * 6 requests) which is still below the 100 requests per hour limit. Since each request will ask for 2 pairs of currency, 144 pairs will be updated every hour.
  6. Run update_currencies.py to get all currencies offered by https://free.currencyconverterapi.com. You can remove currencies that you don't need from currencies.json.

Usage

Run create_cache.py periodically (use script or cron job). In my case, I run it once every 5 minutes. Run app.py to start the Flask server (or use passenger) to serve the cached result:

  1. GET currency will return all cached currencies
  2. GET curerncy/XXX/YYY will return the rate for XXX and YYY pair.

About

Periodically send request to https://free.currencyconverterapi.com without exceeding "Requests per Hour" limit and cache the result. Useful for application that don't need realtime and accurate conversion rate.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages