airtable-monitor
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

airtable-monitor

Build Status npm npm

This library polls your Airtable tables to monitor changes, calling a simple event handler when a change is detected.

Install

yarn add airtable-monitor

Usage

const AirtableMonitor = require('airtable-monitor');

const monitor = new AirtableMonitor(
  {
    baseID: xxx, // Airtable base ID
    apiKey: xxx, // Airtable API token
    tables: ['table_to_monitor'],
    tableInterval: 1, // Optional (default = 0) : an interval in seconds between calls to Airtable API for each table of a tick to avoid rate limiting.
  },
  event => {
    // event structure :
    // {
    //   date,
    //   tableName,
    //   fieldName,
    //   previousValue,
    //   newValue,
    //   recordId,
    // }
  },
);

monitor.start(30); // Poll every 30 seconds. Default : 60 seconds

Caveats

  • Changes that occur between polling intervals will not be detected
  • Be careful when monitoring text fields, as the Airtable API returns the exact text at the moment we request it : If someone is changing foo to lorem ipsum and the check interval occurs in the middle, an first event could be fired for foo -> lorem, then the next check would fire an event for lorem -> lorem ipsum.
  • We don't recommend polling too often to avoid exceeding Airtable API rate limits.

Running tests

yarn install && yarn test

Readme

Keywords

none

Package Sidebar

Install

npm i airtable-monitor

Weekly Downloads

1

Version

1.2.1

License

MIT

Unpacked Size

57.1 kB

Total Files

15

Last publish

Collaborators

  • dlajarretie
  • dqms