Skip to main content

airtable.airtable

Home > @runlightyear/airtable > Airtable

Airtable class

Connector to the Airtable API

Signature:
declare class Airtable extends RestConnector 

Extends:

RestConnector

Example 1

Import

import { Airtable } from "@runlightyear/airtable"

Example 2

Use in an action

defineAction({
name: "airtableExample",
title: "Airtable Example"
apps: ["airtable"],
run: async ({ auths }) => {
const airtable = new Airtable({ auth: auths.airtable });
}
}

Example 3

Create a single record

import { defineAction } from "@runlightyear/lightyear";
import { Airtable } from "@runlightyear/airtable";

defineAction({
name: "createSingleRecord",
title: "Create Single Record",
apps: ["airtable"],
variables: ["baseId", "tableIdOrName", "name"],
run: async ({ auths, variables }) => {
const airtable = new Airtable({
auth: auths.airtable,
});
const response = await airtable.createRecords({
baseId: variables.baseId!,
tableIdOrName: variables.tableIdOrName!,
fields: {
Name: variables.name!,
},
});

console.log("Record: ", response.data);
},
});

Example 4

Create multiple records

import { defineAction } from "@runlightyear/lightyear";
import { Airtable } from "@runlightyear/airtable";

defineAction({
name: "createMultipleRecords",
title: "Create Multiple Records",
apps: ["airtable"],
variables: ["baseId", "tableIdOrName"],
run: async ({ auths, variables }) => {
const airtable = new Airtable({
auth: auths.airtable,
});

const response = await airtable.createRecords({
baseId: variables.baseId!,
tableIdOrName: variables.tableIdOrName!,
records: [
{
fields: {
Name: "Union Square",
},
},
{
fields: {
Name: "Ferry Building",
},
},
],
});

console.log("Response: ", response.data);
},
});

Example 5

Get a record

import { defineAction } from "@runlightyear/lightyear";
import { Airtable } from "@runlightyear/airtable";

defineAction({
name: "getRecord",
title: "Get Record",
apps: ["airtable"],
variables: ["baseId", "tableIdOrName", "recordId"],
run: async ({ auths, variables }) => {
const airtable = new Airtable({
auth: auths.airtable,
});

const response = await airtable.getRecord({
baseId: variables.baseId!,
tableIdOrName: variables.tableIdOrName!,
recordId: variables.recordId!,
});

console.log("Response: ", response.data);
},
});

Example 6

Update a record

import { defineAction } from "@runlightyear/lightyear";
import { Airtable } from "@runlightyear/airtable";

defineAction({
name: "updateRecord",
title: "Update Record",
apps: ["airtable"],
variables: ["baseId", "tableIdOrName", "recordId", "name"],
run: async ({ auths, variables }) => {
const airtable = new Airtable({
auth: auths.airtable,
});

const response = await airtable.updateRecord({
baseId: variables.baseId!,
tableIdOrName: variables.tableIdOrName!,
recordId: variables.recordId!,
fields: {
Name: variables.name!,
},
});

console.log("Response: ", response.data);
},
});

Example 7

Delete a record

import { defineAction } from "@runlightyear/lightyear";
import { Airtable } from "@runlightyear/airtable";

defineAction({
name: "deleteRecord",
title: "Delete Record",
apps: ["airtable"],
variables: ["baseId", "tableIdOrName", "recordId"],
run: async ({ auths, variables }) => {
const airtable = new Airtable({
auth: auths.airtable,
});

const response = await airtable.deleteRecord({
baseId: variables.baseId!,
tableIdOrName: variables.tableIdOrName!,
recordId: variables.recordId!,
});

console.log("Response: ", response.data);
},
});

Example 8

List records

import { defineAction } from "@runlightyear/lightyear";
import { Airtable } from "@runlightyear/airtable";

defineAction({
name: "listRecords",
title: "List Records",
apps: ["airtable"],
variables: ["baseId", "tableIdOrName"],
run: async ({ auths, variables }) => {
const airtable = new Airtable({
auth: auths.airtable,
});

const response = await airtable.listRecords({
baseId: variables.baseId!,
tableIdOrName: variables.tableIdOrName!,
recordMetadata: ["commentCount"],
});

console.log("Response: ", response.data);
},
});

@example Who am I?

typescript import { defineAction } from "@runlightyear/lightyear"; import { Airtable } from "@runlightyear/airtable";

defineAction({ name: "whoami", title: "Who Am I?", apps: ["airtable"], run: async ({ auths, variables }) => { const airtable = new Airtable({ auth: auths.airtable });

const response = await airtable.whoami();

console.log("Response: ", response.data); }, }); ```

Constructors

ConstructorModifiersDescription
(constructor)(props)Constructs a new instance of the Airtable class

Properties

PropertyModifiersTypeDescription
authTypestaticAuthType
OAuthstatictypeof AirtableOAuth

Base Methods

MethodModifiersDescription
getBaseSchema(props)Get base schema
listBases(props)List bases

Meta Methods

MethodModifiersDescription
whoami()Retrieve the user ID and, for OAuth access tokens, the scopes associated with the token used.

Records Methods

MethodModifiersDescription
createRecords(props)Creates multiple records.
deleteRecord(props)Delete record
getRecord(props)Get record
listRecords(props)List records in a table.
updateRecord(props)Update record

Other Methods

MethodModifiersDescription
getBaseUrl()