The classic API is probably the most intuitive to R users.

Setup

First, set up your session with the setup function. The function will let you pass your api_key (required), and optionally a base, and a table. Here we set up the session for the demo “Employee Onboarding” base.

Here we set up the session for the demo “Employee Onboarding” base and its “Onboarding Checklist” table.

library(rtable)
setup(api_key = "xxXXxxxXXx", base = "appfSQILnns4mrSUr", table = "Onboarding Checklist")

Note that you can set up your api_key as a global variable by adding the option below to your .Renviron or .Rprofile.

options("RTABLE_API_KEY" = "xXxxXXXxx")

You can check what has been set up with.

get_setup()

You can always reset the setup with reset_setup.

Create

We can create a new record with create_records

df <- data.frame(Name = "It's me")
created <- create_records(df)

To demonstrate that it worked we can retrieve it again with retrieve_record

(rec <- created[[1]]$id) # we'll need it later
#> [1] "recwLOH4KysxwOZF1"
retrieve_record(rec)

Update

We can update records with update_record. Let’s update the one we just created.

df <- data.frame(Name = "It's me again!", record_id = rec)
updated <- update_records(df, record_id)

We’ll retrieve the record we updated and see if it matches the one we updated.

updated_record <- retrieve_record(rec)
identical(list(updated_record), updated)
#> [1] TRUE

Delete

Finally, we can delete the record we created and updaed.

delete_record(rec)

Then retrieving the deleted record should error as the record we want to retrieve is inexistent.

retrieve_record(rec)