apify-integration-development
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseApify Integration Development
Apify集成开发
Design and build an official Apify integration for a company's product, with minimal help from Apify. This skill covers every integration shape Apify supports - workflow-automation apps, AI agent plugins (coding agents and harnesses), AI framework packages, and direct application clients - so a partner team can ship a first-class Apify integration end to end. The cross-cutting rules below apply to all of them, and one category-specific reference file carries the rest.
Building an official integration? Once you publish it, contact integrations@apify.com so the Apify team can review, test, and validate your integration before it reaches users. We'll check the capability surface, cost controls, error handling, and attribution headers, and help you close any gaps.
在仅需Apify少量协助的情况下,为企业产品设计并构建官方Apify集成。本技能涵盖Apify支持的所有集成形态——工作流自动化应用、AI Agent插件(编码Agent与harness)、AI框架包、直接应用客户端——以便合作团队能够端到端交付一流的Apify集成。以下通用规则适用于所有集成类型,特定分类的额外规则请参考对应的分类参考文件。
正在构建官方集成? 发布后请发送邮件至 integrations@apify.com,Apify团队会在集成面向用户前对其进行审核、测试和验证。我们会检查能力覆盖范围、成本控制、错误处理和归因头,并协助你补齐所有短板。
Step 0 - Learn the Apify model first (required)
步骤0 - 先了解Apify模式(必做)
Before designing anything, fetch and read . It is the canonical quickstart for AI agents and the single source of truth for vocabulary, the run flow, and the cost rule. If the fetch fails, the mini-glossary below keeps the skill usable.
https://apify.com/agents.mdApify vocabulary (always written with a capital A on the platform):
- Actor - a serverless cloud program that takes JSON input, performs a task, and produces structured output. Not an AI agent.
- Actor Run - one execution of an Actor. Each run has its own dataset, key-value store, and request queue, and ends in a terminal status (,
SUCCEEDED,FAILED,TIMED-OUT).ABORTED - Dataset - append-only structured storage for a run's results. An Actor call returns the dataset ID, not its contents.
- Key-Value Store - unstructured/file storage (screenshots, HTML, OUTPUT).
- Actor Task - a saved, parameterized configuration for running an Actor.
- Apify Store - the marketplace of Actors at .
https://apify.com/store.md - Apify Console - the web UI at .
https://console.apify.com - Compute Unit (CU) - billing unit: memory (MB) x duration (hours).
Further terms (build, standby, request queue, proxy, pricing models): .
https://docs.apify.com/llms.txt在进行任何设计之前,请获取并阅读 。这是AI Agent的官方快速入门指南,也是术语、运行流程和计费规则的唯一权威来源。如果无法获取该文档,下方的迷你术语表也能保证本技能的正常使用。
https://apify.com/agents.mdApify术语(在平台中书写时首字母始终大写):
- Actor - 一种接收JSON输入、执行任务并生成结构化输出的无服务器云程序。并非AI Agent。
- Actor Run - Actor的一次执行。每个运行实例都有独立的Dataset、Key-Value Store和请求队列,并以终止状态结束(、
SUCCEEDED、FAILED、TIMED-OUT)。ABORTED - Dataset - 用于存储运行结果的仅追加式结构化存储。Actor调用返回的是Dataset ID,而非其内容。
- Key-Value Store - 非结构化/文件存储(可存储截图、HTML、OUTPUT等)。
- Actor Task - 已保存的、参数化的Actor运行配置。
- Apify Store - 位于 的Actor市场。
https://apify.com/store.md - Apify Console - 位于 的网页管理界面。
https://console.apify.com - Compute Unit (CU) - 计费单位:内存(MB)× 时长(小时)。
更多术语(build、standby、请求队列、代理、定价模型):。
https://docs.apify.com/llms.txtUse Apify MCP for live context while planning
规划阶段使用Apify MCP获取实时上下文
The Apify MCP server is the fastest way to research Actors, schemas, pricing, and docs during integration design. See (append for a markdown version).
https://docs.apify.com/integrations/mcp.mdIf Apify MCP tools are already available in this environment, use them:
- - find Actors by platform/product keyword (search by product name, not end goal).
search-actors - - read an Actor's input schema, output format, README, and pricing before you encode its shape into the integration.
fetch-actor-details - /
search-apify-docs- pull contextual documentation pages.fetch-apify-docs
The anonymous discovery subset (, , , ) works without an account, so you can research even before the developer has connected their token.
search-actorsfetch-actor-detailssearch-apify-docsfetch-apify-docs在集成设计阶段,Apify MCP服务器是调研Actors、Schema、定价和文档的最快方式。参见 (追加 可获取Markdown版本)。
https://docs.apify.com/integrations/mcp.md如果当前环境中已提供Apify MCP工具,请使用以下工具:
- - 按平台/产品关键词查找Actors(请按产品名称搜索,而非最终目标)。
search-actors - - 在将Actor的形态集成到产品中之前,读取其输入Schema、输出格式、README和定价信息。
fetch-actor-details - /
search-apify-docs- 获取相关的文档页面。fetch-apify-docs
匿名发现工具子集(、、、)无需账号即可使用,因此甚至在开发者连接其Token之前就可以开展调研。
search-actorsfetch-actor-detailssearch-apify-docsfetch-apify-docsPick your integration shape
选择你的集成形态
Read exactly one reference file based on the product you are integrating into. Each reference carries the category-specific UX design, a canonical capability matrix, and a definition-of-done checklist.
| Product shape | Examples | Read |
|---|---|---|
| Workflow automation platform | Zapier, n8n, Make, Pipedream, Activepieces | |
| AI agent plugin (coding agent or harness) | Cursor, Claude Code, Codex, GitHub Copilot (coding agents); OpenClaw-style runtimes, Hermes-style harnesses (harnesses) | |
| AI framework package (PyPI/npm for LLM frameworks) | LangChain, LlamaIndex, Haystack, Vercel AI SDK | |
| Application integration (direct client) | A backend service, scheduled job, product feature calling Actors via | |
Paths are relative to this skill folder. If your product spans two shapes (e.g. an AI harness built on top of a framework package), read both - the rules compose. The AI agent plugin reference covers two approaches with different trade-offs: a lightweight skills + MCP bundle for skills/MCP-aware coding agents, and a custom tool-registry plugin for OpenClaw/Hermes-style harnesses.
根据你要集成的产品类型,仅需阅读对应的一份参考文件。每份参考文件都包含该分类特有的UX设计、标准能力矩阵和完成定义检查清单。
| 产品形态 | 示例 | 参考文件 |
|---|---|---|
| 工作流自动化平台 | Zapier, n8n, Make, Pipedream, Activepieces | |
| AI Agent插件(编码Agent或harness) | Cursor, Claude Code, Codex, GitHub Copilot(编码Agents);OpenClaw式运行时、Hermes式harness(harness类) | |
| AI框架包(面向LLM框架的PyPI/npm包) | LangChain, LlamaIndex, Haystack, Vercel AI SDK | |
| 应用集成(直接客户端) | 后端服务、定时任务、通过 | |
以上路径均相对于本技能文件夹。如果你的产品跨越两种形态(例如构建在框架包之上的AI harness),请同时阅读两份参考文件——规则是可组合的。AI Agent插件参考文件涵盖两种各有优劣的方案:面向支持skills/MCP的编码Agent的轻量级skills + MCP组合包,以及面向OpenClaw/Hermes式harness的自定义工具注册表插件。
Cross-cutting design rules (true for every integration type)
通用设计规则(适用于所有集成类型)
These invariants were extracted from every existing Apify integration. Apply them regardless of shape.
这些不变规则是从所有现有Apify集成中总结出来的,无论哪种集成形态都适用。
Vocabulary mirroring
术语对齐
Model the integration's resources on Apify's domain (Actor / Run / Dataset / KV Store / Task). Users coming from Apify Console should find the same concepts under the same names.
集成的资源模型应与Apify的领域模型保持一致(Actor / Run / Dataset / KV Store / Task)。从Apify Console过来的用户应该能看到同名的相同概念。
Asynchronous run flow with bounded polling
带轮询上限的异步运行流程
Actors can run for seconds to hours. Use the asynchronous flow, never the 300-second synchronous endpoint for anything but short jobs:
POST /v2/actors/{actorId}/runs -> start, return runId
GET /v2/actor-runs/{runId} -> poll until terminal status
GET /v2/datasets/{datasetId}/items -> fetch results on SUCCEEDEDPolling must be bounded: use the run's own plus a grace buffer, with an absolute ceiling fallback. Never . On a non-terminal status, surface the run ID so the user/agent can poll again or inspect the failure.
timeoutSecswhile (true)Actors的运行时间从几秒到几小时不等。请使用异步流程,除了短任务外,绝对不要使用300秒的同步端点:
POST /v2/actors/{actorId}/runs -> start, return runId
GET /v2/actor-runs/{runId} -> poll until terminal status
GET /v2/datasets/{datasetId}/items -> fetch results on SUCCEEDED轮询必须有上限:使用运行自身的加上宽限缓冲区,并设置一个绝对上限作为兜底。绝对不要使用。当处于非终止状态时,应展示运行ID,以便用户/Agent可以再次轮询或检查失败原因。
timeoutSecswhile (true)Cost is first-class
成本控制优先
Every path that starts a run must expose a cost control. The canonical control is (caps the run's total charge on most pricing models) and (caps billed items on pay-per-result Actors). Send them as options / query parameters, never as Actor input - inside input they are either an Actor-declared field or simply invalid. / empty / null means no limit. For LLM-facing integrations, the ceilings are developer-controlled; an LLM cannot widen them.
maxTotalChargeUsdmaxItems0每个启动运行的路径都必须提供成本控制功能。标准的控制参数是(在大多数定价模式下限制运行的总费用)和(在按结果付费的Actors中限制计费的结果数量)。请将它们作为选项/查询参数发送,绝对不要放在Actor输入中——放在输入里的话,它们要么是Actor自行声明的字段,要么直接无效。 / 空值 / null 表示无限制。对于面向LLM的集成,这些上限是由开发者控制的,LLM无法放宽这些限制。
maxTotalChargeUsdmaxItems0Attribution headers
归因头
Stamp an integration header on every outbound request so Apify can attribute traffic: . When a request is driven by an AI tool (not a human in a UI), also send . If the integration was built using this skill, add so Apify can distinguish skill-generated integrations from custom ones. One line, big telemetry payoff.
x-apify-integration-platform: <your-platform>x-apify-integration-ai-tool: truex-apify-integration-origin: apify-integration-development-skill在每个出站请求上添加集成标识头,以便Apify统计流量来源:。如果请求是由AI工具驱动的(而非UI中的人类用户),还需发送。如果集成是使用本技能构建的,请添加,以便Apify区分由技能生成的集成和自定义集成。只需一行代码,就能带来巨大的遥测价值。
x-apify-integration-platform: <your-platform>x-apify-integration-ai-tool: truex-apify-integration-origin: apify-integration-development-skillAuthentication
身份验证
- Browser / consumer-facing (a human completes a sign-in): OAuth2 with PKCE. Do not ask for raw tokens.
- Headless / server / CI (no human present): API token as , stored in an env var or secret manager, never hardcoded or logged.
Authorization: Bearer <APIFY_TOKEN>
Both paths are real - pick by who is present at auth time, not by which is easier.
- 浏览器/面向消费者的场景(由人类完成登录):使用带PKCE的OAuth2。不要索要原始Token。
- 无界面/服务端/CI场景(无人类参与):使用API Token,格式为,存储在环境变量或密钥管理工具中,绝对不要硬编码或记录到日志中。
Authorization: Bearer <APIFY_TOKEN>
两种方式都是正规方案——请根据身份验证时是否有人类参与来选择,而非哪种更简单就选哪种。
Centralized HTTP layer
集中式HTTP层
One base-URL constant, shared between credentials and the HTTP layer. Retries with exponential backoff on 429 and 5xx. Never retry non-idempotent on network errors - a duplicate Actor run is a real, billed, side-effecting operation. This is the single most important correctness invariant in the HTTP layer.
POST /runs设置一个基础URL常量,由凭证模块和HTTP层共享。对429和5xx状态码使用指数退避重试。绝对不要在网络错误时重试非幂等的请求——重复的Actor运行是真实的、会产生费用的、有副作用的操作。这是HTTP层中最重要的正确性不变规则。
POST /runsError taxonomy
错误分类体系
Map Apify errors to the host platform's error categories (retryable vs auth vs permanent). Surface the API's actual error text, not a generic HTTP message. For permission-approval failures (a full-permission Actor needs explicit approval), include the approval URL after validating it is an absolute URL. For LLM consumers, return errors as data (JSON error objects), never as raised exceptions - the model needs something to read and reason about.
http(s)将Apify错误映射到宿主平台的错误分类(可重试、身份验证错误、永久错误)。请展示API返回的实际错误文本,而非通用的HTTP消息。对于权限审批失败(需要全权限的Actor需要显式审批),请在验证审批URL为绝对 URL后将其包含在内。对于LLM消费者,请将错误作为数据返回(JSON错误对象),绝对不要抛出异常——模型需要能够读取和推理的内容。
http(s)Webhooks over polling for run-finished events
运行完成事件优先使用Webhooks而非轮询
When the host supports inbound webhooks, register an Apify webhook scoped to or with the terminal statuses the user picked. Make registration idempotent (a re-activated workflow should not create duplicate webhooks), persist the webhook ID so deactivation can clean it up, and always provide sample/fallback data so users can test the trigger without waiting for a real run.
actorIdactorTaskId当宿主平台支持入站Webhooks时,请注册一个作用域为或的Apify Webhook,并设置用户选择的终止状态触发条件。请确保注册操作是幂等的(重新激活工作流不应创建重复的Webhook),持久化存储Webhook ID以便停用时清理,并且始终提供示例/兜底数据,让用户无需等待真实运行就能测试触发器。
actorIdactorTaskIdGenerate from OpenAPI where the host allows it
宿主平台允许时优先从OpenAPI生成
If the host platform can generate UI fields from an OpenAPI spec, use Apify's spec () and a tag allowlist. Hand-write only what the spec cannot express: convenience wrappers, bill-cap fields, lean AI-tool output contracts.
https://apify.com/openapi.json如果宿主平台可以从OpenAPI规范生成UI字段,请使用Apify的规范()和标签白名单。仅手动编写规范无法表达的内容:便捷封装、费用上限字段、精简的AI工具输出契约。
https://apify.com/openapi.jsonHigh-level convenience operations alongside generic runs
除了通用运行外,提供高层便捷操作
Generic "run Actor" serves power users. Add a few opinionated, high-level actions for the common case (e.g. "Scrape single URL" wrapping a content scraper with , ) so non-power users get a 2-field form instead of a full Actor configuration. Validate the URL before starting a paid run.
maxCrawlDepth: 0maxResults: 1通用的「运行Actor」面向高级用户。请针对常见场景添加一些有主见的高层操作(例如「抓取单个URL」,封装了内容抓取器,设置、),这样非高级用户只需填写2个字段的表单,而非完整的Actor配置。请在启动付费运行之前验证URL。
maxCrawlDepth: 0maxResults: 1Testing and release
测试与发布
Keep two test modes: mocked (hermetic, no credentials) and live E2E (real API, CI-gated). Automate releases through the host platform's CI on Git tags / GitHub Releases. Never hand-edit versions or changelogs if a release workflow manages them.
保留两种测试模式:Mock模式(封闭环境,无需凭证)和实时E2E测试(真实API,由CI管控)。通过宿主平台的CI,在Git标签/GitHub Releases触发自动发布。如果发布工作流已经管理了版本和更新日志,就绝对不要手动编辑。
Top anti-patterns to refuse on review
审核时应拒绝的典型反模式
- Retrying on a network error - duplicates a billed run.
POST /runs - Unbounded polling - ties up the host with no ceiling.
while (true) - Putting /
maxTotalChargeUsdinside Actor input instead of options - silently not a cap.maxItems - Dumping a full dataset into an LLM context without size caps or untrusted-content fencing - prompt-injection and context blowout.
- One monolithic tool list for an LLM agent - routing accuracy degrades past ~8 tools; curate subsets.
- Surfacing a raw HTTP status/message instead of Apify's actual error text - users can't act on "400".
- 网络错误时重试——会产生重复的付费运行。
POST /runs - 无上限的轮询——会无限制占用宿主平台资源。
while (true) - 将/
maxTotalChargeUsd放在Actor输入而非选项中——会静默失效,无法起到限制作用。maxItems - 未经大小限制或不可信内容隔离,就将完整Dataset倒入LLM上下文——会导致提示注入和上下文溢出。
- 为LLM Agent提供单一的庞大工具列表——当工具数量超过约8个时,路由准确率会下降;请策划子集。
- 展示原始HTTP状态/消息,而非Apify的实际错误文本——用户无法根据「400」采取行动。
Minimal API surface every integration needs
所有集成都需要的最小API集
| Purpose | Method + path |
|---|---|
| Start an Actor run | |
| Start a Task run | |
| Poll a run | |
| List runs | |
| Dataset items | |
| KV record | |
| Set KV record | |
| Store search | |
| Webhook CRUD | |
| Validate token / current user | |
REST reference: . OpenAPI spec: .
https://docs.apify.com/api/v2https://apify.com/openapi.json| 用途 | 方法 + 路径 |
|---|---|
| 启动Actor运行 | |
| 启动Task运行 | |
| 轮询运行状态 | |
| 列出运行记录 | |
| 获取Dataset条目 | |
| 获取KV记录 | |
| 设置KV记录 | |
| 商店搜索 | |
| Webhook增删改查 | |
| 验证Token/当前用户 | |
REST参考文档:。OpenAPI规范:。
https://docs.apify.com/api/v2https://apify.com/openapi.jsonWorking workflow
工作流程
- Fetch and internalize the model.
https://apify.com/agents.md - Pick the integration shape above and read the matching reference file.
- Use Apify MCP (if available) to research the concrete Actors, schemas, and pricing the integration will expose.
- Draft the capability matrix for the chosen category (each reference has one) and the UX spec (resource -> operation -> fields -> errors).
- Scaffold the integration following the category-specific rules in the reference.
- Verify against the definition-of-done checklist at the end of that reference.
- 获取 并深入理解其模型。
https://apify.com/agents.md - 选择上述集成形态,并阅读对应的参考文件。
- 使用Apify MCP(如果可用)调研集成将要对外提供的具体Actors、Schemas和定价信息。
- 为所选分类起草能力矩阵(每份参考文件中都有)和UX规范(资源 -> 操作 -> 字段 -> 错误)。
- 按照参考文件中特定分类的规则搭建集成的脚手架。
- 对照参考文件末尾的完成定义检查清单进行验证。
Reference implementations to study
可供学习的参考实现
Real, public integrations per category - read their source when in doubt:
- Workflow automation: (npm), the Apify Zapier app.
@apify/n8n-nodes-apify - AI agent plugins (coding agents): the Apify plugin bundle (MCP server + skills + router + slash commands) shipped for Cursor, Claude Code, Copilot, and similar tools.
- AI agent plugins (harnesses): (PyPI),
apify-hermes-agent-plugin.@apify/apify-openclaw-plugin - AI framework packages: (PyPI).
langchain-apify - Application integration: see for the canonical
references/sdk-integration.mdusage in JS/TS, Python, and over REST.apify-client
Support for integration questions: . Contact us both for design guidance while you build and for review/testing once you publish - we validate the capability surface, cost controls, error handling, and attribution before the integration reaches users.
integrations@apify.com每个分类都有真实的公开集成——有疑问时请阅读它们的源码:
- 工作流自动化:(npm)、Apify Zapier应用。
@apify/n8n-nodes-apify - AI Agent插件(编码Agent):为Cursor、Claude Code、Copilot等类似工具发布的Apify插件包(MCP服务器 + skills + 路由器 + 斜杠命令)。
- AI Agent插件(harness类):(PyPI)、
apify-hermes-agent-plugin。@apify/apify-openclaw-plugin - AI框架包:(PyPI)。
langchain-apify - 应用集成:关于JS/TS、Python以及REST方式下的标准用法,请参见
apify-client。references/sdk-integration.md
集成问题支持:。你可以在构建期间联系我们获取设计指导,也可以在发布后联系我们进行审核/测试——我们会在集成面向用户前验证其能力覆盖范围、成本控制、错误处理和归因设置。
integrations@apify.com