Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/81dr/ex_changerate

Elixir client for exchangerate platform API
https://github.com/81dr/ex_changerate

api-exchange-rates convert-currencies exchange-client

Last synced: 7 days ago
JSON representation

Elixir client for exchangerate platform API

Awesome Lists containing this project

README

        

# ex_changerate [![build](https://img.shields.io/travis/81dr/ex_changerate?style=flat-square)](https://travis-ci.org/81dr/ex_changerate) [![license](https://img.shields.io/hexpm/l/ex_changerate?style=flat-square)](https://github.com/81dr/ex_changerate/blob/master/LICENSE) [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat-square)](https://github.com/81dr/ex_changerate/issues) [![hex](https://img.shields.io/hexpm/v/ex_changerate?style=flat-square)](https://hex.pm/packages/ex_changerate)

Exchangerate is a free exchange & crypto rates API, no access key is required.

Development is made in accordance to available endpoint specs (see https://exchangerate.host/#/docs)

By default, the `api_instance` configuration is pointing to the widely-available public instance.

## Examples

Get latest rates:
```elixir
iex> ExChangerate.LatestRates.get
```

Convert currencies
```elixir
iex> ExChangerate.ConvertCurrency.get(from: "BTC", to: "USD")
```

Get historical rates from given date:
```elixir
iex> ExChangerate.HistoricalRates.get(date: "2020-01-01")
```

Display timeseries within given date range:
```elixir
iex> ExChangerate.Timeseries.get(start_date: "2020-04-01", end_date: "2020-04-30")
```

Retrieve information about how currencies fluctuate:
```elixir
iex> ExChangerate.Fluctuation.get(start_date: "2020-05-01", end_date: "2020-05-05")
```

Access list of currently available currencies:
```elixir
iex> ExChangerate.SupportedSymbols.get
```
----

Additional parameters can be provided if they are supported by given endpoint. Below techniques can be used depending on preferences, e.g. for converting currencies, comma separated:
```elixir
iex> ExChangerate.ConvertCurrency.get([from: "BTC", to: "USD"], amount: 2, date: "2020-04-04")
```
or equivalent by including `options`:
```elixir
iex> ExChangerate.ConvertCurrency.get([from: "BTC", to: "USD"], options: "amount=2&date=2020-04-04")
```

## Installation

```elixir
def deps do
[
{:ex_changerate, "~> 0.1"}
]
end
```