The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Introduction to fixerapi

Evan Odell

2018-08-23

Introduction

fixerapi is a package for accessing data from the fixer.io currency exchange rate API. The fixer.io API requires registration and the use of an API key. Free accounts are limited to 10,000 API calls a month, and can only access the most currency conversion rates, using the Euro as the base currency. For complete details, see the documentation on fixer.io.

Setting a key

Set your fixer.io API key with the fixer_api_key() function, or with Sys.setenv(FIXER_API_KEY = <key>). You can find your key on your fixer.io dashboard.

Setting an account type

If you have a paid account, setting your account type to “paid” with fixer_account_type("paid") switches to SSL connections over HTTPS, instead of the HTTP connection used by free accounts. Setting your account type does not have any other effects on your ability to use the fixer.io API. Features limited to certain levels of account are automatically limited by the Fixer API itself, and will return warning messages indicating as such.

Using fixerapi

To access a tibble with the name and currency symbol (a three letter code) for all currencies available through the API, use fixer_symbols().

There are five currency exchange query types, which fixer.io calls endpoints. They are:

With the exception of fixer_convert(), which is limited to two currencies, all functions give an option for a base currency that is indexed to 1 and other currencies are compared to – the default is the Euro – and an option to limit the currencies it is compared with, using the symbols parameter, which takes a character vector of currency symbols. If no symbols are specified, all available currencies are returned.

library(fixer)
today_symbols <- fixer_latest(base = "EUR", 
                              symbols = c("JPY", "GBP", "USD", "CAD", "CHF"))

print(today_symbols)

#> A tibble: 5 x 2
#>   name    value
#>   <chr>   <dbl>
#> 1 JPY   131.   
#> 2 GBP     0.873
#> 3 USD     1.23 
#> 4 CAD     1.57 
#> 5 CHF     1.18 


today_all <- fixer_latest(base = "EUR")

print(today_all)

#> A tibble: 168 x 2
#>    name   value
#>    <chr>  <dbl>
#>  1 AED     4.51
#>  2 AFN    84.9 
#>  3 ALL   130.  
#>  4 AMD   589.  
#>  5 ANG     2.18
#>  6 AOA   263.  
#>  7 ARS    24.7 
#>  8 AUD     1.60
#>  9 AWG     2.18
#> 10 AZN     2.09
#> ... with 158 more rows

The example above shows the exchange rates on 2018-04-03.

Free accounts are limited to the fixer_latest() function, and cannot change the base currency. Free accounts come with 10,000 calls per month, paid accounts with more, depending on the level of the paid account.

Full documentation for the API itself is available on the Fixer website, along with the signup.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.