0
# Command Line Interface
1
2
Complete CLI for direct API interaction, base exploration, record management, and ORM code generation. Provides command-line access to all major pyAirtable functionality.
3
4
## Capabilities
5
6
### CLI Commands
7
8
```python { .api }
9
# Main commands (run with: python -m pyairtable)
10
# or: pyairtable (if installed with CLI dependencies: pip install 'pyairtable[cli]')
11
12
# Authentication (required for all commands):
13
# --key API_KEY Provide API key directly
14
# --key-file PATH Read API key from file
15
# --key-env VAR_NAME Read API key from environment variable
16
17
# Global commands:
18
# whoami Get current user information
19
# bases List all accessible bases
20
21
# Base commands:
22
# base BASE_ID Show base information (default: schema)
23
# base BASE_ID schema Show base schema
24
# base BASE_ID collaborators Show base collaborators (Enterprise)
25
# base BASE_ID shares Show base shares (Enterprise)
26
# base BASE_ID orm [--table NAME] Generate Python ORM code
27
28
# Table commands:
29
# base BASE_ID table TABLE records Get table records
30
# base BASE_ID table TABLE schema Get table schema
31
# base BASE_ID table TABLE records [OPTIONS] Get filtered records
32
# --formula FORMULA Filter with formula
33
# --view VIEW_NAME Filter by view
34
# --limit N Limit number of records
35
# --sort FIELD Sort by field (can specify multiple)
36
# --field FIELD Include only specific fields (can specify multiple)
37
38
# Enterprise commands (Enterprise plans only):
39
# enterprise ENT_ID Show enterprise info (default: info)
40
# enterprise ENT_ID info Show enterprise information
41
# enterprise ENT_ID user EMAIL Show user information
42
# enterprise ENT_ID users Show all users
43
# enterprise ENT_ID users --all Show all enterprise users
44
# enterprise ENT_ID group GROUP_ID Show group information
45
# enterprise ENT_ID groups --all Show all groups
46
```
47
48
### Usage Examples
49
50
```bash
51
# Set API key via environment
52
export AIRTABLE_API_KEY="your_personal_access_token"
53
54
# Get current user info
55
python -m pyairtable whoami
56
57
# List all bases
58
python -m pyairtable bases
59
60
# Get base schema
61
python -m pyairtable base app1234567890abcde schema
62
63
# Get table records with filtering
64
python -m pyairtable base app1234567890abcde table "My Table" records \
65
--formula "AND({Status} = 'Active', {Priority} > 3)" \
66
--sort "Created" \
67
--field "Name" --field "Status" \
68
--limit 50
69
70
# Generate ORM code for all tables
71
python -m pyairtable base app1234567890abcde orm > models.py
72
73
# Generate ORM code for specific tables
74
python -m pyairtable base app1234567890abcde orm \
75
--table "Contacts" --table "Companies" > contact_models.py
76
77
# Enterprise user management
78
python -m pyairtable enterprise entYourEnterpriseId users --all
79
80
# Get specific user details
81
python -m pyairtable enterprise entYourEnterpriseId user user@company.com
82
```