OpenExchangeRates

Build StatusCoverage StatusDeps Status

This Elixir library uses the openexchangerates.org API to retieve the latest exchange rates.

At initialization of the library, it will use the latest exchange rates from a cache file. After initialization it will immediately try to get the latest exchange rates from openexchangerates.org. If this fails it will retry to get a new update every minute.

After a successful update, it will check every minute if the cache needs to be updated and fetches the new rates from openexchangerates.org. You can configure the cache time, which by default is 24 hours. Please take in account that every check will be taking credits from your API usage.

To be able to use this library you will need an API token from openexchangerates.org which you can get here.

Using it without an API key

This library will still function without a connection to the openexchangerates.org API but please take into account the exchanges rates are coming from an (outdated) cache. This cache will be updated with every release of this library.

Example usage

This library gives you the following functions :

Installation

If available in Hex, the package can be installed as:

  1. Add open_exchange_rates to your list of dependencies in mix.exs:
```elixir
def deps do
  [{:open_exchange_rates, "~> 0.1.0"}]
end
```
  1. Ensure open_exchange_rates is started before your application:
```elixir
def application do
  [applications: [:open_exchange_rates]]
end
```

Configuration

Please add the following config to your config.exs

config :open_exchange_rates,
  app_id: "MY API KEY",
  cache_time_in_minutes: 1440 #24 hours

Testing the library

Before you run the tests, please make sure to set the OER_APP_ID environment to you app_id key.