Modules@robinpath/airtable
airtable

@robinpath/airtable

0.1.2Node.jsPublic

Airtable module for RobinPath.

Airtable

Airtable module for RobinPath.

Package: @robinpath/airtable | Category: Productivity | Type: Integration

Authentication

airtable.setToken "default" "patXXXXXXXXXXXXXX"

Call this once at the start of your script before using any other function. Credentials persist for the duration of the script execution.

Use Cases

Use the airtable module when you need to:

  • List all bases accessible by the configured token -- Use airtable.listBases to perform this operation
  • Get the schema (tables and fields) for a base -- Use airtable.getBaseSchema to perform this operation
  • List records from a table with optional filtering, sorting, and pagination -- Use airtable.listRecords to perform this operation
  • Get a single record by ID -- Use airtable.getRecord to perform this operation
  • Create a single record in a table -- Use airtable.createRecord to perform this operation

Quick Reference

FunctionDescriptionReturns
setTokenStore an Airtable personal access token for authentication{key, configured}
listBasesList all bases accessible by the configured token{bases, offset}
getBaseSchemaGet the schema (tables and fields) for a base{tables} with field definitions
listRecordsList records from a table with optional filtering, sorting, and pagination{records, offset}
getRecordGet a single record by IDRecord object with id, fields, createdTime
createRecordCreate a single record in a tableCreated record with id, fields, createdTime
createRecordsBulk create up to 10 records in a table{records} array of created records
updateRecordUpdate a single record (PATCH - only updates specified fields)Updated record
updateRecordsBulk update up to 10 records (PATCH){records} array of updated records
replaceRecordReplace a single record (PUT - clears unspecified fields)Replaced record
deleteRecordDelete a single record by ID{id, deleted: true}
deleteRecordsBulk delete up to 10 records by ID{records} array of {id, deleted}
createTableCreate a new table in a base with field definitionsCreated table object with id, name, fields
updateTableUpdate a table's name or descriptionUpdated table object
createFieldCreate a new field in a tableCreated field object with id, name, type
updateFieldUpdate a field's name or descriptionUpdated field object

Functions

setToken

Store an Airtable personal access token for authentication

Module: airtable | Returns: object -- {key, configured}

airtable.setToken "default" "patXXXXXXXXXXXXXX"
ParameterTypeRequiredDescription
keystringYesToken identifier (e.g. 'default')
apiTokenstringYesAirtable personal access token

listBases

List all bases accessible by the configured token

Module: airtable | Returns: object -- {bases, offset}

airtable.listBases "default"
ParameterTypeRequiredDescription
keystringYesToken identifier
optionsobjectNo{offset?} for pagination

getBaseSchema

Get the schema (tables and fields) for a base

Module: airtable | Returns: object -- {tables} with field definitions

airtable.getBaseSchema "default" "appABC123"
ParameterTypeRequiredDescription
keystringYesToken identifier
baseIdstringYesAirtable base ID (e.g. 'appXXXXXXXXXXXXXX')

listRecords

List records from a table with optional filtering, sorting, and pagination

Module: airtable | Returns: object -- {records, offset}

airtable.listRecords "default" "appABC123" "Tasks" {"filterByFormula": "{Status}='Done'", "maxRecords": 50}
ParameterTypeRequiredDescription
keystringYesToken identifier
baseIdstringYesBase ID
tableIdOrNamestringYesTable ID or name
optionsobjectNo{filterByFormula?, sort?, fields?, maxRecords?, pageSize?, offset?, view?}

getRecord

Get a single record by ID

Module: airtable | Returns: object -- Record object with id, fields, createdTime

airtable.getRecord "default" "appABC123" "Tasks" "recDEF456"
ParameterTypeRequiredDescription
keystringYesToken identifier
baseIdstringYesBase ID
tableIdOrNamestringYesTable ID or name
recordIdstringYesRecord ID (e.g. 'recXXXXXXXXXXXXXX')

createRecord

Create a single record in a table

Module: airtable | Returns: object -- Created record with id, fields, createdTime

airtable.createRecord "default" "appABC123" "Tasks" {"Name": "New task", "Status": "Todo"}
ParameterTypeRequiredDescription
keystringYesToken identifier
baseIdstringYesBase ID
tableIdOrNamestringYesTable ID or name
fieldsobjectYesField name-value pairs

createRecords

Bulk create up to 10 records in a table

Module: airtable | Returns: object -- {records} array of created records

airtable.createRecords "default" "appABC123" "Tasks" [{"fields": {"Name": "Task A"}}, {"fields": {"Name": "Task B"}}]
ParameterTypeRequiredDescription
keystringYesToken identifier
baseIdstringYesBase ID
tableIdOrNamestringYesTable ID or name
recordsarrayYesArray of {fields: {...}} objects (max 10)

updateRecord

Update a single record (PATCH - only updates specified fields)

Module: airtable | Returns: object -- Updated record

airtable.updateRecord "default" "appABC123" "Tasks" "recDEF456" {"Status": "Done"}
ParameterTypeRequiredDescription
keystringYesToken identifier
baseIdstringYesBase ID
tableIdOrNamestringYesTable ID or name
recordIdstringYesRecord ID
fieldsobjectYesField name-value pairs to update

updateRecords

Bulk update up to 10 records (PATCH)

Module: airtable | Returns: object -- {records} array of updated records

airtable.updateRecords "default" "appABC123" "Tasks" [{"id": "recDEF456", "fields": {"Status": "Done"}}]
ParameterTypeRequiredDescription
keystringYesToken identifier
baseIdstringYesBase ID
tableIdOrNamestringYesTable ID or name
recordsarrayYesArray of {id, fields} objects (max 10)

replaceRecord

Replace a single record (PUT - clears unspecified fields)

Module: airtable | Returns: object -- Replaced record

airtable.replaceRecord "default" "appABC123" "Tasks" "recDEF456" {"Name": "Replaced", "Status": "New"}
ParameterTypeRequiredDescription
keystringYesToken identifier
baseIdstringYesBase ID
tableIdOrNamestringYesTable ID or name
recordIdstringYesRecord ID
fieldsobjectYesComplete field name-value pairs

deleteRecord

Delete a single record by ID

Module: airtable | Returns: object -- {id, deleted: true}

airtable.deleteRecord "default" "appABC123" "Tasks" "recDEF456"
ParameterTypeRequiredDescription
keystringYesToken identifier
baseIdstringYesBase ID
tableIdOrNamestringYesTable ID or name
recordIdstringYesRecord ID

deleteRecords

Bulk delete up to 10 records by ID

Module: airtable | Returns: object -- {records} array of {id, deleted}

airtable.deleteRecords "default" "appABC123" "Tasks" ["recDEF456", "recGHI789"]
ParameterTypeRequiredDescription
keystringYesToken identifier
baseIdstringYesBase ID
tableIdOrNamestringYesTable ID or name
recordIdsarrayYesArray of record IDs (max 10)

createTable

Create a new table in a base with field definitions

Module: airtable | Returns: object -- Created table object with id, name, fields

airtable.createTable "default" "appABC123" "Projects" [{"name": "Name", "type": "singleLineText"}, {"name": "Status", "type": "singleSelect", "options": {"choices": [{"name": "Active"}, {"name": "Done"}]}}]
ParameterTypeRequiredDescription
keystringYesToken identifier
baseIdstringYesBase ID
namestringYesTable name
fieldsarrayYesArray of field definitions [{name, type, options?}]

updateTable

Update a table's name or description

Module: airtable | Returns: object -- Updated table object

airtable.updateTable "default" "appABC123" "tblXYZ" {"name": "Renamed Table", "description": "Updated description"}
ParameterTypeRequiredDescription
keystringYesToken identifier
baseIdstringYesBase ID
tableIdstringYesTable ID
optionsobjectYes{name?, description?}

createField

Create a new field in a table

Module: airtable | Returns: object -- Created field object with id, name, type

airtable.createField "default" "appABC123" "tblXYZ" "Priority" "singleSelect" {"options": {"choices": [{"name": "High"}, {"name": "Low"}]}}
ParameterTypeRequiredDescription
keystringYesToken identifier
baseIdstringYesBase ID
tableIdstringYesTable ID
namestringYesField name
typestringYesField type (e.g. singleLineText, number, singleSelect)
optionsobjectNo{description?, options?} field-type-specific options

