Community程式設計與開發github.com

Apify 整合開發

為公司產品設計並建立官方的 Apify 整合,涵蓋工作流程自動化應用程式、AI 代理外掛、AI 框架套件及直接應用客戶端。

Apify 整合開發 是什麼?

此技能詳細說明如何為合作夥伴產品打造端到端的官方 Apify 整合,無需依賴 Apify 團隊的過多協助。它適用於所有 Apify 支援的整合形式,包括工作流程自動化平台(如 Zapier、n8n)、AI 代理外掛(針對 Cursor、Claude Code 等編碼代理的輕量級技能+MCP 套件,以及 OpenClaw/Hermes 風格的客製化工具註冊外掛)、AI 框架套件(如 LangChain、LlamaIndex),以及直接使用 apify-client 或 REST API 的應用整合。關鍵原則包括:同步非同步執行輪詢時必須設置上限、將成本控制(maxTotalChargeUsd、maxItems)作為第一級功能、為所有對外請求添加歸因標頭、以及提供高階便利操作(如「Web Fetch」)以簡化常見用例。此技能幫助開發者導航 Apify 的模型(Actor、Run、Dataset、KV Store),避免常見的反模式,例如對非冪等 POST /runs 進行重試,或使用無限制的 while(true) 輪詢循環。

相容平台✓Claude Code✓Codex CLI✓Cursor
npx skills add https://github.com/nehakanjamala/personal_website/tree/HEAD/.agents/skills/apify-integration-development

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Apify 整合開發 是做什麼的?

為公司的產品設計並建立一個官方的 Apify 整合,在 Apify 團隊的協助最少的情況下完成。本技能涵蓋 Apify 支援的所有整合形式——工作流程自動化應用程式、AI 代理外掛(編碼代理與框架)、AI 框架套件以及直接應用客戶端——讓合作夥伴團隊能夠從頭到尾交付一流的 Apify 整合。下列跨領域規則適用於所有整合,而每個類別專屬的參考檔案則負責其餘部分。

正在建立官方整合? 一旦發布,請聯繫 [email protected],以便 Apify 團隊在整合上線前進行審查、測試與驗證。我們會檢查功能面、成本控制、錯誤處理及歸因標頭,並協助你填補任何缺口。

步驟 0 - 先了解 Apify 模型(必要)

在設計任何內容之前,請先擷取並閱讀 https://apify.com/agents.md。這是 AI 代理的標準快速入門指南,也是詞彙、執行流程和成本規則的唯一權威來源。如果擷取失敗,底下的迷你詞彙表仍可讓技能正常運作。

Apify 詞彙(在平台上總是使用大寫 A 書寫):

  • Actor - 一個無伺服器雲端程式,接收 JSON 輸入、執行任務並產生結構化輸出。不是 AI 代理。
  • Actor Run - 一次 Actor 的執行。每次執行都有自己的 Dataset、Key-Value Store 和 Request Queue,並以終端狀態結束(SUCCEEDED、FAILED、TIMED-OUT、ABORTED)。
  • Dataset - 僅可附加的結構化儲存空間,用於存放執行結果。Actor 呼叫會傳回 Dataset ID,而非其內容。
  • Key-Value Store - 非結構化/檔案儲存(螢幕截圖、HTML、OUTPUT)。
  • Actor Task - 用於執行 Actor 的已儲存、參數化的配置。
  • Apify Store - 位於 https://apify.com/store.md 的 Actor 市集。
  • Apify Console - 位於 https://console.apify.com 的網頁 UI。
  • Compute Unit (CU) - 計費單位:記憶體(MB)x 時間(小時)。
  • Server Actor - 一個作為隨時可用的 HTTP 伺服器,在其穩定的 URL 上運行的 Actor(在 API 和文件中可能仍稱為 Standby)。你發送請求並在回應中收到結果——無需啟動執行,也無需讀取 Dataset。

更多術語(build、request queue、proxy、定價模型):https://docs.apify.com/llms.txt。

在規劃時使用 Apify MCP 取得即時上下文

