Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/airtable/airtable.ts>Airtable

Unofficial Airtable client for Deno 🦕
Latest
class Airtable
import { Airtable } from "https://deno.land/x/airtable@v1.1.1/airtable.ts";

Unofficial Airtable API client for Deno

Constructors

new
Airtable(options?: AirtableOptions)

Creates an instance of Airtable client

const airtable = new Airtable()
const airtable = new Airtable({ useEnv: true })
const airtable = new Airtable({
  apiKey: "keyXXXXXXXXXXXXXX",
  baseId: "appXXXXXXXXXXXXXX",
  tableName: "Some table name",
})

Methods

private
getRequestUrl(query?: Record<string, any>, ...segments: string[]): string
private
jsonRequest<T>(unnamed 0: AirtableRequestOptions): Promise<T>
private
request<T>(unnamed 0: AirtableRequestOptions): Promise<T>
private
updateOrReplace<T extends FieldSet>(unnamed 0: UpdateOrReplaceOptions<T>): Promise<TableRecord<T>> | Promise<TableRecords<T>>
base(baseId: string): Airtable

Returns new Airtable client with defined base ID

const airtable = new Airtable()
const airtableWithNewBaseId = airtable.base("appXXXXXXXXXXXXXX")

Reconfigure the Airtable client

airtable.configure({
  apiKey: "keyXXXXXXXXXXXXXX",
  baseId: "appXXXXXXXXXXXXXX",
  tableName: "Some table name",
})
create<T extends FieldSet>(data: T, options?: RecordOptions): Promise<TableRecord<T>>

Create record for selected base and table

 const createOne = await airtable.create({
   Name: "Griko Nibras",
   Age: 25,
 });
create<T extends FieldSet>(data: T[], options?: RecordOptions): Promise<TableRecords<T>>

Create multiple records for selected base and table

const createMultiple = await airtable.create(
  [
    { Name: "Foo", Age: 20 },
    { Name: "Bar", Age: 15 },
  ],
  { typecast: true }
);
delete(id: string): Promise<DeletedRecord>

Delete record from selected base and table

const deleteOne = await airtable.delete("recXXXXXXXXXXXXXX");
delete(ids: string[]): Promise<DeletedRecords>

Delete multiple records from selected base and table

const deleteMultiple = await airtable.delete([
  "recXXXXXXXXXXXXXX",
  "recXXXXXXXXXXXXXX",
]);
find<T extends FieldSet>(id: string): Promise<TableRecord<T>>

Retrieve record from selected base and table

const record = await airtable.find("recXXXXXXXXXXXXXX")
const { id, fields, createdTime } = await airtable.find("recXXXXXXXXXXXXXX")
replace<T extends FieldSet>(records: TableRecord<T>[], options?: RecordOptions): Promise<TableRecords<T>>

Replace multiple for selected base and table

const replaceMultiple = await airtable.replace(
  [
    {
      id: "recXXXXXXXXXXXXXX",
      fields: { Name: "Adult boi", Age: 30 },
    },
    {
      id: "recXXXXXXXXXXXXXX",
      fields: { Name: "Yung boi", Age: 15 },
    },
  ],
  { typecast: true }
);
replace<T extends FieldSet>(
id: string,
record: T,
options?: RecordOptions,
): Promise<TableRecord<T>>

Replace single records for selected base and table

const replaceOne = await airtable.update("recXXXXXXXXXXXXXX", {
  Name: "Adult boi",
  Age: 30,
});
select<T extends FieldSet>(options?: SelectOptions<T>): Promise<SelectResult<T>>

List records from selected base and table

const results = await airtable.select()
table(tableName: string): Airtable

Returns new Airtable client with defined table name

const airtable = new Airtable()
const airtableWithNewTableName = airtable.table("Some table name")
update<T extends FieldSet>(records: TableRecord<T>[], options?: RecordOptions): Promise<TableRecords<T>>

Update multiple for selected base and table

const updateMultiple = await airtable.update(
  [
    {
      id: "recXXXXXXXXXXXXXX",
      fields: { Name: "Adult boi", Age: 30 },
    },
    {
      id: "recXXXXXXXXXXXXXX",
      fields: { Name: "Yung boi", Age: 15 },
    },
  ],
  { typecast: true }
);
update<T extends FieldSet>(
id: string,
record: T,
options?: RecordOptions,
): Promise<TableRecord<T>>

Update single records for selected base and table

const updateOne = await airtable.update("recXXXXXXXXXXXXXX", {
  Name: "Adult boi",
  Age: 30,
});

Static Properties

defaultOptions: Partial<AirtableOptions>