Hey, just released a small library called Forex, to retrieve the European Central Bank daily exchange rates.
The idea behind the library is to provide a simple, no API keys, no authentication, no rate limits, just a simple Elixir library that fetches the data from the European Central Bank and caches it for later use.
With this said take into account this is not aimed at building any type of transactional app, financial applications or any type of application that relies on to the second foreign exchange rates. The reference rates from the ECB are usually updated at around 16:00 CET every working day. This is useful for information purposes, for example, you might want to show on your job board how much is the role salary range in the user’s local currency, etc.
Usage
By default the base
currency is the Euro (EUR), the same as the European Central Bank,
but you can change the base currency by passing the base
option to the relevant functions.
Sample Usage
To fetch the latest exchange rates, you can use the current_rates/1
function:
iex> Forex.current_rates()
{:ok,
%{
base: :eur,
date: ~D[2025-03-12],
rates: %{
usd: Decimal.new("1.1234"),
jpy: Decimal.new("120.1234"),
...
zar: Decimal.new("24.1442")
}}
}
If you use it and found a bug or have any suggestion, don’t hesitate to create an issue or post here.
Thanks,
Nuno F.
Hex: forex | Hex
Repo: