airtable-monitor
v1.2.1
Published
Get notified when an Airtable record is edited
Downloads
18
Readme
airtable-monitor
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
tolorem ipsum
and the check interval occurs in the middle, an first event could be fired forfoo
->lorem
, then the next check would fire an event forlorem
->lorem ipsum
. - We don't recommend polling too often to avoid exceeding Airtable API rate limits.
Running tests
yarn install && yarn test