详细分析 ▾
运行时依赖
版本
- Initial release of Supabase API integration. - Enables managed authentication and access to Supabase database tables, auth users, and storage buckets via the Maton Gateway. - Provides API reference for querying tables, managing users, and using storage. - Includes connection management and usage examples with required environment variable (MATON_API_KEY). - Documentation for common operations with sample Python code and endpoint details.
安装命令
点击复制本土化适配说明
Supabase — Supabase工具 安装说明: 安装命令:npx clawhub@latest install supabase-api
技能文档
Access the Supabase API with managed authentication. Query database tables via PostgREST, manage auth users, and handle storage buckets.
Quick 开始
# List storage buckets
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://gateway.maton.ai/supabase/storage/v1/bucket')
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/supabase/{service}/{native-api-path}
The gateway proxies requests to your connected Supabase project. Services include:
rest/v1- PostgREST API (数据库 tables)auth/v1- GoTrue authentication APIstorage/v1- Storage API
Authentication
All requests require the Maton API key in the Authorization header:
Authorization: Bearer $MATON_API_KEY
Environment 变量: 设置 API 键 作为 MATON_API_KEY:
export MATON_API_KEY="YOUR_API_KEY"
Getting API 键
- 签名 在...中 或 创建 账户 在 maton.ai
- Go 到 maton.ai/settings
- 复制 API 键
连接 Management
Manage your Supabase connections at https://ctrl.maton.ai.
列表 Connections
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://ctrl.maton.ai/connections?app=supabase&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
创建 连接
python <<'EOF'
import urllib.request, os, json
data = json.dumps({'app': 'supabase'}).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
获取 连接
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
响应:
{
"connection": {
"connection_id": "c22a6ea6-4cf6-42a0-9e1c-d81ca8d6fc7e",
"status": "ACTIVE",
"creation_time": "2026-03-29T22:47:35.570344Z",
"last_updated_time": "2026-03-29T22:48:23.435225Z",
"url": "https://connect.maton.ai/?session_token=...",
"app": "supabase",
"metadata": {}
}
}
Open the returned url in a browser to complete authentication setup.
删除 连接
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 连接
If you have multiple Supabase connections, specify which one to use with the Maton-Connection header:
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://gateway.maton.ai/supabase/storage/v1/bucket')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Maton-Connection', 'c22a6ea6-4cf6-42a0-9e1c-d81ca8d6fc7e')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
If omitted, the gateway uses the default (oldest) active connection.
API Reference
数据库 (PostgREST)
The PostgREST API auto-generates endpoints based on your database schema. Access tables and views in the public schema.
获取 OpenAPI Schema
GET /supabase/rest/v1/
Returns the OpenAPI specification describing all available tables and endpoints.
列表 Records 从 表
GET /supabase/rest/v1/{table_name}
查询 Parameters:
select- Columns 到 return (e.g.,select=id,name,email)order- 排序 order (e.g.,order=created_at.desc)limit- Maximum records 到 returnoffset- 数字 的 records 到 skip
示例:
GET /supabase/rest/v1/users?select=id,email&order=created_at.desc&limit=10
获取 Single 记录
GET /supabase/rest/v1/{table_name}?id=eq.{id}&select=
Insert Records
POST /supabase/rest/v1/{table_name} Content-Type: application/json Prefer: return=representation
{ "name": "John Doe", "email": "john@example.com" }
更新 Records
PATCH /supabase/rest/v1/{table_name}?id=eq.{id} Content-Type: application/json Prefer: return=representation
{ "name": "Jane Doe" }
删除 Records
DELETE /supabase/rest/v1/{table_name}?id=eq.{id}
Filtering Operators
| Operator | Meaning | Example |
|---|---|---|
eq | Equals | ?status=eq.active |
neq | Not equals | ?status=neq.deleted |
gt | Greater than | ?age=gt.18 |
gte | Greater than or equal | ?age=gte.18 |
lt | Less than | ?age=lt.65 |
lte | Less than or equal | ?age=lte.65 |
like | Pattern match | ?name=like.john |
ilike | Case-insensitive pattern | ?name=ilike.john* |
in | In list | ?status=in.(active,pending) |
is | Is null/true/false | ?deleted_at=is.null |
Auth (GoTrue)
获取 Auth Health
GET /supabase/auth/v1/health
响应:
{
"version": "v2.188.1",
"name": "GoTrue",
"description": "GoTrue is a user registration and authentication API"
}
获取 Auth Settings
GET /supabase/auth/v1/settings
响应:
{
"external": {
"email": true,
"phone": false,
"google": false,
"github": false
},
"disable_signup": false,
"mailer_autoconfirm": false
}
列表 Users (管理员)
GET /supabase/auth/v1/admin/users
响应:
{
"users": [
{
"id": "8974a9fa-95c4-4839-8d50-76f4666d2113",
"email": "user@example.com",
"email_confirmed_at": "2026-03-29T23:01:46.718322Z",
"created_at": "2026-03-29T23:01:46.689584Z"
}
],
"aud": "authenticated"
}
获取 用户 (管理员)
GET /supabase/auth/v1/admin/users/{user_id}
创建 用户 (管理员)
POST /supabase/auth/v1/admin/users Content-Type: application/json
{ "email": "newuser@example.com", "password": "securepassword123", "email_confirm": true }
响应:
{
"id": "8974a9fa-95c4-4839-8d50-76f4666d2113",
"email": "newuser@example.com",
"email_confirmed_at": "2026-03-29T23:01:46.718322Z",
"role": "authenticated",
"app_metadata": {
"provider": "email",
"providers": ["email"]
}
}
更新 用户 (管理员)
PUT /supabase/auth/v1/admin/users/{user_id} Content-Type: application/json
{ "email": "updated@example.com", "user_metadata": { "name": "Updated Name" } }
删除 用户 (管理员)
DELETE /supabase/auth/v1/admin/users/{user_id}
Storage
列表 Buckets
GET /supabase/storage/v1/bucket
响应:
[
{
"id": "avatars",
"name": "avatars",
"public": true,
"created_at": "2026-03-29T23:01:06.638Z",
"updated_at": "2026-03-29T23:01:06.638Z"
}
]
获取 Bucket
GET /supabase/storage/v1/bucket/{bucket_id}
创建 Bucket
POST /supabase/storage/v1/bucket Content-Type: application/json
{ "id": "documents", "name": "documents", "public": false, "file_size_limit": 10485760, "allowed_mime_types": ["application/pdf", "image/png"] }
更新 Bucket
PUT /supabase/storage/v1/bucket/{bucket_id} Content-Type: application/json
{ "public": true }
删除 Bucket
DELETE /supabase/storage/v1/bucket/{bucket_id}
列表 Objects 在...中 Bucket
POST /supabase/storage/v1/object/list/{bucket_id} Content-Type: application/json
{ "prefix": "", "limit": 100, "offset": 0 }
上传 对象
POST /supabase/storage/v1/object/{bucket_id}/{path} Content-Type: {mime_type}
{binary_data}
下载 对象
GET /supabase/storage/v1/object/{bucket_id}/{path}
删除 对象
DELETE /supabase/storage/v1/object/{bucket_id}/{path}
分页
PostgREST 分页
Use limit and offset query parameters:
GET /supabase/rest/v1/users?limit=10&offset=20
Use the Range header for range-based pagination:
GET /supabase/rest/v1/users
Range: 0-9
Auth 用户 分页
GET /supabase/auth/v1/admin/users?page=1&per_page=50
Code Examples
JavaScript
// List storage buckets
const response = await fetch(
'https://gateway.maton.ai/supabase/storage/v1/bucket',
{
headers: {
'Authorization': Bearer ${process.env.MATON_API_KEY}
}
}
);
const buckets = await response.json();
Python
import os import requests
# Query database table response = requests.get( 'https://gateway.maton.ai/supabase/rest/v1/users', headers={'Authorization': f'Bearer {os.environ["MATON_API_KEY"]}'}, params={'select': 'id,email', 'limit': 10} ) users = response.json()
创建 用户 和 Storage Bucket
import os import requestsheaders = { 'Authorization': f'Bearer {os.environ["MATON_API_KEY"]}', 'Content-Type': 'application/json' }
# Create auth user user_resp = requests.post( 'https://gateway.maton.ai/supabase/auth/v1/admin/users', headers=headers, json={ 'email': 'test@example.com', 'password': 'securepass123', 'email_confirm': True } ) user = user_resp.json()
# Create storage bucket bucket_resp = requests.post( 'https://gateway.maton.ai/supabase/storage/v1/bucket', headers=headers, json={ 'id': 'user-uploads', 'name': 'user-uploads', 'public': False } ) bucket = bucket_resp.json()
Notes
- 连接 routes 到 specific Supabase project configured 期间 setup
- PostgREST endpoints auto-generated 从 数据库 schema
- 使用
Prefer: return=representation页头 到 获取 created/updated records back - Storage bucket names 必须 unique 在...内 project
- Auth 管理员 endpoints require 服务 角色 permissions
- 数据库 queries support complex filtering, ordering, 和 joins 通过 PostgREST syntax
- IMPORTANT: 当...时 使用 curl commands, 使用
curl -g当...时 URLs contain brackets 或 special characters - IMPORTANT: 当...时 piping curl 输出 到
jq, environment variables 可能 不 expand correctly 在...中 一些 shells
错误 Handling
| Status | Meaning |
|---|---|
| 400 | Missing Supabase connection or invalid request |
| 401 | Invalid or missing Maton API key |
| 404 | Table or resource not found |
| 409 | Conflict (e.g., duplicate bucket name) |
| 429 | Rate limited |
| 4xx/5xx | Passthrough error from Supabase API |
PostgREST Errors
{
"code": "PGRST205",
"details": null,
"hint": null,
"message": "Could not find the table 'public.users' in the schema cache"
}