updateField

Update a field's name or description

Module: airtable | Returns: object -- Updated field object

airtable.updateField "default" "appABC123" "tblXYZ" "fldABC" {"name": "Renamed Field", "description": "Updated desc"}
ParameterTypeRequiredDescription
keystringYesToken identifier
baseIdstringYesBase ID
tableIdstringYesTable ID
fieldIdstringYesField ID
optionsobjectYes{name?, description?}

Error Handling

All functions throw on failure. Common errors:

ErrorCause
Airtable API ${method} ${path} failed (${response.status}): ${message}Check the error message for details
API token is requiredCheck the error message for details
Base ID is requiredCheck the error message for details
Table ID or name is requiredCheck the error message for details
Record ID is requiredCheck the error message for details
Records must be an arrayCheck the error message for details
Bulk create supports up to 10 records at a timeCheck the error message for details
Bulk update supports up to 10 records at a timeCheck the error message for details
@desc "List bases and validate result"
do
  set $result as airtable.listBases "default"
  if $result != null
    print "Success"
  else
    print "No result"
  end
enddo

Recipes

1. List and iterate Bases

Retrieve all items and loop through them.

@desc "Setup authentication"
do
  airtable.setToken $token
enddo

@desc "List bases and iterate results"
do
  set $result as airtable.listBases "default"
  each $item in $result
    print $item
  end
enddo

2. Create a new item with createRecord

Create a new resource and capture the result.

@desc "Setup authentication"
do
  airtable.setToken $token
enddo

@desc "Create record"
do
  set $result as airtable.createRecord "default" "appABC123" "Tasks" {"Name": "New task", "Status": "Todo"}
  print "Created: " + $result
enddo

3. Create and update workflow

Create an item and then update it.

@desc "Setup authentication"
do
  airtable.setToken $token
enddo

@desc "Create record and update record"
do
  set $created as airtable.createRecord "default" "appABC123" "Tasks" {"Name": "New task", "Status": "Todo"}
  # Update the created item
  airtable.updateRecord "default" "appABC123" "Tasks" "recDEF456" {"Status": "Done"}
enddo

4. Check before creating

List existing items and only create if needed.

@desc "Setup authentication"
do
  airtable.setToken $token
enddo

@desc "List bases and create record"
do
  set $existing as airtable.listBases "default"
  if $existing == null
    airtable.createRecord "default" "appABC123" "Tasks" {"Name": "New task", "Status": "Todo"}
    print "Item created"
  else
    print "Item already exists"
  end
enddo

5. Multi-step Airtable workflow

Chain multiple airtable operations together.

@desc "Setup authentication"
do
  airtable.setToken $token
enddo

@desc "List bases, get base schema, and more"
do
  set $r_listBases as airtable.listBases "default"
  set $r_getBaseSchema as airtable.getBaseSchema "default" "appABC123"
  set $r_listRecords as airtable.listRecords "default" "appABC123" "Tasks" {"filterByFormula": "{Status}='Done'", "maxRecords": 50}
  print "All operations complete"
enddo

6. Safe listBases with validation

Check results before proceeding.

@desc "Setup authentication"
do
  airtable.setToken $token
enddo

@desc "List bases and validate result"
do
  set $result as airtable.listBases "default"
  if $result != null
    print "Success: " + $result
  else
    print "Operation returned no data"
  end
enddo

Related Modules

  • google-sheets -- Google Sheets module for complementary functionality
  • google-calendar -- Google Calendar module for complementary functionality
  • google-contacts -- Google Contacts module for complementary functionality
  • google-forms -- Google Forms module for complementary functionality
  • gmail -- Gmail module for complementary functionality

Versions (1)

VersionTagPublished
0.1.2latest1 months ago
Install
$ robinpath add @robinpath/airtable

Collaborators

Dumitru Balaban
Dumitru Balaban
@dumitru
View all @robinpath modules
Version0.1.2
LicenseMIT
Unpacked Size7.6 KB
Versions1
Weekly Downloads26
Total Downloads26
Stars0
Last Publish1 months ago
Created1 months ago

Category

productivity