- 26 Jul 2024
- 6 Minutes to read
- Print
- DarkLight
- PDF
Airtable
- Updated on 26 Jul 2024
- 6 Minutes to read
- Print
- DarkLight
- PDF
Airtable API
Any instance where an entry in the below configuration has a leading $ represents a parameter that needs to be replaced with a static value.
Parameters in this document:
- $base_id and $table_id - The Base ID and Table ID can be found in the URL when a base is open, as described here under the
Finding base URL IDs
section. Base IDs will begin withapp
, while Table IDs will begin withtbl
. - $personal_access_token - Personal Access Tokens are used to authenticate requests to the Airtable API, and will begin with
pat
. Personal Access Tokens can be created here, complete documentation on Personal Access Tokens can be found here. To create a Personal Access Token:- From here, click the “Create new token” button to create a new Personal Access Token.
- Give your token a unique name. As this name will be visible in record revision history, we recommend including a reference to Panoply in this name so you are able to easily isolate calls made from our platform.
- Choose the scopes to grant to your token, which will grant access to different API endpoints. We recommend at least adding the
data.records:read
scope, as this will be the minimum to access data outlined in the below configuration - Click ‘add a base’, which will grant the token access to a base or workspace. If you would like to ensure all future bases/tables are useable within Panoply automatically, use
All current and future bases in all current and future workspaces
. - Once your token is created, Airtable will only show you the value once, so be sure to store it in a secure location so you can reference it in the future if needed.
- $timezone - For a list of supported timezone identifiers from Airtable, see here. An example of a value for this parameter is
America/New_York
. - $user_locale - For a list of supported user locales from Airtable, see here. An exampe of a value for this parameter is
en-us
.
Array Fields
When an Airtable table has any fields that are of Linked record, Lookup, or Multiple select type, the field values in the API response will be in an array, such as:
{
"records": [
{
"id": "exampleid",
"createdTime": "2024-01-01T00:00:00.000Z",
"fields": {
"Example Array": [
"value1",
"value2"
]
}
}
]
}
When only one array is present in a response, Panoply allows for the ability to flatten this value if desired, which will be explained further below. However, when multiple arrays are present in the response, then each field will result in a new sub-table, such as the following:
{
"records": [
{
"id": "exampleid",
"createdTime": "2024-01-01T00:00:00.000Z",
"fields": {
"Example Array 1": [
"value1",
"value2",
]
"Example Array 2": [
"value3",
"value4",
]
}
}
]
}
where the result would be tables fields_example_array_1
and fields_example_array_2
, with each table have two values that are linked to the exampleid
. This can work just fine, however when querying the data and joining multiple sub-tables that were created from an array field, this can lead to duplicates in the resulting query, and should be done with caution of such possibilities.
All of this leads to multiple approaches to configuring an Airtable Flex Connector in Panoply, all of which will be outlined below. If there are any questions regarding a given configuration, or which may best fit your end goals with the data resulting from this configuration, please reach out to our Support Team and we would be happy to assist as needed.
1. If none of the fields in the table being ingested are of Linked record
, Lookup
, or Multiple select
type, please follow the Standard Configuration
options below, which will essentially ingest the data as if it was a normal table with no special considerations.
2. If one of the fields in the table being ingested is of Linked record
, Lookup
, or Multiple select
type and you would like to flatten the array, please follow the Flatten Array
options below. Please note, when flattening an array on a table, this will result in a number of duplicate records equal to the number of values in the array. For example, using the same single-array example from above, the resulting table would be:
id | createdTime | fields_example_array |
---|---|---|
exampleid | 2024-01-01T00:00:00.000Z | value1 |
exampleid | 2024-01-01T00:00:00.000Z | value2 |
3. If multiple fields in the table being ingested is of Linked record
, Lookup
, or Multiple select
type, there are two options available for ingestion:
- 3a: Only Available for BigQuery Panoply Accounts - If you would like the data within the fields object to be kept as JSON when ingested, please follow the
JSON
options below. This will create a column calledfields
that preserves the JSON formatting from the API response, which can then be queried. Please note that this querying will be slightly more complex than a normal SQL query, so if you are aiming for a solution that doesn't require much SQL experience, this may not be the best option. - 3b: If you would like the data within the fields object to be treated as strings instead of arrays, please follow the
Strings
options below. This is a native option to Airtable and converts the array fields into strings. Using the second example from above with multiple arrays, the API response would instead be:
thus resulting in just a single{ "records": [ { "id": "exampleid", "createdTime": "2024-01-01T00:00:00.000Z", "fields": { "Example Array 1": "value1, value2" "Example Array 2": "value3, "value4" } } ] }
fields
table and that contains a single column for each of the fields. If you are looking to simplify your SQL querying requirements and don't care about preserving the array structure of the API response, this would be the ideal option.- Please note that as part of this option, fields that have multiple parts to them resulting in a new JSON level in the API response, such as the Button Field, will result in a change to how much information is contained in the API response, which may or may not be meaningful to your business case. As you can see from the below examples, the
label
value ofTest
is not present in theStrings
response, and instead only theurl
value ofDone
appears:
Non-Strings Response
Strings Response
- Please note that as part of this option, fields that have multiple parts to them resulting in a new JSON level in the API response, such as the Button Field, will result in a change to how much information is contained in the API response, which may or may not be meaningful to your business case. As you can see from the below examples, the
Connector configuration
- Base url: https://api.airtable.com/v0/$base_id / $table_id
- Method: GET
When using the Strings
option above (3b), set the URL Parameters to the following:
timeZone=$timezone&userLocale=$user_locale&cellFormat=string
- URL Parameters: pageSize=100
Destination Table naming convention is ultimately up to you as the data owner. One common structure used for this API is to append the Table Name to airtable_
. For example, if your Table Name is Example Table
, then your Destination Table value would be airtable_example_table
.
Authorization
- Authorization: Bearer Token
- Token: $personal_access_token
Pagination
- Enable:
- Get next page value: Dynamic (next page value included in the response)
- Next page key in response: offset
- Use next page value: As a URL parameter value
- URL/body key: offset
- Stop iterating when: No next page in response
Advanced Settings
- Data key: records
When using the Flatten Array
option above (2), set the Array to flatten
value to the column name that is of Linked record
, Lookup
, or Multiple select
type, appended to fields.
. For example, if the column's name is example
, the Array to flatten
value should be set to fields.example
.
Only Available for BigQuery Panoply Accounts
When using the JSON
option above (3a), set the Nested Data -> Default Behavior to Ingest as JSON data type
.