Apify MCP 伺服器是在整合設計期間研究 Actor、Schema、定價和文件的最快方式。請參閱 https://docs.apify.com/integrations/mcp(附加 .md 以取得 Markdown 版本)。

如果此環境中已提供 Apify MCP 工具,請使用它們:

  • search-actors - 依平台/產品關鍵字尋找 Actor(按產品名稱搜尋,而非最終目標)。
  • fetch-actor-details - 在將 Actor 的形狀編碼到整合中之前,讀取其輸入 schema、輸出格式、README 和定價。
  • search-apify-docs / fetch-apify-docs - 提取相關的文件頁面。

匿名探索子集(search-actors、fetch-actor-details、search-apify-docs、fetch-apify-docs)無需帳號即可運作,因此即使在開發者尚未連接其 token 之前,你也可以進行研究。

選擇你的整合形式

根據你要整合的產品,僅讀取一個參考檔案。每個參考檔案都包含該類別專屬的 UX 設計、標準功能矩陣以及完成定義檢查清單。

產品形式範例參考檔案
工作流程自動化平台Zapier、n8n、Make、Pipedream、Activepiecesreferences/workflow-automation.md
AI 代理外掛(編碼代理或框架)Cursor、Claude Code、Codex、GitHub Copilot(編碼代理);OpenClaw 風格執行環境、Hermes 風格框架(框架)references/ai-harness-plugin.md
AI 框架套件(LLM 框架的 PyPI/npm)LangChain、LlamaIndex、Haystack、Vercel AI SDKreferences/ai-framework-package.md
應用整合(直接客戶端)後端服務、排程工作、透過 apify-client 或 REST 呼叫 Actor 的產品功能references/sdk-integration.md

路徑相對於此技能資料夾。如果你的產品跨越兩種形式(例如,建立在框架套件之上的 AI 框架),請同時閱讀兩者——規則可以組合。AI 代理外掛參考涵蓋了兩種具有不同權衡的方法:適用於技能/MCP 感知編碼代理的輕量級技能 + MCP 套件,以及適用於 OpenClaw/Hermes 風格框架的客製化工具註冊外掛。

跨領域設計規則(適用於所有整合類型)

這些不變項是從所有現有的 Apify 整合中提取出來的。無論形式為何,都應套用它們。

詞彙對映

將整合的資源對應到 Apify 的領域(Actor / Run / Dataset / KV Store / Task)。來自 Apify Console 的使用者應能在相同的名稱下找到相同的概念。

非同步執行流程與有界輪詢

Actor 的執行時間可能從幾秒到幾小時不等。對於除了短期工作以外的所有情況,請使用非同步流程,切勿使用 300 秒的同步端點:

POST /v2/actors/{actorId}/runs            -> 啟動,傳回 runId
GET  /v2/actor-runs/{runId}               -> 輪詢直到終端狀態
GET  /v2/datasets/{datasetId}/items       -> 在 SUCCEEDED 時擷取結果

輪詢必須是有界的:使用 run 本身的 timeoutSecs 加上一個寬限緩衝,並以絕對上限作為備用。絕對不要使用 while (true)。在非終端狀態時,顯示 run ID,以便使用者/代理可以再次輪詢或檢查失敗。

成本是第一級功能

每個啟動 run 的路徑都必須公開成本控制。標準控制項是 maxTotalChargeUsd(在大多數定價模型上限制 run 的總費用)和 maxItems(限制按結果計費 Actor 的計費項目)。將它們作為選項 / 查詢參數傳送,絕不能作為 Actor 的輸入——在輸入中,它們要不是 Actor 宣告的欄位,就是完全無效。0 / 空值 / null 表示無限制。對於面向 LLM 的整合,上限是由開發者控制的;LLM 不能放寬它們。像 Web Fetch(如下)這樣的 Server Actor 請求不會啟動 run,也不接受這兩個選項。

歸因標頭

在每個對外請求上蓋上整合標頭,以便 Apify 歸因流量:x-apify-integration-platform: <你的平台>。當請求是由 AI 工具(而非 UI 中的人類)驅動時,也要傳送 x-apify-integration-ai-tool: true。如果此整合是使用此技能建立的,請加上 x-apify-integration-origin: apify-integration-development-skill,以便 Apify 能夠區分技能產生的整合和客製化整合。一行程式碼,巨大的遙測回報。

