This is the beginnings of an API client for the YNAB online budget software. This is not even in “alpha” yet, as there are many function to adjust and add. The first stage of this project is to make it easy to pull all of your budget and bank account data from the YNAB API (v1) into R so that you can analyze it. This package tries to be tidy verse friendly, returning data frames where ever possible.
It is currently functional to pull a dump of your data of your bank transactional data. Follow the steps below to get set up:
install.packages("devtools")
devtools::install_github("joxborrow/ynabr")
Setup developer access to YNAB and obtain an personal access token. This can be done at the following address https://api.youneedabudget.com/#personal-access-tokens. The access token is a 64 bit long alpha numeric that is required to download data.
Set the personal access token for usage.
ynab_set_token()
function.
Sys.setenv(YNAB_TOKEN = "<ynab token>")
ynab_set_token()
ynab_set_token()
function as shown below. Note that having a token directly in your code is a bad security practice.
ynab_set_token("<ynab token>")
ynab_list_budgets()
function. This returns and prints a data frame of the available budgets that can be downloaded.ynab_list_budgets
you can download all of the budgets associated data. This returns a object of class "budget_data"
that is used as the input for other functions in the package. It is an extensive list containing all budget and account data downloaded from YNAB.
bd <- ynab_get_budget("<budget name or id>")
Once you have downloaded a budget and assigned it to a variable, you can then extract account information for all account using the ynab_get_account_data()
function.
ac <- ynab_get_account_data(bd)
Note that this downloads account data in your YNAB account. This includes reconciled, cleared, and uncleared transactions. This will not necessarily match data against your true bank account as uncleared transactions, and differing dates may be different.