knitr::opts_chunk$set(echo = TRUE) library(freeCurrencyApiR)
freeCurrencyApiR provides functions for getting current and historical currency exchange rates. Please refer to The Free Currency Converter API https://free.currencyconverterapi.com for all endpoints available and rate limits.
From the website:
Rate Limits of the Free API Conversion Pairs per Request: 2 Number of Requests per Hour: 100 Date Range in History: 8 Days Allowed Back in History: 1 Year(s) Currency values are updated every 60 minutes. If you need a realtime web service or a service that updates more frequently, you may checkout the premium service at CurrencyConverterAPI.com.
devtools::install_github("raybuhr/freeCurrencyApiR")
This is only required once, right after install.
You will need to signup to get an API key. Once you get the email with your key and confirm your email address by clicking through the included link, add this key to your .Renviron
. If you are unfamiliar with this, you can run
usethis::edit_r_environ()
This will open up the .Renviron
file for you to edit. Add a new line like this
FREE_CURRENCY_API_KEY=c224f8b5ee2f30e42256
Restart your R Session.
Get lists of the countries and currencies available:
currencies <- free_currency_api_list_currencies() currencies$results[[1]]
countries <- free_currency_api_list_countries() countries$results[[42]]
Get the current exchange rate between two currencies (based on a 60 minute refresh cache):
free_currency_api_get_current(currency_from = "USD", currency_to = "CNY", compact = "ultra")
Get a data.frame
of daily historical exchange rates between two currencies (No idea when the daily rate snapshot is taken):
free_currency_api_get_historical( currency_from = "USD", currency_to = "INR", start_date = "2018-04-01", end_date = "2018-04-08" )
Report at https://github.com/raybuhr/freeCurrencyApiR/issues
Feel free to provide pull requests!
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.