Skip to main content

Airtable

Airtable can store information in a spreadsheet that's visually appealing and easy-to-use

Official Websitehttps://airtable.com/
Version0.11.1
TagsDatabase, Saas

Airtable snippets available in YepCode editor

note

The title is the triggering text for YepCode to autocomplete the script

Integration

New integration from credential
const airtableClient = yepcode.integration.airtable('credential-slug')
New integration from plain authentication data
const Airtable = require('airtable')

const airtableClient = new Airtable({
apiKey: 'your_api_key'
})

Select records

Select records from base
airtableClient.base('baseName').select({
maxRecords: 30,
view: "Grid view"
}).eachPage(function page(records, fetchNextPage) {
records.forEach(function(record) {
console.log('Retrieved', record.get('productId'));
});
fetchNextPage();

}, function done(err) {
if (err) { console.error(err); return; }
});

Find records

Find one record by id
airtableClient.base('baseName').find('recordId', function(err, record) {
if (err) { console.error(err); return; }
console.log('Retrieved', record.id);
});

Create records

Create records
airtableClient.base('baseName').create([
{
"fields": {
"productId": 1,
"stock": 10
}
},
{
"fields": {
"productId": 1,
"stock": 20
}
}
], function(err, records) {
if (err) {
console.error(err);
return;
}
records.forEach(function (record) {
console.log(record.getId());
});
});

Update records

Update records
airtableClient.base('baseName').update([
{
"id": "recordId",
"fields": {
"stock": 20
}
},
{
"id": "otherRecordId",
"fields": {
"stock": 20
}
}
], function(err, records) {
if (err) {
console.error(err);
return;
}
records.forEach(function (record) {
console.log(record.getId());
});
});

Delete records

Delete records
airtableClient.base('baseName').destroy(['recordId'], function(err, deletedRecords) {
if (err) {
console.error(err);
return;
}
console.log('Deleted', deletedRecords.length, 'records');
});