ClawSkills logoClawSkills

Airtable

集成 Airtable API 并提供托管的 OAuth。管理 bases、表和记录。当用户想要读取、创建、更新或删除 Airtable 记录

介绍

# Airtable

使用托管的 OAuth 身份验证访问 Airtable API。通过完整的 CRUD 操作管理 Base、Table 和记录。

## Quick Start

```bash # List records from a table python <<'EOF' import urllib.request, os, json req = urllib.request.Request('https://gateway.maton.ai/airtable/v0/{baseId}/{tableIdOrName}?maxRecords=100') req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}') print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2)) EOF ```

## Base URL

``` https://gateway.maton.ai/airtable/{native-api-path} ```

将 `{native-api-path}` 替换为实际的 Airtable API 端点路径。网关将请求代理到 `api.airtable.com` 并自动注入您的 OAuth 令牌。

## Authentication

所有请求都需要在 Authorization 头中包含 Maton API 密钥:

``` Authorization: Bearer $MATON_API_KEY ```

**Environment Variable:** 将您的 API 密钥设置为 `MATON_API_KEY`:

```bash export MATON_API_KEY="YOUR_API_KEY" ```

### Getting Your API Key

1. 在 [maton.ai](https://maton.ai) 登录或创建账户 2. 访问 [maton.ai/settings](https://maton.ai/settings) 3. 复制您的 API 密钥

## Connection Management

在 `https://ctrl.maton.ai` 管理您的 Airtable OAuth 连接。

### List Connections

```bash python <<'EOF' import urllib.request, os, json req = urllib.request.Request('https://ctrl.maton.ai/connections?app=airtable&status=ACTIVE') req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}') print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2)) EOF ```

### Create Connection

```bash python <<'EOF' import urllib.request, os, json data = json.dumps({'app': 'airtable'}).encode() req = urllib.request.Request('https://ctrl.maton.ai/connections', data=data, method='POST') req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}') req.add_header('Content-Type', 'application/json') print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2)) EOF ```

### Get Connection

```bash python <<'EOF' import urllib.request, os, json req = urllib.request.Request('https://ctrl.maton.ai/connections/{connection_id}') req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}') print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2)) EOF ```

**Response:** ```json { "connection": { "connection_id": "21fd90f9-5935-43cd-b6c8-bde9d915ca80", "status": "ACTIVE", "creation_time": "2025-12-08T07:20:53.488460Z", "last_updated_time": "2026-01-31T20:03:32.593153Z", "url": "https://connect.maton.ai/?session_token=...", "app": "airtable", "metadata": {} } } ```

在浏览器中打开返回的 `url` 以完成 OAuth 授权。

### Delete Connection

```bash python <<'EOF' import urllib.request, os, json req = urllib.request.Request('https://ctrl.maton.ai/connections/{connection_id}', method='DELETE') req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}') print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2)) EOF ```

### Specifying Connection

如果您有多个 Airtable 连接,请使用 `Maton-Connection` 头指定要使用的连接:

```bash python <<'EOF' import urllib.request, os, json req = urllib.request.Request('https://gateway.maton.ai/airtable/v0/appXXXXX/TableName') req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}') req.add_header('Maton-Connection', '21fd90f9-5935-43cd-b6c8-bde9d915ca80') print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2)) EOF ```

如果省略,网关将使用默认(最早创建的)活动连接。

## API Reference

### List Bases

```bash GET /airtable/v0/meta/bases ```

### Get Base Schema

```bash GET /airtable/v0/meta/bases/{baseId}/tables ```

### List Records

```bash GET /airtable/v0/{baseId}/{tableIdOrName}?maxRecords=100 ```

With view:

```bash GET /airtable/v0/{baseId}/{tableIdOrName}?view=Grid%20view&maxRecords=100 ```

With filter formula:

```bash GET /airtable/v0/{baseId}/{tableIdOrName}?filterByFormula={Status}='Active' ```

With field selection:

```bash GET /airtable/v0/{baseId}/{tableIdOrName}?fields[]=Name&fields[]=Status&fields[]=Email ```

With sorting:

```bash GET /airtable/v0/{baseId}/{tableIdOrName}?sort[0][field]=Created&sort[0][direction]=desc ```

### Get Record

```bash GET /airtable/v0/{baseId}/{tableIdOrName}/{recordId} ```

### Create Records

```bash POST /airtable/v0/{baseId}/{tableIdOrName} Content-Type: application/json

{ "records": [ { "fields": { "Name": "New Record", "Status": "Active", "Email": "[email protected]" } } ] } ```

### Update Records (PATCH - partial update)

```bash PATCH /airtable/v0/{baseId}/{tableIdOrName} Content-Type: application/json

{ "records": [ { "id": "recXXXXXXXXXXXXXX", "fields": { "Status": "Completed" } } ] } ```

### Update Records (PUT - full replace)

```bash PUT /airtable/v0/{baseId}/{tableIdOrName} Content-Type: application/json

{ "records": [ { "id": "recXXXXXXXXXXXXXX", "fields": { "Name": "Updated Name", "Status": "Active" } } ] } ```

### Delete Records

```bash DELETE /airtable/v0/{baseId}/{tableIdOrName}?records[]=recXXXXX&records[]=recYYYYY ```

## Pagination

使用 `pageSize` 和 `offset` 进行分页:

```bash GET /airtable/v0/{baseId}/{tableIdOrName}?pageSize=50&offset=itrXXXXXXXXXXX ```

当存在更多记录时,响应包含 `offset`:

```json { "records": [...], "offset": "itrXXXXXXXXXXX" } ```

## Code Examples

### JavaScript

```javascript const response = await fetch( 'https://gateway.maton.ai/airtable/v0/appXXXXX/TableName?maxRecords=10', { headers: { 'Authorization': `Bearer ${process.env.MATON_API_KEY}` } } ); ```

### Python

```python import os import requests

response = requests.get( 'https://gateway.maton.ai/airtable/v0/appXXXXX/TableName', headers={'Authorization': f'Bearer {os.environ["MATON_API_KEY"]}'}, params={'maxRecords': 10} ) ```

## Notes

- Base ID 以 `app` 开头 - Table ID 以 `tbl` 开头(也可以使用表名称) - Record ID 以 `rec` 开头 - 每次 create/update 请求最多 100 条记录 - 每次 delete 请求最多 10 条记录 - 筛选公式使用 Airtable 公式语法 - 重要:使用 curl 命令时,如果 URL 包含括号(`fields[]`、`sort[]`、`records[]`),请使用 `curl -g` 以禁用 glob 解析 - 重要:将 curl 输出通过管道传递给 `jq` 或其他命令时,某些 shell 环境中可能无法正确展开环境变量(如 `$MATON_API_KEY`)。通过管道传输时可能会收到“Invalid API key”错误。

## Error Handling

| Status | Meaning | |--------|---------| | 400 | 缺少 Airtable 连接 | | 401 | Maton API 密钥无效或缺失 | | 429 | 速率受限(每账户 10 次/秒)| | 4xx/5xx | 来自 Airtable API 的透传错误 |

### Troubleshooting: API Key Issues

1. 检查是否已设置 `MATON_API_KEY` 环境变量:

```bash echo $MATON_API_KEY ```

2. 通过列出连接来验证 API 密钥是否有效:

```bash python <<'EOF' import urllib.request, os, json req = urllib.request.Request('https://ctrl.maton.ai/connections') req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}') print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2)) EOF ```

### Troubleshooting: Invalid App Name

1. 确保您的 URL 路径以 `airtable` 开头。例如:

- 正确:`https://gateway.maton.ai/airtable/v0/{baseId}/{tableIdOrName}` - 错误:`https://gateway.maton.ai/v0/{baseId}/{tableIdOrName}`

## Resources

- [Airtable API Overview](https://airtable.com/developers/web/api/introduction) - [List Records](https://airtable.com/developers/web/api/list-records) - [Create Records](https://airtable.com/developers/web/api/create-records) - [Update Records](https://airtable.com/developers/web/api/update-record) - [Delete Records](https://airtable.com/developers/web/api/delete-record) - [Formula Reference](https://support.airtable.com/docs/formula-field-reference) - [Maton Community](https://discord.com/invite/dBfFAcefs2) - [Maton Support](mailto:[email protected])

更多产品