Skip to content

GooRoo/Airtable.nu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Airtable.nu

This module allows to work with data stored in Airtable via Web API.

Installation

> nupm install --git [email protected]:GooRoo/Airtable.nu.git
> use airtable

Authorization

First, You need to create a Personal Access Token here.

To log in, use:

> airtable login 'your-PAT'

This will store your auth information for the current session.

Personally, I use it together with 1Password CLI like this:

> op read "op://Vault/Airtable/API tokens/my-pat" | airtable login

Usage

Tip

In all commands, entity names and their corresponding IDs (for databases, tables, fields, etc.) could be used interchangeably. The names look better but could be changed by someone (and you'll have to adapt your scripts), while IDs are uglier but unique and always stay the same.

Getting the list of databases

Note

The operation requires schema.bases:read scope.

> airtable db list

Listing the tables with their schemas

Note

The operation requires schema.bases:read scope.

> airtable db list | get 0.id | airtable db tables

Choosing active database

If you don't want to pass the database ID manually to all commands that require it, you can store it for the current session like this:

> let dbs = airtable db list
> airtable db use $dbs.0.id

or as a one-liner:

> airtable db list | get 0.id | airtable db use

Working with tables

Getting the data

Note

The operation requires data.records:read scope.

Simply call:

> airtable table show 'your-table-id'

You can also pass the table ID via pipe:

> 'your-table-id' | airtable table show

Warning

This command requires a database ID to which a table belongs. If you haven't chosen the active DB like it is shown above, you can pass it through the pipe:

> {base_id: 'your-db-id', table_id: 'your-table-id'} | airtable table show

You can also limit the fields you want to retrieve:

> 'Clients' | airtable table show --fields [Name Country Email]

Additionally, you can sort the fields:

> 'Clients' | airtable table show --sort [[field direction];[Name asc],[Birthdate desc]]

Note

Sorting on Airtable's backend side is not the same as sorting in Nushell! Consider the following:

'Clients' | airtable table show | take 20 | sort-by Name

Here, you want to get information about the first 20 clients sorted by their names. However, the order, in which Airtable returns the records, is not specified. As a result, you get 20 random client records and then sort them by name. Instead, the correct way would be this:

'Clients' | airtable table show -s [{field: Name, direction: asc}] | take 20

About

Work with Airtable in Nushell

Topics

Resources

License

Stars

Watchers

Forks