Airtable is a spreadsheet-database hybrid, with the features of a database but applied to a spreadsheet. airtab2php is a group of simple functions that make it possible to use Airtable's API in PHP. By using this you can list, create, update and delete records in Airtable.
Easy to install, just include it.
require_once 'airtab2php.php';
Apache, Lighttpd, Nginx or similar with PHP 5 or 7 and cURL.
API-key, base ID and table name are required arguments for all functions.
Argument | Description | Example |
---|---|---|
[APIKEY] | Generated API-key from Airtable | 'keysccH0c9F1ZtwXe' |
[BASE] | Unique ID of base in Airtable | 'appxxxp0BT5w4x1ac' |
[TABLE] | Table name in Airtable | 'phonebook' |
This function lists records from Airtable based on base ID and table name. It's also possible to customize it by using the arguments listed in the table below.
airtab2php_select([APIKEY], [BASE], [TABLE], [VIEW], [FIELDS], [WHERE], [SORT], [LIMIT]);
The function will return the result as an array.
Argument | Description | Example |
---|---|---|
[VIEW] | Custom Grid view | 'Grid view' (default) |
[FIELDS] | Name of fields to include | 'firstname;lastname;phonenumber' |
[WHERE] | Where value is equal to or not equal to | 'firstname=John' or 'firstname!=John' |
[SORT] | Sort record by field and direction | 'firstname;desc' (default direction is ascending) |
[LIMIT] | Maximum total number of records | '10' (default is 100) |
This function will create new record in Airtable based on base ID and table name. In addition, fields and values are also required arguments to be able to perform this function correctly. The use of these arguments are listed in the table below.
airtab2php_insert([APIKEY], [BASE], [TABLE], [FIELDS], [VALUES]);
If the function is performed correctly, it will return TRUE
.
Argument | Description | Example |
---|---|---|
[FIELDS] | Specify name of fields in table | 'firstname;lastname;phonenumber' |
[VALUES] | Specify values to create in table | 'John;Doe;155588812' |
This function will update existing record in Airtable based on base ID and table name. In addition, record ID, fields and values are also required arguments to be able to perform this function correctly. The use of these arguments are listed in the table below.
airtab2php_update([APIKEY], [BASE], [TABLE], [ID], [FIELDS], [VALUES]);
If the function is performed correctly, it will return TRUE
.
Argument | Description | Example |
---|---|---|
[ID] | ID of record to update in table | 'rectCv8ZQm6bypdz4' |
[FIELDS] | Specify name of fields in table | 'firstname;lastname;phonenumber' |
[VALUES] | Specify values to update in table | 'John;Doe;155588834' |
This function will delete existing record in Airtable based on base ID and table name. In addition, record ID is also required argument to be able to perform this function correctly. The use of this argument is listed in the table below.
airtab2php_delete([APIKEY], [BASE], [TABLE], [ID]);
If the function is performed correctly, it will return TRUE
.
Argument | Description | Example |
---|---|---|
[ID] | ID of record to delete in table | 'rectCv8ZQm6bypdz4' |
Distributed under the MIT License. See LICENSE
for more information.
Nille - @aliasnille / himself@nillewebb.se / nillewebb.se (in Swedish)
Project Link: https://github.com/aliasnille/airtab2php