Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
The airtable npm package allows you to interact with the Airtable API, enabling you to manage and manipulate data stored in Airtable bases. It provides a simple and intuitive interface for performing CRUD (Create, Read, Update, Delete) operations on Airtable records.
Initialize Airtable
This code initializes the Airtable client with your API key and base ID, allowing you to interact with a specific Airtable base.
const Airtable = require('airtable');
const base = new Airtable({apiKey: 'YOUR_API_KEY'}).base('YOUR_BASE_ID');
Create a Record
This code creates a new record in the specified table with the given field values.
base('Table Name').create({
'Field1': 'Value1',
'Field2': 'Value2'
}, function(err, record) {
if (err) {
console.error(err);
return;
}
console.log(record.getId());
});
Read Records
This code retrieves records from the specified table and logs the value of 'Field1' for each record.
base('Table Name').select({
maxRecords: 3,
view: 'Grid view'
}).eachPage(function page(records, fetchNextPage) {
records.forEach(function(record) {
console.log('Retrieved', record.get('Field1'));
});
fetchNextPage();
}, function done(err) {
if (err) { console.error(err); return; }
});
Update a Record
This code updates a specific record in the table with a new value for 'Field1'.
base('Table Name').update('recXXXXXXXXXXXXXX', {
'Field1': 'Updated Value'
}, function(err, record) {
if (err) {
console.error(err);
return;
}
console.log(record.get('Field1'));
});
Delete a Record
This code deletes a specific record from the table.
base('Table Name').destroy('recXXXXXXXXXXXXXX', function(err, deletedRecord) {
if (err) {
console.error(err);
return;
}
console.log('Deleted record', deletedRecord.id);
});
The google-spreadsheet package allows you to interact with Google Sheets in a similar way to how airtable interacts with Airtable bases. It provides methods for reading, writing, and updating data in Google Sheets. Compared to airtable, it is more suited for users who prefer using Google Sheets as their data storage.
The notion-client package provides an interface to interact with Notion databases. It allows you to perform CRUD operations on Notion pages and databases. Compared to airtable, it is more suitable for users who prefer using Notion for their data management and note-taking needs.
The mongodb package is a driver for MongoDB, a NoSQL database. It allows you to perform CRUD operations on MongoDB collections. Compared to airtable, it is more suitable for users who need a more robust and scalable database solution.
The official Airtable JavaScript library.
The Airtable API provides a simple way of accessing your data. Whether it's contacts, sales leads, inventory, applicant information or todo items, the vocabulary of the interactions closely matches your data structure. You will use your table names to address tables, column names to access data stored in those columns. In other words, the Airtable API is your own RESTful API for your base.
To install airtable.js in a node project:
npm install airtable
Airtable.js is compatible with Node 10 and above.
To use airtable.js in the browser, use airtable.browser.js which is in the build
folder.
For a demo, run:
cd test/test_files
python -m SimpleHTTPServer
Edit test/test_files/index.html
- put your BASE_ID
and API_KEY
(Be careful! You are putting your API key on a web page! Create a separate account and share only one base with it).
Then open http://localhost:8000/ in your browser.
Airtable.js is compatible with browsers supported by the Airtable web app with the exception of Safari 10.0. Airtable.js supports Safari 10.1 and higher. See the technical requirements for more details.
There are three configurable options available:
apiKey
- set the token to your secret API token. Visit your account page to create an API token. (AIRTABLE_API_KEY
)endpointUrl
- the API endpoint to hit. You might want to override
it if you are using an API proxy (e.g. runscope.net) to debug your API calls. (AIRTABLE_ENDPOINT_URL
)requestTimeout
- the timeout in milliseconds for requests. The default is 5 minutes (300000
)You can set the options globally via Airtable.configure
:
Airtable.configure({ apiKey: 'YOUR_SECRET_API_KEY' })
Globally via process env (e.g. in 12factor setup).
export AIRTABLE_API_KEY=YOUR_SECRET_API_KEY
You can also override the settings per connection:
var airtable = new Airtable({endpointUrl: 'https://api-airtable-com-8hw7i1oz63iz.runscope.net/'})
Go to https://airtable.com/api to see the interactive API documentation for your Airtable bases. Once you select a base, click the "JavaScript" tab to see code snippets using Airtable.js. It'll have examples for all operations you can perform against your base using this library.
As of v0.5.0 all of the methods that take a done
callback will return a Promise if you don't pass in a done
callback.
For example:
table.select().firstPage(result => { ... })
is equivalent to
table.select().firstPage().then(result => { ... })
Tests are run via npm run test
.
We strive for 100% test coverage. Some aspects may not be testable or suitable for test coverage. The tooling supports ignoring specific parts of a file documented here; use that as appropriate.
When you run the tests a coverage report will be generated at ./coverage/lcov-report/index.html
which you can access in the browser for line by line reporting.
v0.11.2
FAQs
The official Airtable JavaScript library.
The npm package airtable receives a total of 131,306 weekly downloads. As such, airtable popularity was classified as popular.
We found that airtable demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 12 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.