Title: | Efficient Wrapper for the 'Airtable' API |
---|---|
Description: | Efficient CRUD interface for the 'Airtable' API <https://airtable.com/developers/web/api>, supporting batch requests and parallel encoding of large data sets. |
Authors: | Matthew Rogers [aut, cre] |
Maintainer: | Matthew Rogers <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.2 |
Built: | 2024-11-03 03:04:05 UTC |
Source: | https://github.com/matthewjrogers/rairtable |
Creates an S3 airtable object, which serves as a pointer for rairtable functions
airtable( table, base, view = NULL, api_url = "https://api.airtable.com", api_version = 0 )
airtable( table, base, view = NULL, api_url = "https://api.airtable.com", api_version = 0 )
table |
Table name in Airtable |
base |
Airtable base containing table. A base functions like a schema in a traditional database. You can retrieve the base ID from the API documentation. |
view |
Optional view of data to read |
api_url |
API endpoint to connect to. Can be changed for API integrations that require custom endpoint |
api_version |
Version of API to use. Defaults to 0 (the current version as of Fall 2021) |
An airtable object
## Not run: table <- airtable("Table 1", "appXXXXXXXXXXXXX") ## End(Not run)
## Not run: table <- airtable("Table 1", "appXXXXXXXXXXXXX") ## End(Not run)
Delete records in an Airtable table based on their Airtable record ID.
delete_records( data, airtable, airtable_id_col = "airtable_record_id", safely = TRUE, batch_size = 10 )
delete_records( data, airtable, airtable_id_col = "airtable_record_id", safely = TRUE, batch_size = 10 )
data |
A data frame containing records to delete |
airtable |
An airtable object |
airtable_id_col |
Column containing Airtable record IDs. Not required if record IDs are stored in row names as returned from |
safely |
If |
batch_size |
Number of requests to send at a time. Maximum of 10. |
A vector of IDs deleted
Insert rows into an Airtable table. Requires that data names and types exactly match column names and types in Airtable. Violating this assumption will return a 422 Unprocessable Entity error. Supports batch insert and parallel JSON encoding (recommended for large tables).
insert_records( data, airtable, typecast = FALSE, parallel = FALSE, batch_size = 10 )
insert_records( data, airtable, typecast = FALSE, parallel = FALSE, batch_size = 10 )
data |
A dataframe containing records to insert |
airtable |
An airtable object |
typecast |
If |
parallel |
If |
batch_size |
Number of records per request to insert. Maximum of 10 |
A dataframe (invisibly) of the input data, to be stored as an object or piped into further 'dplyr' functions
Connect to and read values from an Airtable table.
read_airtable(airtable, fields = NULL, id_to_col = TRUE, max_rows = 50000)
read_airtable(airtable, fields = NULL, id_to_col = TRUE, max_rows = 50000)
airtable |
An airtable object |
fields |
An optional list of fields to select. |
id_to_col |
If TRUE, store airtable ID as a column rather than as row names |
max_rows |
Optional maximum number of rows to read |
A dataframe containing the data read from the specified 'Airtable' table
Set Airtable API key as an environment variable, and optionally install the API key to your .Renviron file for future use.
set_airtable_api_key(key, install = FALSE)
set_airtable_api_key(key, install = FALSE)
key |
A valid Airtable API key |
install |
Add your API key to .Renviron for future sessions. Optionally overwrite an existing Airtable API key. |
No return value, called for side effects
## Not run: airtable_api_key("XXXXXXXXXX", install = TRUE) ## End(Not run)
## Not run: airtable_api_key("XXXXXXXXXX", install = TRUE) ## End(Not run)
Update one or more columns of data in an Airtable table. Supports batch updates and parallel JSON encoding (recommended for large tables).
update_records( data, airtable, columns = dplyr::everything(), airtable_id_col = "airtable_record_id", safely = TRUE, parallel = FALSE, batch_size = 10 )
update_records( data, airtable, columns = dplyr::everything(), airtable_id_col = "airtable_record_id", safely = TRUE, parallel = FALSE, batch_size = 10 )
data |
A dataframe containing the records and fields to update |
airtable |
An airtable object |
columns |
Columns in the data to update on Airtable. Can be a vector of character strings, unquoted column names, or a |
airtable_id_col |
Column containing Airtable record IDs. Not required if record IDs are stored in row names as returned from |
safely |
If |
parallel |
If |
batch_size |
Number of records to update per request. Maximum of 10 |
A dataframe (invisibly) of the input data, to be stored as an object or piped into further 'dplyr' functions