驗證

  • 瀏覽器 / 面向消費者(人類完成登入):使用 PKCE 的 OAuth2。請勿要求原始 token。
  • 無頭 / 伺服器 / CI(沒有人類在場):API token,格式為 Authorization: Bearer <APIFY_TOKEN>,儲存在環境變數或機密管理器中,絕不能寫死在程式碼中或記錄下來。

這兩種路徑都是真實的——根據驗證時誰在場來選擇,而不是根據哪個比較簡單。

集中式 HTTP 層

一個基礎 URL 常數,在憑證和 HTTP 層之間共享。Server Actor 位於自己的主機上(https://web-fetch.apify.actor)——透過同一層路由它,以便驗證和歸因標頭仍然適用。在遇到 429 和 5xx 錯誤時使用指數退避進行重試。絕不能因網路錯誤而重試非冪等的 POST /runs——重複的 Actor run 是真實存在、會計費且會產生副作用的操作。這是 HTTP 層中最重要的正確性不變項。

錯誤分類

將 Apify 錯誤對應到主機平台的錯誤類別(可重試 vs 驗證 vs 永久性)。顯示 API 的實際錯誤文字,而不是泛泛的 HTTP 訊息。對於權限核准失敗(需要明確核准的全權限 Actor),在驗證其為絕對 http(s) URL 後,包含核准 URL。對於 LLM 消費者,將錯誤作為資料(JSON 錯誤物件)傳回,絕不能作為引發的例外——模型需要有東西可以讀取和推理。

用 Webhook 取代輪詢來處理 run 完成事件

當主機支援入站 Webhook 時,註冊一個範圍限定在 actorId 或 actorTaskId 的 Apify Webhook,並使用使用者選擇的終端狀態。讓註冊具有冪等性(重新啟動的工作流程不應建立重複的 Webhook),持久化 Webhook ID,以便停用時可以清理它,並始終提供範例/備用資料,以便使用者無需等待真實的 run 即可測試觸發器。

在主機允許的情況下從 OpenAPI 產生

如果主機平台可以從 OpenAPI 規範產生 UI 欄位,請使用 Apify 的規範(https://apify.com/openapi.json)和標籤允許清單。僅手動編寫規範無法表達的內容:便利包裝器、帳單上限欄位、精簡的 AI 工具輸出協定。

高階便利操作與通用 run 並存

通用的「run Actor」服務於進階使用者。為常見情況新增一些有觀點的高階操作,讓非進階使用者看到的是兩個欄位的表單,而不是完整的 Actor 配置。標準的範例是 Web Fetch:輸入一個 URL,輸出頁面內容,建立在 apify/web-fetch Server Actor 之上——POST https://web-fetch.apify.actor/ 搭配 {"url": "...", "formats": ["markdown"]} 會在回應中傳回內容。由於不會啟動任何 run,因此上述的 run 規則(非同步流程、輪詢、maxTotalChargeUsd)不適用;成本是每個成功請求一個 fetch 事件。需要正確處理三件事:始終傳送 formats、檢查 fetch.httpStatusCode(HTTP 200 僅表示 Web Fetch 本身成功),以及處理兩種錯誤形式——來自 Actor 的扁平 {code, error} 和來自平台的巢狀 {error: {message}}——無需自動重試其 502/504 錯誤。完整合約:https://apify.com/apify/web-fetch.md。請勿使用 maxCrawlDepth: 0 的爬蟲 run 來建立這個功能——那是舊的「Scrape single URL」模式。

測試和發布

保留兩種測試模式:模擬測試(封閉、無需憑證)和即時端到端測試(真實 API、由 CI 控管)。透過主機平台在 Git tags / GitHub Releases 上的 CI 自動化發布。如果發布工作流程管理版本和變更日誌,則絕不要手動編輯。

審查時應拒絕的頂級反模式

  1. 因網路錯誤重試 POST /runs——會重複產生已計費的 run。
  2. 無限制的 while (true) 輪詢——會消耗主機資源且沒有上限。
  3. 將 maxTotalChargeUsd / maxItems 放在 Actor 輸入中而非選項中——這樣做並不會形成有效的上限。
  4. 將整個 Dataset 傾倒到 LLM 上下文中,而未設定大小上限或不受信任內容的防護——會導致提示注入和上下文爆炸。
  5. 為 LLM 代理提供一個單一、龐大的工具列表——路由準確度會在超過約 8 個工具時下降;請策劃子集。
  6. 顯示原始的 HTTP 狀態/訊息而非 Apify 實際的錯誤文字——使用者無法根據「400」採取行動。

每個整合都需要的最小 API 面

用途方法 + 路徑
啟動 Actor runPOST /v2/actors/{actorId}/runs
啟動 Task runPOST /v2/actor-tasks/{taskId}/runs
輪詢 runGET /v2/actor-runs/{runId}
列出 runGET /v2/actor-runs
Dataset 項目GET /v2/datasets/{datasetId}/items
KV 記錄GET /v2/key-value-stores/{storeId}/records/{key}
設定 KV 記錄PUT /v2/key-value-stores/{storeId}/records/{key}
商店搜尋GET /v2/store
Webhook CRUDPOST/GET/DELETE /v2/webhooks
驗證 token / 目前使用者GET /v2/users/me
擷取一個 URL(Web Fetch,Server Actor)POST https://web-fetch.apify.actor/

REST 參考:https://docs.apify.com/api/v2。OpenAPI 規範:https://apify.com/openapi.json。

工作流程

  1. 擷取 https://apify.com/agents.md 並內化該模型。
  2. 選擇上述的整合形式並閱讀相符的參考檔案。
  3. 使用 Apify MCP(如果可用)研究整合將要公開的具體 Actor、Schema 和定價。
  4. 為選擇的類別草擬功能矩陣(每個參考都有一個)以及 UX 規範(資源 -> 操作 -> 欄位 -> 錯誤)。
  5. 依照參考檔案中的類別專屬規則建立整合的支架。
  6. 根據該參考檔案末尾的完成定義檢查清單進行驗證。

可供研究的參考實作

每個類別的公開實作——有疑問時請閱讀其原始碼:

  • 工作流程自動化:@apify/n8n-nodes-apify(npm),Apify Zapier 應用程式。
  • AI 代理外掛(編碼代理):為 Cursor、Claude Code、Copilot 及類似工具發布的 Apify 外掛套件(MCP 伺服器 + 技能 + 路由器 + 斜線指令)。
  • AI 代理外掛(框架):apify-hermes-agent-plugin(PyPI),@apify/apify-openclaw-plugin。
  • AI 框架套件:langchain-apify(PyPI)。
  • 應用整合:請參閱 references/sdk-integration.md 以了解在 JS/TS、Python 和 REST 上使用 apify-client 的標準用法。

整合問題支援:[email protected]。無論是在實作時需要設計指導,還是在發布後需要審查/測試,都請聯繫我們——我們會在上線前驗證功能面、成本控制、錯誤處理和歸因。

Individual skills in this repo

This repo contains 13 individual skills — each has its own dedicated page.

nehakanjamala/personal_website

This skill should be used when the user asks to "fix janky CSS animation", "make animation 60fps", "stop layout thrashing", "animate width/height/top/left smoothly", "convert animation to transform", "animate box-shadow performantly", "animate height auto", "FLIP animation", or "why is my scroll/hover animation choppy".

nehakanjamala/personal_website

This skill should be used when the user asks to "respect prefers-reduced-motion", "honor reduced motion", "make my animations accessible", "fix vestibular / motion-sickness issues", "add a useReducedMotion hook", "gate GSAP / Framer Motion / Lenis for reduced motion", or "meet WCAG 2.3.3 / C39". Provides tiered (not all-or-nothing) reduced-motion patterns in CSS and JS.

nehakanjamala/personal_website

Create, modify, debug, and deploy Apify Actors, and write their input and output schemas. Use when building an Actor from scratch, changing or troubleshooting Actor code, generating or updating .actor schema files, or pushing an Actor to the Apify platform. To wrap an existing non-Actor project, use apify-actorization instead.

nehakanjamala/personal_website

Convert existing projects into Apify Actors - serverless cloud programs. Actorize JavaScript/TypeScript (SDK with Actor.init/exit), Python (async context manager), or any language (CLI wrapper). Use when migrating code to Apify, wrapping CLI tools as Actors, or adding Actor SDK to existing projects.

nehakanjamala/personal_website

Deprecated. Output schema generation moved to the apify-actor-development skill; prefer that skill whenever it is available.

nehakanjamala/personal_website

Universal AI-powered web scraper for any platform. Scrape data from Instagram, Facebook, TikTok, YouTube, LinkedIn, X/Twitter, Google Maps, Google Search, Google Trends, Reddit, Airbnb, Yelp, and 15+ more platforms. Use for lead generation, brand monitoring, competitor analysis, influencer discovery, trend research, content analytics, audience analysis, review analysis, SEO intelligence, recruitment, or any data extraction task.

nehakanjamala/personal_website

This skill should be used when the user asks to "add a glassmorphism effect", "frosted glass UI", "Apple liquid glass style", "frosted blur card", "translucent glass panel animation", "make a frosted nav bar", "build a glass modal/dialog", "animate a glass card on hover", or "add a refracting liquid-glass hero". Covers frosted translucent panels with backdrop-filter blur, edge/specular highlights, SVG liquid-glass refraction, motion on hover/scroll/enter, and accessible reduced-transparency fallbacks.

nehakanjamala/personal_website

This skill should be used when the user asks to "build a scroll animation", "add ScrollTrigger", "pin a section while scrolling", "scrub an animation to scroll", "create a hero timeline", "do a horizontal scroll section", "split text and animate words", "animate a layout change with GSAP Flip", "sync ScrollTrigger with Lenis", "Lenis smooth scroll jittery", "ScrollTrigger markers drift", "ScrollTrigger pins break with Lenis/Locomotive", or "set up smooth scroll with GSAP pinning". Covers GSAP timelines, ScrollTrigger, SplitText, Flip, and Lenis/Locomotive smooth-scroll sync for code-driven web motion.

nehakanjamala/personal_website

This skill should be used when the user asks to "add a Lottie animation", "play a .lottie or .json animation", "integrate a Bodymovin/After Effects animation on web or mobile", "control Lottie playback / segments", "make a scroll-driven Lottie", "recolor a Lottie at runtime", or "export an AE animation to Lottie". Covers dotLottie/lottie-web integration, playback control, interactivity, theming, and the AE export checklist.

nehakanjamala/personal_website

This skill should be used when the user asks to "add a hover/press effect", "animate a toggle or switch", "build an animated like button", "make a toast/snackbar slide in", "animate a drawer or modal", "animate list reordering or add/remove", "do a shared-element layout transition", or "polish UI feedback". Covers UI motion with Framer Motion (motion/react) and modern CSS.

nehakanjamala/personal_website

This skill should be used when the user asks to "animate page or route transitions", "add a page transition or crossfade between views", "animate route changes in Next.js App Router", "use the View Transitions API", "AnimatePresence exit doesn't fire on navigation", or "Framer Motion exit animation not working / exit animation before unmount in Next.js". Covers enter/exit page-transition animation with the View Transitions API and Framer Motion, for Next.js App Router and general SPA routing.

nehakanjamala/personal_website

Scrape web pages using Scrapling with anti-bot bypass (like Cloudflare Turnstile), stealth headless browsing, spiders framework, adaptive scraping, and JavaScript rendering. Use when asked to scrape, crawl, or extract data from websites; web_fetch fails; the site has anti-bot protections; write Python code to scrape/crawl; or write spiders.

nehakanjamala/personal_website

This skill should be used when the user asks to "animate an SVG", "make a line draw itself on", "do a stroke draw-on / signature animation", "morph one shape into another", "move an element along a path", "animate an icon/logo", or "animate an SVG gradient or filter". Covers stroke-dashoffset draw-on, path morphing, motion-along-path, and animated icons/gradients/filters via CSS, SMIL, and GSAP.

相關技能