Wrapper for the National Bank of Poland API

Use the < https://api.nbp.pl/> API through R. Retrieve currency exchange rates and gold prices data published by the National Bank of Poland in form of convenient R objects.


rnbp

R-CMD-check CRANversion Cran totaldownloads

The rnbp package is an R wrapper for the National Bank of Poland API: https://api.nbp.pl/

Installation

The rnbp package is available on CRAN, you can install it with:

install.packages("rnbp")

You can install the the development version of rnbp from GitHub with:

# install.packages("devtools")
devtools::install_github("szymanskir/rnbp")

Retrieve the currently effective exchange rate table

library(rnbp)
library(ggplot2)

## Retrieve current C exchange rate table
response <- get_current_exchangerate_table("C")

## Retrieve content from the response
current_exchangerate_table <- response$content$rates[[1]]

ggplot(current_exchangerate_table, aes(x = code, y = bid, fill = code)) +
  geom_bar(stat = "identity")

Retrieve exchange rates for specific currencies

## Retrieve last 20 exchange rates for euros
euros_response <- get_last_n_exchangerates("A", "EUR", 20)

## Retrieve last 20 exchange rates for euros
dollars_response <- get_last_n_exchangerates("A", "USD", 20)

## Retrieve rates data
euros_data <- euros_response$content$rates
dollars_data <- dollars_response$content$rates

## Add currency code columns
euros_data$code <- euros_response$content$code
dollars_data$code <- dollars_response$content$code
currency_data <- rbind(euros_data, dollars_data)

ggplot(currency_data, aes(x = effectiveDate, y = mid, col = code)) +
  geom_line() +
  geom_point()

Retrieve gold prices

current_date <- Sys.Date()
response <- get_goldprice_from_interval(current_date - 90, current_date)

ggplot(response$content, aes(x = data, y = cena)) +
  geom_point() +
  geom_line() +
  geom_smooth(method = "loess", formula = y ~ x)

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("rnbp")

0.2.2 by Ryszard Szymanski, 2 years ago


https://github.com/szymanskir/rnbp


Report a bug at https://github.com/szymanskir/rnbp/issues


Browse source code at https://github.com/cran/rnbp


Authors: Ryszard Szymanski [aut, cre]


Documentation:   PDF Manual  


GPL-3 license


Imports curl, httr, jsonlite, utils

Suggests covr, httptest, testthat, knitr, rmarkdown, ggplot2


See at CRAN