/airtable-deno

Unofficial Airtable client for Deno 🦕

Primary LanguageTypeScriptMIT LicenseMIT

airtable-deno

release



Imports

Comparison with Node.js version

  • Using built-in Deno fetch and only one dependency
  • First-class support for generic field types with extra field types (Collaborators, MultipleSelect<T>, etc.)
  • Single object instance (new Airtable() instead of new Airtable().base()().select()...)

Permissions

  • --allow-net

    Network access for fetching and requesting datas to Airtable API endpoints.

  • --allow-env (optional)

    Configuring Airtable options via environment variables instead of passing values (see advanced examples).

Basic examples

Instantiate Airtable client

import { Airtable } from "https://deno.land/x/airtable/mod.ts";

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

Select record(s)

const results = await airtable.select();

Creating record(s)

const createOne = await airtable.create({
  Name: "Griko Nibras",
  Age: 25,
});

import { Field } from "https://deno.land/x/airtable/mod.ts";

type Fields = {
  Name: string;
  Age: number;
  Active?: Field.Checkbox;
};

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

Updating record(s)

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

const updateMultiple = await airtable.update<Fields>(
  [
    {
      id: "recXXXXXXXXXXXXXX",
      fields: { Name: "Adult boi", Age: 30 },
    },
    {
      id: "recXXXXXXXXXXXXXX",
      fields: { Name: "Yung boi", Age: 15 },
    },
  ],
  { typecast: true }
);

Delete record(s)

const deleteOne = await airtable.delete("recXXXXXXXXXXXXXX");

const deleteMultiple = await airtable.delete([
  "recXXXXXXXXXXXXXX",
  "recXXXXXXXXXXXXXX",
]);

Advanced examples

For advanced examples, view the examples.ts file.

Further reading

All options, parameters, errors, and responses are the same as on the Airtable API documentation.

Used by

Dependencies

License

MIT License Copyright (c) 2020 Griko Nibras