Learn R Programming

qbr

The goal of qbr is to make it easy to interact with Quickbase’s JSON API.

Installation

You can install the development version of qbr like so:

 library(devtools)
 install_github("BHII-KSC/qbr")

Functions

API pageFunctionDescription
Usersget_usersReturns a tibble with details of each user in an account
User tokenclone_tokenCopy a usertoken
User tokendeactivate_tokenDeactivate a usertoken
User tokendelete_tokenDelete a usertoken
Appsget_appGet metadata for an app
Appscopy_appCopy an app
Appsdelete_appDelete an app
Appsget_app_eventsReturns a tibble of triggerable events
Tablesget_tablesGet metadata for all tables in an app
Fieldsget_fieldsGet metadata for all fields in a table
Fieldsdelete_fieldsDelete one or more fields in a table
Reportsget_reportReturns a named list of metadata for the specified report
Reportsget_reportsReturns a tibble of metadata for each report in a table
Reportsrun_reportReturns a tibble containing all data in the specified report
Recordsdelete_recordsDeletes records matching query conditions
Recordsupdate_recordsInserts and/or updates record(s)
Recordsquery_recordsReturns a tibble with data matching query conditions
N/Asummarize_appGet metadata for an app and its users, tables, and fields

Usage

It is often cumbersome to manually download data from Quickbase to work on it in R. run_report makes it easy to extract report data via the Quickbase JSON API:

library(qbr)

# Get data from a Quickbase report as a tibble
run_report(subdomain = "bhi",
       auth = keyring::key_get("qb_example"),
       table_id = "bn9d8iesz",
       report_id = "7")
#> # A tibble: 10 × 5
#>    `Record ID#` `Date assessed` `Respondent type` Intuitive           Accessible
#>           <int> <chr>           <chr>             <chr>               <chr>     
#>  1            3 2018-12-19      "Evaluator"       "1 - Strongly disa… "2 - Some…
#>  2           28 2023-09-15      ""                ""                  ""        
#>  3           29 2023-09-15      ""                ""                  ""        
#>  4            1 2018-12-19      "Data analyst"    "5 - Strongly agre… "4 - Some…
#>  5            2 2018-12-19      "Data analyst"    "4 - Somewhat agre… "4 - Some…
#>  6            4 2018-12-19      "Evaluator"       "3 - Neutral"       "4 - Some…
#>  7            5 2019-11-27      "Data analyst"    "2 - Somewhat disa… "4 - Some…
#>  8           20 2019-12-04      "Data analyst"    "2 - Somewhat disa… "3 - Neut…
#>  9           24 2023-09-14      ""                ""                  ""        
#> 10           25 2023-09-14      ""                ""                  ""

Notice that this function returns a tibble even though the payload from Quickbase is non-tabular JSON. This function extracts data from the Quickbase report (recursively if needed to handle the API’s auto-pagination) and then makes the data tidy using ‘tidyverse’ principles.

If you don’t know the report ID of the report you want to retrieve data from, you can use get_reports to retrieve metadata about all reports in a table:

library(qbr)

get_reports(subdomain = "bhi",
            auth = keyring::key_get("qb_example"),
            table_id = "bn9d8iesz")
#> # A tibble: 7 × 13
#>   description        id    name  type  usedCount usedLast properties.displayOn…¹
#>   <chr>              <chr> <chr> <chr>     <int> <chr>    <lgl>                 
#> 1 ""                 6     Aspi… table        11 2024-09… FALSE                 
#> 2 ""                 5     Find… table        62 2023-09… FALSE                 
#> 3 ""                 1     List… table        36 2025-01… FALSE                 
#> 4 "Sorted by Date M… 2     List… table         0 <NA>     TRUE                  
#> 5 ""                 9     qbr … table         4 2024-09… FALSE                 
#> 6 ""                 7     qbr … table        66 2025-01… FALSE                 
#> 7 ""                 8     qbr … table        29 2024-09… FALSE                 
#> # ℹ abbreviated name: ¹​properties.displayOnlyNewOrChangedRecords
#> # ℹ 6 more variables: query.fields <list>, query.filter <chr>,
#> #   query.formulaFields <list>, query.groupBy <list>, query.sortBy <list>,
#> #   query.tableId <chr>

It’s sometimes helpful to manage user tokens programmatically:

library(qbr)

# Clone a user token. The 'clone_name' must be unique. 
token <- clone_token(subdomain = "bhi", 
                     auth = keyring::key_get("qb_example"),
                     clone_name = "My new token",
                     clone_desc = "A token cloned by an R script")

# The token passed to 'auth' is deleted. Token supplied must be active.
delete_token(subdomain = "bhi", auth = token)
#> Token deleted

You can manage apps using the app functions:

library(qbr)

# Copy an app and print the new app's ID
app <- copy_app(subdomain = "bhi",
                auth = keyring::key_get("qb_example"),
                app_id = "bn9d8f78g",
                app_name = "R Testing copy",
                app_desc = "Used to test copy_app() from qbr package",
                keep_data = TRUE)

print(app$id)
#> [1] "butjcrxzi"

# Delete the newly created app
delete_app(subdomain = "bhi",
           auth = keyring::key_get("qb_example"),
           app_id = app$id,
           app_name = app$name)
#> $deletedAppId
#> [1] "butjcrxzi"

# Get the triggerable events of an app
get_app_events(subdomain = "bhi",
               auth = keyring::key_get("qb_example"),
               app_id = "bn9d8f78g")
#> # A tibble: 2 × 8
#>   type    isActive tableId  name  owner.email owner.id owner.name owner.userName
#>   <chr>   <lgl>    <chr>    <chr> <chr>       <chr>    <chr>      <chr>         
#> 1 webhook TRUE     bp5gg5b… Push… john.erdma… 5962446… John Erdm… jerdmann      
#> 2 webhook TRUE     bp84kms… GET … john.erdma… 5962446… John Erdm… jerdmann

Complex data types

This packages returns some field types slightly differently to a Quickbase report:

Field typeReturned data type
Multi-select textSemicolon-separated text
UserUser’s email address
List-userSemicolon-separated email addresses

Limitations

Some extended ASCII characters (codes 128-255) cannot be properly parsed when converting from JSON at present, such as ’ (&#146). Reports containing text and rich-text fields are the most likely to suffer an error resulting from the use of these extended characters.

This package makes no attempt to convert data types. Number fields in Quickbase may well be interpreted in the resulting tibble as characters. The run_report function does provide a type_suffix argument to allow you to discern the intended datatype more easily.

Copy Link

Version

Install

install.packages('qbr')

Monthly Downloads

1,673

Version

1.3.0

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

John Erdmann

Last Published

January 10th, 2025

Functions in qbr (1.3.0)

get_tables

Get all tables
get_report

Get a report
get_users

Get users
update_records

Insert/Update records
summarize_app

Summarize an app
get_reports

Get all reports for a table
query_records

Query for data
qb_run

Run a Quickbase report
qbr-package

qbr: Access the 'Quickbase' JSON API
run_report

Run a report
get_fields

Get all fields in a table
delete_app

Delete an app
delete_token

Delete a user token
deactivate_token

Deactivate a user token
delete_fields

Delete field(s) in a table
get_app_events

Get app events
copy_app

Copy an app
delete_records

Delete records
clone_token

Clone a user token
get_app

Get an app