介绍
# JotForm
使用托管的 OAuth 身份验证访问 JotForm API。创建和管理表单、获取提交记录以及管理 Webhook。
## 快速开始
```bash # List user forms python <<'EOF' import urllib.request, os, json req = urllib.request.Request('https://gateway.maton.ai/jotform/user/forms?limit=20') req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}') print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2)) EOF ```
## 基础 URL
``` https://gateway.maton.ai/jotform/{native-api-path} ```
将 `{native-api-path}` 替换为实际的 JotForm API 端点路径。网关会将请求代理到 `api.jotform.com` 并自动注入您的 API 密钥。
## 身份验证
所有请求都需要在 Authorization header 中提供 Maton API 密钥:
``` Authorization: Bearer $MATON_API_KEY ```
**环境变量:** 将您的 API 密钥设置为 `MATON_API_KEY`:
```bash export MATON_API_KEY="YOUR_API_KEY" ```
### 获取您的 API 密钥
1. 在 [maton.ai](https://maton.ai) 登录或创建账户 2. 前往 [maton.ai/settings](https://maton.ai/settings) 3. 复制您的 API 密钥
## 连接管理
在 `https://ctrl.maton.ai` 管理您的 JotForm 连接。
### 列出连接
```bash python <<'EOF' import urllib.request, os, json req = urllib.request.Request('https://ctrl.maton.ai/connections?app=jotform&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 ```
### 创建连接
```bash python <<'EOF' import urllib.request, os, json data = json.dumps({'app': 'jotform'}).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 ```
### 获取连接
```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 ```
**响应:** ```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": "jotform", "metadata": {} } } ```
在浏览器中打开返回的 `url` 以完成 OAuth 授权。
### 删除连接
```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 ```
### 指定连接
如果您有多个 JotForm 连接,请使用 `Maton-Connection` header 指定要使用的连接:
```bash python <<'EOF' import urllib.request, os, json req = urllib.request.Request('https://gateway.maton.ai/jotform/user/forms') 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 参考
### 用户
```bash GET /jotform/user GET /jotform/user/forms?limit=20 GET /jotform/user/submissions?limit=20 GET /jotform/user/usage ```
### 表单
#### 获取表单
```bash GET /jotform/form/{formId} ```
#### 获取表单问题
```bash GET /jotform/form/{formId}/questions ```
#### 获取表单提交记录
```bash GET /jotform/form/{formId}/submissions?limit=20 ```
带过滤条件:
```bash GET /jotform/form/{formId}/submissions?filter={"created_at:gt":"2024-01-01"} ```
#### 创建表单
```bash POST /jotform/user/forms Content-Type: application/json
{ "properties": {"title": "Contact Form"}, "questions": { "1": {"type": "control_textbox", "text": "Name", "name": "name"}, "2": {"type": "control_email", "text": "Email", "name": "email"} } } ```
#### 删除表单
```bash DELETE /jotform/form/{formId} ```
### 提交记录
#### 获取提交记录
```bash GET /jotform/submission/{submissionId} ```
#### 删除提交记录
```bash DELETE /jotform/submission/{submissionId} ```
### Webhooks
```bash GET /jotform/form/{formId}/webhooks POST /jotform/form/{formId}/webhooks DELETE /jotform/form/{formId}/webhooks/{webhookIndex} ```
## 问题类型
- `control_textbox` - 单行文本 - `control_textarea` - 多行文本 - `control_email` - 邮箱 - `control_phone` - 电话号码 - `control_dropdown` - 下拉菜单 - `control_radio` - 单选按钮 - `control_checkbox` - 复选框 - `control_datetime` - 日期/时间选择器 - `control_fileupload` - 文件上传
## 过滤语法
```json {"field:gt":"value"} // Greater than {"field:lt":"value"} // Less than {"field:eq":"value"} // Equal to ```
## 代码示例
### JavaScript
```javascript const response = await fetch( 'https://gateway.maton.ai/jotform/user/forms?limit=10', { headers: { 'Authorization': `Bearer ${process.env.MATON_API_KEY}` } } ); ```
### Python
```python import os import requests
response = requests.get( 'https://gateway.maton.ai/jotform/user/forms', headers={'Authorization': f'Bearer {os.environ["MATON_API_KEY"]}'}, params={'limit': 10} ) ```
## 注意事项
- 表单 ID 是数字 - 分页使用 `limit` 和 `offset` - 使用 `orderby` 对结果进行排序 - 重要:在使用 curl 命令时,如果 URL 包含括号(`fields[]`、`sort[]`、`records[]`),请使用 `curl -g` 以禁用 glob 解析 - 重要:当将 curl 输出通过管道传递给 `jq` 或其他命令时,某些 shell 环境中的环境变量(如 `$MATON_API_KEY`)可能无法正确展开。在通过管道传递时,您可能会遇到“Invalid API key”错误。
## 错误处理
| 状态 | 含义 | |--------|---------| | 400 | 缺少 JotForm 连接 | | 401 | 无效或缺少 Maton API 密钥 | | 429 | 请求频率受限(每个账户每秒 10 次请求) | | 4xx/5xx | 来自 JotForm API 的透传错误 |
### 故障排除:API 密钥问题
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 ```
### 故障排除:无效的应用名称
1. 确保您的 URL 路径以 `jotform` 开头。例如:
- 正确:`https://gateway.maton.ai/jotform/user/forms` - 错误:`https://gateway.maton.ai/user/forms`
## 资源
- [JotForm API 概览](https://api.jotform.com/docs/) - [用户表单](https://api.jotform.com/docs/#user-forms) - [表单提交记录](https://api.jotform.com/docs/#form-id-submissions) - [Webhooks](https://api.jotform.com/docs/#form-id-webhooks) - [Maton 社区](https://discord.com/invite/dBfFAcefs2) - [Maton 支持](mailto:[email protected])