Package 'fixerapi'

Title: An R Client for the "Fixer.io" Currency API
Description: An R client for the "fixer.io" currency conversion and exchange rate API. The API requires registration and some features are only available on paid accounts. The full API documentation is available at <https://fixer.io/documentation>.
Authors: Evan Odell [aut, cre]
Maintainer: Evan Odell <[email protected]>
License: MIT + file LICENSE
Version: 0.1.6.9000
Built: 2024-10-31 16:33:18 UTC
Source: https://github.com/evanodell/fixerapi

Help Index


Set account type

Description

Paid accounts have access to additional features, including SSL encryption of API requests using HTTPS. Account type must be set in order to use HTTPS requests. Setting account type to "paid" when using a free account will result in an error, even on features available to free accounts. Setting account type to "free" when using a paid account will have no impact on requests aside from using HTTP instead of HTTPS to access the API. If you have a paid account but do not set your account status you will not be able to use the HTTPS connection but there will be no other impact on your usage of the API.

The fixer.io API still checks the account type when receiving requests, so setting you account type here only forces HTTPS instead of HTTP.

Setting the environmental variable FIXER_ACT_TYPE to one of "free" or "paid" will negate the need to use this function every time the package is used.

Usage

fixer_account_type(type = c("free", "paid"))

Arguments

type

Your fixer.io account type. Accepts one of "free" or "paid". If no value or an incorrect value is given, account type will be set as "free". This parameter is not case sensitive.

Examples

## Not run: 
fixer_account_type("paid")

## End(Not run)

Fixer API Key

Description

fixer.io requires an API key, which is saved as an environmental variable. In interactive mode, using fixer_api_key will prompt you to enter an API key. You can also use Sys.setenv(FIXER_API_KEY = <key>) to set the API key.

Usage

fixer_api_key(force = FALSE)

Arguments

force

If TRUE, resets the API key and requires a new key to be provided, even if one already exists. If FALSE and an API key already exists, that key will be printed to the console. If no key exists, you will be prompted to enter a key regardless of the value of force. Defaults to FALSE.

Details

By default fixerapi will look for the environment variable FIXER_API_KEY when the package is loaded.


Convert currencies

Description

Convert from one currency to another, on a given date or using the latest available exchange rates.

Currency conversion is available on all paid plans.

Usage

fixer_convert(from, to, amount = 1, date = NULL)

Arguments

from

Symbol of currency to convert from.

to

Symbol of currency to convert to.

amount

The numeric value of the from currency to convert. Defaults to 1, and accepts integers greater than 0 and less than 100000.

date

Optional variable. A date in YYYY-MM-DD format, or any value that can be coerced to YYYY-MM-DD format with as.Date(). Defaults to NULL, which returns the latest conversion data.

Value

A list containing the value of the conversion, the exchange rate and the date and time of the currency conversion.

Examples

## Not run: 

x <- fixer_convert(from = "GBP", to = "JPY", amount = 25)

y <- fixer_convert(from = "GBP", to = "JPY",
                   amount = 25, date = "2018-05-05")


## End(Not run)

Currency fluctuation

Description

Returns fluctuation in currency exchange rates for one or more currencies compared to the base currency over a given period of time. The maximum time frame is 365 days.

Currency fluctuation data is only available for "Professional Plus" and "Enterprise" accounts.

Usage

fixer_fluctuation(start_date, end_date, base = "EUR", symbols = NULL)

Arguments

start_date

The start date of requested time series, in "YYYY-MM-DD" style, or any style convertable to "YYYY-MM-DD" using as.Date().

end_date

The end date of requested time series, in "YYYY-MM-DD" style, or any style convertable to "YYYY-MM-DD" using as.Date().

base

The base currency to index other currencies against. Defaults to "EUR". Other base currencies are only available on paid plans.

symbols

A character vector of the symbols of currencies to return exchange rates for, or a string for a single currency. Defaults to NULL and returns all available currencies. See fixer_symbols() for details on symbol options.

Value

A tibble with the currency symbol, start rate, end rate, change and change percentage over the requested time period. Each currency is given its own row, with start rate, end rate, change and change percentage each in their own columns.

See Also

fixer_time_series()

Examples

## Not run: 

x <- fixer_fluctuation(start_date = "2018-02-25", end_date = "2018-02-26",
                       symbols = c("USD", "JPY"))


## End(Not run)

Historic exchange rates

Description

Historical exchange rates are only available on paid fixer.io accounts.

Usage

fixer_historical(date = NULL, base = "EUR", symbols = NULL)

Arguments

date

A date in YYYY-MM-DD format, or any value that can be coerced to YYYY-MM-DD format with as.Date(). Defaults to NULL, which returns the latest conversion data.

base

The base currency to index other currencies against. Defaults to "EUR". Can only be changed with paid plans.

symbols

The symbols of currencies to return exchange rates for. Defaults to NULL and returns all available currencies. See fixer_symbols] for details on symbol options.

Value

A tibble with exchange rates to the base currency on a given date.

Examples

## Not run: 

historical <- fixer_historical(date = "2017-05-18")


## End(Not run)

Latest exchange rates

Description

Returns a tibble with the most recently available currency conversion data available from the Fixer API.

Usage

fixer_latest(base = "EUR", symbols = NULL)

Arguments

base

The base currency to index other currencies against. Defaults to "EUR". Other base currencies are only available on paid plans.

symbols

A character vector of the symbols of currencies to return exchange rates for, or a string for a single currency. Defaults to NULL and returns all available currencies. See fixer_symbols() for details on symbol options.

Value

A tibble with the latest available currency exchange data.

Examples

## Not run: 

today <- fixer_latest()

today_usd <- fixer_latest(base = "USD")

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


## End(Not run)

Currency symbols

Description

Returns a tibble with the symbol and name of all currencies available through the Fixer API.

Usage

fixer_symbols()

Exchange rate time series

Description

Time series plans are only available on "professional" and above plans. The maximum allowed length in a single request is 365 days.

Each currency symbol is displayed in its own column, with a value relative to the base currency on the given date.

Time series data is only available for "Professional", "Professional Plus" and "Enterprise" accounts.

Usage

fixer_time_series(start_date, end_date, base = "EUR", symbols = NULL)

Arguments

start_date

The start date of requested time series, in "YYYY-MM-DD" style, or any style convertable to "YYYY-MM-DD" using as.Date().

end_date

The end date of requested time series, in "YYYY-MM-DD" style, or any style convertable to "YYYY-MM-DD" using as.Date().

base

The base currency to index other currencies against. Defaults to "EUR". Other base currencies are only available on paid plans.

symbols

A character vector of the symbols of currencies to return exchange rates for, or a string for a single currency. Defaults to NULL and returns all available currencies. See fixer_symbols() for details on symbol options.

Value

A tibble with the exchange rate from the base currency to the given currency symbols for each date in the requested range.

See Also

fixer_fluctuation()

Examples

## Not run: 

x <- fixer_time_series(start_date = "2017-04-30", end_date = "2017-06-20",
                       base = "GBP", symbols = c("USD", "EUR"))


## End(Not run)

fixerapi: an R client for the fixer.io currency api

Description

The fixer.io API provides real-time exchange rates for 170 currencies, covering 1999 to the present. fixer.io requires an account and a private key, and most features require a paid account. See the full API documentation for more details on account features and pricing.