- We aim to support all Airtable API features natively
- Built in protection against Airtable injections
- Support for modifying/getting records using field values, not just record IDs
Airlua requires Astra, a modern lua runtime with built in support for HTTP requests, and many other useful functions. Astra allows Airlua to be 100% written in Lua.
Once you have Astra installed, simply download airtable.lua and add it to your project folder, or run:
luarocks install airtable-luaNote: for installation with luarocks, use "airtable-lua" instead of airtable for imports
Also, make sure to set AIRTABLE_API_KEY in your .env
| Type | Percent | Completed |
|---|---|---|
| Records | 100% | All routes supported |
| Tables | 100% | All routes supported |
| Fields | 100% | All routes supported |
| Comments | 100% | All routes supported |
| Bases | 100% | All routes supported |
Lists records from a table.
Parameters:
base_id(string) - The ID of the Airtable basetable_name(string) - The name or ID of the tableview(string, optional) - The name of a view to filter byparams(table, optional) - Additional parameters (e.g.,filterByFormula,maxRecords,sort)
Returns: Table containing records array, or nil and error message
local records, err = airtable.list("appXXXXXXXXXX", "Tasks", "Grid view", {maxRecords = 10})Retrieves a single record by its ID.
Parameters:
base_id(string) - The ID of the Airtable basetable_name(string) - The name or ID of the tablerecord_id(string) - The ID of the record to retrieve
Returns: Record object, or nil and error message
local record, err = airtable.get("appXXXXXXXXXX", "Tasks", "recXXXXXXXXXX")Retrieves the first record matching a field value.
Parameters:
base_id(string) - The ID of the Airtable basetable_name(string) - The name or ID of the tablefield(string) - The field name to search byvalue(string) - The value to match
Returns: First matching record, or nil/error message
local record = airtable.getByField("appXXXXXXXXXX", "Users", "Email", "user@example.com")Creates a new record in the table.
Parameters:
base_id(string) - The ID of the Airtable basetable_name(string) - The name or ID of the tablefields(table, optional) - The field values for the new record
Returns: Created record object, or nil and error message
local record, err = airtable.create("appXXXXXXXXXX", "Tasks", {Name = "New Task", Status = "Todo"})Updates an existing record by its ID.
Parameters:
base_id(string) - The ID of the Airtable basetable_name(string) - The name or ID of the tablerecord_id(string) - The ID of the record to updatefields(table) - The field values to update
Returns: Updated record object, or nil and error message
local record, err = airtable.update("appXXXXXXXXXX", "Tasks", "recXXXXXXXXXX", {Status = "Done"})Updates the first record matching a field value.
Parameters:
base_id(string) - The ID of the Airtable basetable_name(string) - The name or ID of the tablefield(string) - The field name to search byvalue(string) - The value to matchupdatedFields(table) - The field values to update
Returns: Updated record object, or nil and error message
local record, err = airtable.updateByField("appXXXXXXXXXX", "Users", "Email", "user@example.com", {Name = "Updated Name"})Deletes a record by its ID.
Parameters:
base_id(string) - The ID of the Airtable basetable_name(string) - The name or ID of the tablerecord_id(string) - The ID of the record to delete
Returns: Deletion confirmation object, or nil and error message
local result, err = airtable.delete("appXXXXXXXXXX", "Tasks", "recXXXXXXXXXX")Creates multiple records in a single request (max 10 per request).
Parameters:
base_id(string) - The ID of the Airtable basetable_name(string) - The name or ID of the tablerecordsArray(table) - Array of field tables for each record
Returns: Table containing records array with created records, or nil and error message
local result, err = airtable.createBulk("appXXXXXXXXXX", "Tasks", {
{Name = "Task 1", Status = "Todo"},
{Name = "Task 2", Status = "In Progress"},
{Name = "Task 3", Status = "Done"}
})Updates multiple records in a single request (max 10 per request).
Parameters:
base_id(string) - The ID of the Airtable basetable_name(string) - The name or ID of the tablerecordsArray(table) - Array of tables, each withidandfieldsproperties
Returns: Table containing records array with updated records, or nil and error message
local result, err = airtable.updateBulk("appXXXXXXXXXX", "Tasks", {
{id = "recXXXXXXXXX1", fields = {Status = "Done"}},
{id = "recXXXXXXXXX2", fields = {Status = "Done"}},
})Deletes multiple records in a single request (max 10 per request).
Parameters:
base_id(string) - The ID of the Airtable basetable_name(string) - The name or ID of the tablerecordIds(table) - Array of record IDs to delete
Returns: Table containing records array with deletion confirmations, or nil and error message
local result, err = airtable.deleteBulk("appXXXXXXXXXX", "Tasks", {
"recXXXXXXXXX1",
"recXXXXXXXXX2",
"recXXXXXXXXX3"
})Creates a new table in a base.
Parameters:
base_id(string) - The ID of the Airtable basename(string) - The name of the tablefields(table) - Array of field configurations (at least one required). The first field becomes the primary field.description(string, optional) - Table description (max 20,000 characters)
Returns: Created table object, or nil and error message
local newTable, err = airtable.createTable("appXXXXXXXXXX", "My Table", {
{name = "Name", type = "singleLineText"},
{name = "Notes", type = "multilineText"},
{name = "Status", type = "singleSelect", options = {choices = {{name = "Todo"}, {name = "Done"}}}}
}, "Optional description")Updates an existing table's name, description, or date dependency settings.
Parameters:
base_id(string) - The ID of the Airtable basetable_id(string) - The ID or name of the tableoptions(table) - Table options to update:name(string, optional) - The new name of the tabledescription(string, optional) - New table description (max 20,000 characters)dateDependencySettings(table, optional) - Date dependency settings
Returns: Updated table object, or nil and error message
local table, err = airtable.updateTable("appXXXXXXXXXX", "tblXXXXXXXXXX", {
name = "Renamed Table",
description = "Updated description"
})Creates a new field in a table.
Parameters:
base_id(string) - The ID of the Airtable basetable_id(string) - The ID of the tablefieldtype(string) - The type of field to create (e.g.,"singleLineText","number","checkbox")options(table) - Field options:name(string) - The name of the fielddescription(string, optional) - Field description (max 20,000 characters)
Returns: Created field object, or nil and error message
local field, err = airtable.createField("appXXXXXXXXXX", "tblXXXXXXXXXX", "singleLineText", {
name = "New Field",
description = "A description of this field"
})Updates an existing field in a table.
Parameters:
base_id(string) - The ID of the Airtable basetable_id(string) - The ID of the tablefield_id(string) - The ID of the field to updateoptions(table) - Field options to update:name(string, optional) - The new name of the fielddescription(string, optional) - New field description (max 20,000 characters)
Returns: Updated field object, or nil and error message
local field, err = airtable.updateField("appXXXXXXXXXX", "tblXXXXXXXXXX", "fldXXXXXXXXXX", {
name = "Renamed Field",
description = "Updated description"
})Lists all comments on a record.
Parameters:
base_id(string) - The ID of the Airtable basetable_name(string) - The name or ID of the tablerecord_id(string) - The ID of the record
Returns: Table containing comments array, or nil and error message
local comments, err = airtable.listComments("appXXXXXXXXXX", "Tasks", "recXXXXXXXXXX")Creates a new comment on a record.
Parameters:
base_id(string) - The ID of the Airtable basetable_name(string) - The name or ID of the tablerecord_id(string) - The ID of the recordtext(string) - The comment textparentCommentId(string, optional) - The ID of a parent comment for replies
Returns: Created comment object, or nil and error message
local comment, err = airtable.createComment("appXXXXXXXXXX", "Tasks", "recXXXXXXXXXX", "This is a comment")Updates an existing comment.
Parameters:
base_id(string) - The ID of the Airtable basetable_name(string) - The name or ID of the tablerecord_id(string) - The ID of the recordcomment_id(string) - The ID of the comment to updatecontent(string) - The new comment text
Returns: Updated comment object, or nil and error message
local comment, err = airtable.updateComment("appXXXXXXXXXX", "Tasks", "recXXXXXXXXXX", "comXXXXXXXXXX", "Updated comment")Deletes a comment.
Parameters:
base_id(string) - The ID of the Airtable basetable_name(string) - The name or ID of the tablerecord_id(string) - The ID of the recordcomment_id(string) - The ID of the comment to delete
Returns: Deletion confirmation object, or nil and error message
local result, err = airtable.deleteComment("appXXXXXXXXXX", "Tasks", "recXXXXXXXXXX", "comXXXXXXXXXX")Sanitizes a value for safe use in Airtable formulas by escaping quotes and removing parentheses.
Parameters:
value(any) - The value to sanitize
Returns: Sanitized string
Validates a formula string to ensure it doesn't contain potentially dangerous patterns.
Parameters:
formula(string) - The formula to validate
Returns: true if valid, or false and error message
Lists all bases accessible by the API token.
Parameters:
offset(string, optional) - Pagination offset for fetching additional pages of bases
Returns: Table containing bases array and optional offset for pagination, or nil and error message
local result, err = airtable.listBases()
for _, base in ipairs(result.bases) do
print(base.name, base.id)
endReturns the schema of all tables in a base.
Parameters:
base_id(string) - The ID of the Airtable baseinclude(table, optional) - Array of additional fields to include (e.g.,{"visibleFieldIds"})
Returns: Table containing tables array with schema information, or nil and error message
local schema, err = airtable.getBaseSchema("appXXXXXXXXXX")
for _, tbl in ipairs(schema.tables) do
print(tbl.name, tbl.id)
endCreates a new base in a workspace.
Parameters:
workspace_id(string) - The ID of the workspace where the base will be createdname(string) - The name for the new basetables(table) - Array of table configurations (at least one required)
Returns: Created base object with id and tables, or nil and error message
local newBase, err = airtable.createBase("wspXXXXXXXXXX", "My New Base", {
{
name = "Tasks",
fields = {
{name = "Name", type = "singleLineText"},
{name = "Status", type = "singleSelect", options = {choices = {{name = "Todo"}, {name = "Done"}}}}
}
}
})