Loading...
Loading...
Compare original and translation side by side
sgsgsg --versioncommand not foundnpm install -g @superglue/clisg system listfetch failedsg initsg system findsg system search-docssg system call<<systemId_credentialKey>>sg tool buildsg tool runsg tool save --draft <id>--credentials--sensitive-credentials--credentials '{"api_key":"sk-xxx"}'sg --versioncommand not foundnpm install -g @superglue/clisg system listfetch failedsg initsg system findsg system search-docssg system call<<systemId_credentialKey>>sg tool buildsg tool runsg tool save --draft <id>--credentials--sensitive-credentials--credentials '{"api_key":"sk-xxx"}'npm install -g @superglue/clisgnpm install -g @superglue/clisghttps://api.superglue.cloudsg inithttps://api.superglue.cloudstdoutstdout+file.superglue/config.json~/.superglue/config.jsondrafts/.gitignoresg initexport SUPERGLUE_API_KEY="your-api-key"
export SUPERGLUE_API_ENDPOINT="https://api.superglue.cloud" # optional, this is the defaultsgsg system list --api-key "your-key" --endpoint "https://api.superglue.cloud"https://api.superglue.cloudsg inithttps://api.superglue.cloudstdoutstdout+file.superglue/config.json~/.superglue/config.jsondrafts/.gitignoresg initexport SUPERGLUE_API_KEY="your-api-key"
export SUPERGLUE_API_ENDPOINT="https://api.superglue.cloud" # 可选,此为默认值sgsg system list --api-key "your-key" --endpoint "https://api.superglue.cloud".superglue/config.json~/.superglue/config.json.superglue/config.json~/.superglue/config.jsonsg system list # should return a list (possibly empty) without errorssg system list # 应返回列表(可能为空)且无错误sg system list
sg tool build --config '{"id":"...","instruction":"...","steps":[...]}'
sg tool run --draft <draftId>
sg tool save --draft <draftId>sg system list
sg tool build --config '{"id":"...","instruction":"...","steps":[...]}'
sg tool run --draft <draftId>
sg tool save --draft <draftId>| Flag | Description |
|---|---|
| Force JSON output (auto-enabled in non-TTY) |
| Override API key |
| Override API endpoint |
| 标志 | 描述 |
|---|---|
| 强制输出JSON格式(在非TTY环境下自动启用) |
| 覆盖API密钥 |
| 覆盖API端点 |
sg initsg init.superglue/.superglue/sg tool builddraftIdsg tool build --config '{"id":"...","steps":[...]}' # inline JSON
sg tool build --id my-tool --instruction "..." --steps steps.json --payload '{"key":"val"}'
sg tool build --config tool.json # from file--config <file-or-json>--id <id>--instruction <text>--steps <file>--payload <json>--file <key=path>sg tool runsg tool run --draft <draftId> --payload '{"userId":"123"}'
sg tool run --tool my-tool --payload-file payload.json--draft <id>--tool <id>--payload <json>--payload-file <path>--include-step-results--include-configsg tool editsg tool edit --draft <draftId> --patches '[{"op":"replace","path":"/steps/0/config/url","value":"..."}]'
sg tool edit --tool my-tool --patches patches.json--patches <json-or-file>sg tool savesg tool save --draft <draftId>sg tool listsg tool findsg tool list # all non-archived tools
sg tool find "shopify orders" # search (compact results)
sg tool find --id my-tool # exact ID lookup (full config)sg tool builddraftIdsg tool build --config '{"id":"...","steps":[...]}' # 内联JSON
sg tool build --id my-tool --instruction "..." --steps steps.json --payload '{"key":"val"}'
sg tool build --config tool.json # 从文件加载--config <file-or-json>--id <id>--instruction <text>--steps <file>--payload <json>--file <key=path>sg tool runsg tool run --draft <draftId> --payload '{"userId":"123"}'
sg tool run --tool my-tool --payload-file payload.json--draft <id>--tool <id>--payload <json>--payload-file <path>--include-step-results--include-configsg tool editsg tool edit --draft <draftId> --patches '[{"op":"replace","path":"/steps/0/config/url","value":"..."}]'
sg tool edit --tool my-tool --patches patches.json--patches <json-or-file>sg tool savesg tool save --draft <draftId>sg tool listsg tool findsg tool list # 所有未归档的工具
sg tool find "shopify orders" # 搜索(精简结果)
sg tool find --id my-tool # 精确ID查找(完整配置)sg system create--name <name>--url <url>--template--id <id>--name--template <id>sg system create --name "My API" --url https://api.example.com \
--credentials '{"api_key":"sk-xxx"}'sg system create --name "Slack" --template slack| Flag | Description |
|---|---|
| Human-readable name — REQUIRED |
| System ID (lowercase, underscores only) — derived from name if omitted |
| API base URL — REQUIRED (auto-filled by |
| Template ID (stripe, shopify, slack, etc.) |
| Credentials JSON (use for ALL creds in non-interactive mode) |
| Comma-separated fields for masked input (TTY only — do NOT use in AI agents) |
| Documentation URL to scrape |
| OpenAPI spec URL |
| Environment: |
sg system edit--env dev|prodsg system listsg system findfind--env dev|prodsg system callundefinedsg system create--name <name>--url <url>--template--id <id>--name--template <id>sg system create --name "My API" --url https://api.example.com \
--credentials '{"api_key":"sk-xxx"}'sg system create --name "Slack" --template slack| 标志 | 描述 |
|---|---|
| 人类可读名称 — 必填 |
| 系统ID(仅小写字母和下划线) — 如果省略,将从名称派生 |
| API基础URL — 必填(使用 |
| 模板ID(stripe、shopify、slack等) |
| 凭证JSON(非交互式模式下用于所有凭证) |
| 逗号分隔的掩码输入字段(仅TTY环境可用 — 请勿在AI Agent中使用) |
| 要抓取的文档URL |
| OpenAPI规范URL |
| 环境: |
sg system edit--env dev|prodsg system listsg system findfind--env dev|prodsg system callundefined
| Flag | Description |
| ------------------- | --------------------------------------------------------- |
| `--url <url>` | Full URL with protocol (http/https/postgres/sftp/ftp/smb) |
| `--system-id <id>` | System ID for credential injection |
| `--method <method>` | HTTP method (GET, POST, PUT, DELETE, PATCH) |
| `--headers <json>` | HTTP headers JSON with credential placeholders |
| `--body <string>` | Request body (JSON string) |
| `--env <env>` | Environment: `dev` or `prod` |
| `--file <key=path>` | File references (repeatable) |
**`sg system search-docs`** — Search system documentation.
```bash
sg system search-docs --system-id slack -k "send message channels"sg system oauthsg system oauth --system-id gmail --scopes "https://www.googleapis.com/auth/gmail.readonly"
sg system oauth --system-id my_api --grant-type client_credentials --scopes "read write"--system-id <id>--scopes <scopes>--grant-type <type>authorization_codeclient_credentials
| 标志 | 描述 |
| ------------------- | -------------------------------------------------- |
| `--url <url>` | 带协议的完整URL(http/https/postgres/sftp/ftp/smb) |
| `--system-id <id>` | 用于凭证注入的系统ID |
| `--method <method>` | HTTP方法(GET、POST、PUT、DELETE、PATCH) |
| `--headers <json>` | 带凭证占位符的HTTP头JSON |
| `--body <string>` | 请求体(JSON字符串) |
| `--env <env>` | 环境:`dev`或`prod` |
| `--file <key=path>` | 文件引用(可重复使用) |
**`sg system search-docs`** — 搜索系统文档。
```bash
sg system search-docs --system-id slack -k "send message channels"sg system oauthsg system oauth --system-id gmail --scopes "https://www.googleapis.com/auth/gmail.readonly"
sg system oauth --system-id my_api --grant-type client_credentials --scopes "read write"--system-id <id>--scopes <scopes>--grant-type <type>authorization_codeclient_credentialssg run list--tool--status--source--limitsg run get <runId>--fetch-resultssg run list--tool--status--source--limitsg run get <runId>--fetch-results{
"id": "kebab-case-tool-name",
"instruction": "Brief human-readable description of what this tool does",
"steps": [
{
"id": "unique-step-id",
"config": {
"systemId": "example_system",
"url": "https://api.example.com/endpoint?param=<<payload_field>>",
"method": "GET",
"headers": {
"Authorization": "Bearer <<example_system_access_token>>"
},
"queryParams": { "limit": "10" },
"body": "{ \"key\": \"<<payload_field>>\" }"
},
"dataSelector": "(sourceData) => sourceData.previousStep.data.items",
"failureBehavior": "fail"
}
],
"outputTransform": "(sourceData) => sourceData.stepId.data",
"outputSchema": { "type": "object", "properties": {} },
"inputSchema": { "type": "object", "properties": {} }
}{
"id": "kebab-case-tool-name",
"instruction": "Brief human-readable description of what this tool does",
"steps": [
{
"id": "unique-step-id",
"config": {
"systemId": "example_system",
"url": "https://api.example.com/endpoint?param=<<payload_field>>",
"method": "GET",
"headers": {
"Authorization": "Bearer <<example_system_access_token>>"
},
"queryParams": { "limit": "10" },
"body": "{ \"key\": \"<<payload_field>>\" }"
},
"dataSelector": "(sourceData) => sourceData.previousStep.data.items",
"failureBehavior": "fail"
}
],
"outputTransform": "(sourceData) => sourceData.stepId.data",
"outputSchema": { "type": "object", "properties": {} },
"inputSchema": { "type": "object", "properties": {} }
}| Field | Type | Description |
|---|---|---|
| string | |
| string | System whose credentials to use |
| string | Full URL with |
| string | HTTP method |
| object | HTTP headers with credential placeholders |
| object | URL query parameters |
| string | Request body (JSON string with placeholders) |
| object | Auto-pagination config (see below) |
| 字段 | 类型 | 描述 |
|---|---|---|
| 字符串 | |
| 字符串 | 要使用其凭证的系统ID |
| 字符串 | 带 |
| 字符串 | HTTP方法 |
| 对象 | 带凭证占位符的HTTP头 |
| 对象 | URL查询参数 |
| 字符串 | 请求体(带占位符的JSON字符串) |
| 对象 | 自动分页配置(见下文) |
| Field | Type | Description |
|---|---|---|
| string | |
| string | JS function: |
| 字段 | 类型 | 描述 |
|---|---|---|
| 字符串 | |
| 字符串 | JS函数: |
| Field | Type | Description |
|---|---|---|
| string | JS function controlling step input and loop mode |
| string | |
| 字段 | 类型 | 描述 |
|---|---|---|
| 字符串 | 控制步骤输入和循环模式的JS函数 |
| 字符串 | |
<<systemId_credentialKey>><<systemId_credentialKey>>{"Authorization": "Bearer <<stripe_api_key>>"}
{"Authorization": "Bearer <<gmail_access_token>>"}
{"X-API-Key": "<<my_api_api_key>>"}
{"Authorization": "Basic <<my_api_username>>:<<my_api_password>>"}Basic {"Authorization": "Bearer <<stripe_api_key>>"}
{"Authorization": "Bearer <<gmail_access_token>>"}
{"X-API-Key": "<<my_api_api_key>>"}
{"Authorization": "Basic <<my_api_username>>:<<my_api_password>>"}Basic client_idauth_url--credentialsapi_keyclient_secret--credentials--sensitive-credentialsSUPERGLUE_CRED_<FIELD>access_tokenrefresh_tokenclient_idauth_url--credentialsapi_keyclient_secret--credentials--sensitive-credentialsSUPERGLUE_CRED_<FIELD>access_tokenrefresh_token<<variable>>| Syntax | Resolves to |
|---|---|
| Payload field or credential |
| System credential |
| JavaScript expression |
<<varName>><<userId>><<currentItem>><<stripe_api_key>><<currentItem.id>><<sourceData.userId>><<(sourceData) => sourceData.currentItem.id>><<variable>>| 语法 | 解析目标 |
|---|---|
| 负载字段或凭证 |
| 系统凭证 |
| JavaScript表达式 |
<<varName>><<userId>><<currentItem>><<stripe_api_key>><<currentItem.id>><<sourceData.userId>><<(sourceData) => sourceData.currentItem.id>>sourceDatasourceData = {
// Payload fields at ROOT level (NEVER use sourceData.payload.*)
userId: "123",
date: "2024-01-15",
// Previous step results, keyed by step ID
// Object-selector step:
getUsers: { currentItem: {}, data: { users: [...] }, success: true },
// Array-selector (loop) step:
fetchDetails: [
{ currentItem: "id1", data: { name: "Alice" }, success: true },
{ currentItem: "id2", data: { name: "Bob" }, success: true },
],
// Current loop item (only set inside a looping step's config)
currentItem: { id: 1 },
// Credentials (flattened, namespaced)
systemId_access_token: "...",
systemId_api_key: "..."
}sourceDatasourceData = {
// 根级别的负载字段(绝不要使用sourceData.payload.*)
userId: "123",
date: "2024-01-15",
// 之前步骤的结果,按步骤ID键存储
// 对象选择器步骤:
getUsers: { currentItem: {}, data: { users: [...] }, success: true },
// 数组选择器(循环)步骤:
fetchDetails: [
{ currentItem: "id1", data: { name: "Alice" }, success: true },
{ currentItem: "id2", data: { name: "Bob" }, success: true },
],
// 当前循环项(仅在循环步骤的配置中设置)
currentItem: { id: 1 },
// 凭证(扁平化、命名空间化)
systemId_access_token: "...",
systemId_api_key: "..."
}sourceData.stepId = { currentItem: <selectorOutput>, data: <apiResponse>, success: true }
// Access the API response:
sourceData.stepId.data
sourceData.stepId.data.userssourceData.stepId = [
{ currentItem: <item1>, data: <response1>, success: true },
{ currentItem: <item2>, data: <response2>, success: true },
...
]sourceData.stepId = { currentItem: <selectorOutput>, data: <apiResponse>, success: true }
// 访问API响应:
sourceData.stepId.data
sourceData.stepId.data.userssourceData.stepId = [
{ currentItem: <item1>, data: <response1>, success: true },
{ currentItem: <item2>, data: <response2>, success: true },
...
]| Return type | Behavior |
|---|---|
| Single object | Step runs once with that object |
| Array | Step runs once per item (loop mode) |
| Step receives full sourceData |
sourceData.currentItem| 返回类型 | 行为 |
|---|---|
| 单个对象 | 步骤使用该对象运行一次 |
| 数组 | 步骤针对每个项运行一次(循环模式) |
| 步骤接收完整的sourceData |
sourceData.currentItem{
"id": "get-users",
"config": {
"type": "request",
"systemId": "my_api",
"url": "https://api.example.com/users",
"method": "GET",
"headers": { "Authorization": "Bearer <<my_api_access_token>>" }
}
}{
"id": "format-data",
"config": {
"type": "transform",
"transformCode": "(sourceData) => sourceData.getUsers.data.map(u => ({ id: u.id, name: u.fullName }))"
}
}systemIdurlmethodheadersbodyqueryParamspaginationtransformCodesourceData.data| Need | Use |
|---|---|
| Filter/reshape data for a SUBSEQUENT request step | Transform step ( |
| Shape the final tool output | |
| Select input / control looping for a step | |
| Inline data computation in URL/body/headers | |
{
"id": "get-users",
"config": {
"type": "request",
"systemId": "my_api",
"url": "https://api.example.com/users",
"method": "GET",
"headers": { "Authorization": "Bearer <<my_api_access_token>>" }
}
}{
"id": "format-data",
"config": {
"type": "transform",
"transformCode": "(sourceData) => sourceData.getUsers.data.map(u => ({ id: u.id, name: u.fullName }))"
}
}systemIdurlmethodheadersbodyqueryParamspaginationtransformCodesourceData.data| 需求 | 使用方式 |
|---|---|
| 为后续请求步骤过滤/重新格式化数据 | 转换步骤( |
| 格式化工具的最终输出 | |
| 选择步骤输入 / 控制步骤循环 | 步骤上的 |
| 在URL/请求体/头中内联数据计算 | |
sourceData{ ...originalPayload, ...previousStepResults, ...credentials }dataSelector(sourceData)currentItemsourceData<<>>.datatransformCode(sourceData).data{ currentItem, data, success }sourceData[stepId]outputTransform(sourceData)sourceData{ ...originalPayload, ...previousStepResults, ...credentials }dataSelector(sourceData)currentItemsourceData<<>>.datatransformCode(sourceData).data{ currentItem, data, success }sourceData[stepId]outputTransform(sourceData){
"pagination": {
"type": "offset|cursor|page",
"pageSize": 100,
"cursorPath": "$.nextPageToken",
"stopCondition": "(response) => !response.hasMore"
}
}| Type | How it works |
|---|---|
| Increments |
| Extracts next cursor from |
| Increments |
stopCondition{
"pagination": {
"type": "offset|cursor|page",
"pageSize": 100,
"cursorPath": "$.nextPageToken",
"stopCondition": "(response) => !response.hasMore"
}
}| 类型 | 工作原理 |
|---|---|
| 每页将 |
| 从 |
| 递增 |
stopConditioncredentials--credentialssensitiveCredentials--credentials '{"api_key":"..."}'--sensitive-credentialscredentials--credentialssensitiveCredentials--credentials '{"api_key":"..."}'--sensitive-credentialssg system findsg system findsg system create --name "Gmail" --url https://gmail.googleapis.com --credentials '{"auth_url":"...","token_url":"..."}' --sensitive-credentials client_id,client_secretsg system oauth --system-id gmail --scopes "..."sg system create --name "Gmail" --url https://gmail.googleapis.com --credentials '{"auth_url":"...","token_url":"..."}' --sensitive-credentials client_id,client_secretsg system oauth --system-id gmail --scopes "..."<<systemId_credKey>><<systemId_credKey>>--include-step-resultsdatasg system find --id <systemId>sg system call--include-step-resultsdatasg system find --id <systemId>sg system callundefinedundefinedundefinedundefinedimport { configure, runTool } from "@superglue/client";
configure({ apiKey: process.env.SUPERGLUE_API_KEY!, baseUrl: "https://api.superglue.cloud/v1" });
const response = await runTool("my-tool-id", { inputs: { userId: "123" } });
// response.data is a Run object: { runId, toolId, status, data, error, metadata }import { configure, runTool } from "@superglue/client";
configure({ apiKey: process.env.SUPERGLUE_API_KEY!, baseUrl: "https://api.superglue.cloud/v1" });
const response = await runTool("my-tool-id", { inputs: { userId: "123" } });
// response.data是Run对象:{ runId, toolId, status, data, error, metadata }import os
from superglue_client import AuthenticatedClient
from superglue_client.api.tools import run_tool
from superglue_client.models.run_request import RunRequest
from superglue_client.models.run_request_inputs import RunRequestInputs
client = AuthenticatedClient(base_url="https://api.superglue.cloud/v1", token=os.environ["SUPERGLUE_API_KEY"])
with client as c:
result = run_tool.sync("my-tool-id", client=c, body=RunRequest(inputs=RunRequestInputs.from_dict({"userId": "123"})))import os
from superglue_client import AuthenticatedClient
from superglue_client.api.tools import run_tool
from superglue_client.models.run_request import RunRequest
from superglue_client.models.run_request_inputs import RunRequestInputs
client = AuthenticatedClient(base_url="https://api.superglue.cloud/v1", token=os.environ["SUPERGLUE_API_KEY"])
with client as c:
result = run_tool.sync("my-tool-id", client=c, body=RunRequest(inputs=RunRequestInputs.from_dict({"userId": "123"})))references/| File | When to read |
|---|---|
| READ THIS when deploying tools to production - SDK usage, REST API, webhooks, error handling |
| Building tools that query PostgreSQL/MySQL databases |
| Building tools that interact with FTP/SFTP/SMB file servers |
| Complex data transformations, output shaping, JS sandbox constraints |
references/integration.mdreferences/| 文件 | 阅读时机 |
|---|---|
| 务必阅读此文件,当你将工具部署到生产环境时 - SDK使用、REST API、Webhook、错误处理 |
| 构建查询PostgreSQL/MySQL数据库的工具时阅读 |
| 构建与FTP/SFTP/SMB文件服务器交互的工具时阅读 |
| 处理复杂数据转换、输出格式化、JS沙箱约束时阅读 |
references/integration.md.superglue/drafts/<draftId>.jsonbuildeditsave.superglue/drafts/<draftId>.jsonbuildeditsave--file key=pathfile::<key>sg tool run --draft <id> --payload '{"data": "file::mysheet"}' --file mysheet=data.xlsx--file key=pathfile::<key>sg tool run --draft <id> --payload '{"data": "file::mysheet"}' --file mysheet=data.xlsx