How to use the Airtable Plugin with CRUD
Seamlessly integrate and manage data in an Airtable spreadsheet. 👉 Ensure you have installed the 🧩 Airtable plugin
📌 Create an Airtable Token Scopes Required:
data.records:read
data.records:write
schema.bases:read
schema.bases:write
Access: Your workspace
Your Airtable URL follows this structure:
https://airtable.com/BASE/TABLE/VIEW
Example: https://airtable.com/appnXXXX/tblXXXX/viwXXX
Copy your Airtable details into the block below:
const BASE = "appnXXXX"; // Base ID
const TOKEN = "XXXXXXXX"; // API Token
const TABLE = "tblXXX"; // Table ID
const AirtableApi = require("./airtable-api.js");
const data = {
"name": "Purchases",
"description": "List of customers for downloadable content",
"fields": [
{ "name": "Email", "type": "email" },
{ "name": "purchaseDate", "options": { "dateFormat": { "format": "YYYY-MM-DD", "name": "iso" } }, "type": "date" },
{ "name": "nbrOfDownload", "options": { "precision": 0 }, "type": "number" },
{ "name": "version", "options": { "precision": 0 }, "type": "number" }
]
};
const airtable = new AirtableApi(TOKEN, BASE);
printJSON(await airtable.createTable(data));
const AirtableApi = require("./airtable-api.js");
const airtable = new AirtableApi(TOKEN, BASE);
const result = await airtable.listRecords(TABLE, 100, 0);
// Alternative: Sort by purchaseDate
// const result = await airtable.listRecordsSorted(TABLE, 100, 0, "purchaseDate");
printJSON(result);
const AirtableApi = require("./airtable-api.js");
const airtable = new AirtableApi(TOKEN, BASE);
const result = await airtable.searchRecord(TABLE, 'SEARCH(SUBSTITUTE("usermail@gmail.com","+","%2B"), {email})');
printJSON(result);
const AirtableApi = require("./airtable-api.js");
const airtable = new AirtableApi(TOKEN, BASE);
const creationDate = new Date().toISOString().split('T')[0];
const data = {
"records": [
{
"fields": {
"Email": "usermail@gmail.com",
"purchaseDate": creationDate,
"nbrOfDownload": 0,
"version": 1
}
}
]
};
const result = await airtable.createRecord(TABLE, data);
printJSON(result);
const AirtableApi = require("./airtable-api.js");
const airtable = new AirtableApi(TOKEN, BASE);
const RECORD_ID = "rech8grvSTiksocGa"; // Change to the actual record ID
const data = {
"fields": {
"nbrOfDownload": 1
}
};
const result = await airtable.updateRecord(TABLE, RECORD_ID, data);
printJSON(result);
✅ You're now ready to manage Airtable data directly from Znote! 🚀