@automate.ax/client
公共Automate.ax管理API的Type安全客户端.
安装
bun add @automate.ax/client
API 密钥
import { createAutomateClient } from "@automate.ax/client"
const client = createAutomateClient({
apiKey: process.env.AUTOMATE_AX_API_KEY!,
})
const firstPage = await client.project.list({ limit: 25 })
for (const project of firstPage.items) {
console.log(project.name)
}
if (firstPage.items[0]) {
const automations = await client.automation.list({
projectId: firstPage.items[0].id,
limit: 25,
})
if (automations.items[0]) {
const automation = await client.automation.get({
automation: automations.items[0].id,
})
console.log(automation.triggers)
}
}
清单程序返回 { items, pageInfo }时 pageInfo.hasMore 是真的,通过 pageInfo.nextCursor 作为下一个请求 cursor。 。 。 .
钥匙是组织拥有的,寄入 x-api-key 头曰. 它不代表用户会话.
客户目标 https://automate.ax/api/rpc。嵌入式和本地呼叫器可以覆盖 rpcUrl,提供自定义 fetch,并按请求添加 headers数字 :
const client = createAutomateClient({
apiKey: process.env.AUTOMATE_AX_API_KEY!,
rpcUrl: "https://automate.test/api/rpc",
headers: () => ({ "x-request-source": "local-test" }),
})
认证信头是附加信头后设置的,不能被覆盖 headers。 。 。 .
Automate.ax 动作运行时间使用相同的客户端 runtimeToken。该模式用于平台提供的活性执行符;它不是外部应用程序中组织API密钥的替换.
用户会话
用户范围程序,包括执行数据发现,使用登录用户的无记名会话:
import { createAutomateClient } from "@automate.ax/client"
const client = createAutomateClient({
sessionToken: process.env.AUTOMATE_SESSION_TOKEN!,
})
const manifest = await client.executionData.manifest({
projectId: "proj_01...",
since: "2026-08-01T00:00:00Z",
})
console.log(manifest.consistency, manifest.resources)
信誉回调在每次请求之前都会得到评价,因此客户端可以使用刷新后发回的符号而无需再被创建. 供应的正中之一 apiKey, (中文(简体) ), runtimeToken,或 sessionToken。 。 。 .