设计与多媒体

API / Application Programming Interface

覆盖 147 个第三方 REST 与 GraphQL API 的参考与排错模式手册

它能做什么

REST 与 GraphQL 双协议参考,覆盖 147 个服务的鉴权方式、端点、限流策略和各家坑点,包含 Stripe、OpenAI、GitHub、Slack、Twilio 等。配套的模式手册专门处理常见的失败场景:401/403/429 错误、分页死循环、指数退避重试与幂等键、Webhook 签名校验、SSE 流式消费、文件上传、异步任务轮询、ETag 条件缓存,以及把外部数据增量同步到本地存储。示例默认用 curl 调用 sandbox 凭据,示例语言、重试上限、凭据命名等偏好都可按用户配置调整。

什么时候用它

  • 接入 Stripe、OpenAI、GitHub、Slack、Twilio 等第三方服务
  • 排查 401/403/429、超时、CORS、静默错误返回等问题
  • 实现退避重试、幂等键、Webhook 签名校验等可靠性模式
  • 通过轮询或 Webhook 把外部 API 数据同步到本地数据库

技能文档

REST and GraphQL API reference for 147 services: authentication, endpoints, rate limits, and per-service gotchas, plus pattern playbooks for everything that goes wrong between you and an API. User preferences live in ~/Clawic/data/api/ — the only location this skill writes (see setup.md on first use). If you have data at an old location (~/api/ or ~/clawic/api/), move it to ~/Clawic/data/api/.

When To Use

  • User names a service to integrate ("call the Stripe API", "post to a Slack channel") → its section via API Categories below
  • A request that "should work" returns 401/403/429, times out, or silently returns wrong data → debug.md and the pattern files
  • Designing the client side of any integration: retries, pagination, webhooks, streaming, file transfer, async job polling
  • Choosing between similar providers in a category (email, auth, media) → compare sections in the same category file
  • Not for building your OWN API (routing, schema design, versioning your endpoints) — this skill documents consuming others' APIs

Quick Reference

SituationRead
Endpoints/auth for a named serviceIts category file — API Categories table below
401/403 that "should work", OAuth flow choice, JWT rejectedauth.md
Works in curl but not in code, works locally but not in prod, TLS errors, mysterious 400sdebug.md
Duplicated/missing items across pages, loop never endspagination.md
Timeouts, retries, flaky upstream, circuit breakers, provider outageresilience.md
429s, rate-limit headers, quota budgeting, spending less of the limitrate-limits.md
Polling for changes, ETag/304 conditional requests, what to cache client-sidecaching.md
Mirroring API data locally, incremental sync, detecting deletions, sync token expiredsync.md
Blocked by CORS, calling an API from frontend code, key would ship to the browserbrowser.md
SSE stream buffers, hangs, or cuts off; events half-parsed; WebSocket dropsstreaming.md
Receiving events, signature verification, duplicate deliverieswebhooks.md
Upload rejected with 400/411/413, download corrupted or truncated, presigned URLsfiles.md
202 Accepted, job polling, batch partial failures, async exportsasync-jobs.md
The service speaks GraphQL (GitHub v4, Shopify, Linear)graphql.md
Version pinning, Sunset/Deprecation headers, provider changed the APIversioning.md
Sandbox vs live, mocking providers, recorded fixtures, contract drifttesting.md
Money amounts, timestamps, big numeric IDs, unicode limits in payloadsdata-formats.md
Multiple accounts/keys for one servicecredentials.md
Anything elseCore Rules below, then the Official Docs link at the end of each API section

API Categories

CategoryFileServices
AI/MLapis/ai-ml.mdanthropic, openai, cohere, groq, mistral, perplexity, huggingface, replicate, stability, elevenlabs, deepgram, assemblyai, together, anyscale
Paymentsapis/payments.mdstripe, paypal, square, plaid, chargebee, paddle, lemonsqueezy, recurly, wise, coinbase, binance, alpaca, polygon
Communicationapis/communication.mdtwilio, sendgrid, mailgun, postmark, resend, mailchimp, slack, discord, telegram, zoom
Realtimeapis/realtime.mdsendbird, stream-chat, pusher, ably, onesignal, courier, knock, novu
CRMapis/crm.mdsalesforce, hubspot, pipedrive, attio, close, apollo, outreach, gong
Marketingapis/marketing.mddrift, crisp, front, customer-io, braze, iterable, klaviyo
Developerapis/developer.mdgithub, gitlab, bitbucket, vercel, netlify, railway, render, fly, digitalocean, heroku, cloudflare, circleci, pagerduty, launchdarkly, split, statsig
Databaseapis/database.mdsupabase, firebase, planetscale, neon, upstash, mongodb, fauna, xata, convex, appwrite
Authapis/auth-providers.mdclerk, auth0, workos, stytch
Mediaapis/media.mdcloudinary, mux, bunny, imgix, uploadthing, uploadcare, transloadit, vimeo, youtube, spotify, unsplash, pexels, giphy, tenor
Socialapis/social.mdtwitter, linkedin, instagram, tiktok, pinterest, reddit, twitch
Productivityapis/productivity.mdnotion, airtable, google-sheets, google-drive, google-calendar, dropbox, linear, jira, asana, trello, monday, clickup, figma, calendly, cal, loom, typeform
Businessapis/business.mdshopify, docusign, hellosign, bitly, dub
Geoapis/geo.mdopenweather, mapbox, google-maps
Supportapis/support.mdintercom, zendesk, freshdesk, helpscout
Analyticsapis/analytics.mdmixpanel, amplitude, posthog, segment, sentry, datadog, algolia

How to Navigate API Files

Each category file starts with an index table (API name → line number). Read the index, then only the section you need (50-100 lines each):

head -20 apis/ai-ml.md          # index
sed -n '139,251p' apis/ai-ml.md # one API's section (OpenAI, per the index)

Core Rules

  1. Raw request before client code. Reproduce with curl first; if curl succeeds and the SDK fails, the bug is in SDK config (base URL, version pin, auth header name), not the API. Chains: debug.md.

  2. Backoff with full jitter, and Retry-After overrides it. sleep = random(0, min(cap, base × 2^attempt)), base 1s, cap 30-60s, max retry_max attempts (default 4; AWS "full jitter"). Attempt 3 → sleep is a random value in [0, 8s], not exactly 8s — the randomness is what prevents synchronized retry storms. If the 429/503 carries Retry-After, obey it instead.

  3. Retry only what cannot double-execute. GET/PUT/DELETE are idempotent; retry freely. POST only with an idempotency key — a 500 or timeout on POST may have committed server-side (the charge went through, the response didn't). Details and key lifetime: resilience.md.

  4. Status triage in this order: 401 → credential, 403 → permission, 404 → maybe permission too. 401 = the API doesn't know who you are (missing/expired/malformed token). 403 = it knows you and says no (scope, plan tier, IP allowlist). Some APIs (GitHub among them) return 404 for resources you lack access to, to avoid confirming existence — a "not found" on a resource you know exists is an auth bug, not a URL bug.

  5. HTTP 200 is not success. Check the body for error/errors fields (GraphQL always returns 200 — graphql.md), batch endpoints for per-item failures (207 Multi-Status or a 200 with a mixed results array — async-jobs.md), and streams for completion (streaming.md).

  6. Both timeouts, always. Set connect and read timeouts explicitly; a request without them hangs forever on a dead upstream. Values and rationale: resilience.md; for streams, read timeout means inter-chunk idle (streaming.md).

  7. Credentials in headers, never in URLs. Query-param keys land in access logs, proxy caches, and browser history. Env vars only; naming scheme for multi-account setups: credentials.md.

  8. Paginate to completion or say you didn't. Terminate on the API's own signal (has_more, next cursor absent) — never on item count alone. If you stop early, state that results are partial.

Status Triage

Beyond Core Rule 4's 401/403/404 chain:

CodeMeaningFirst move
400Request malformed or rejectedRead the body's error field, then debug.md Mysterious 400s
405Method not allowedWrong verb — or a redirect: clients follow 301/302 on POST by re-issuing GET (trailing-slash URLs are the classic trigger)
409State conflictRe-fetch current state; concurrent edit or duplicate create
410Gone permanentlyRetired resource or API version (versioning.md); expired sync token (sync.md Sync Tokens)
412Precondition failedYour If-Match ETag is stale — re-read, re-apply, retry
415Unsupported media typeContent-Type missing or wrong (top trap below)
422Validation failedWell-formed but semantically rejected — field-level errors are in the body
429Rate limitedrate-limits.md; obey Retry-After
500Server bugRetry only idempotent requests (resilience.md Retry Logic)
502/503/504Edge/LB failure or overload, often with an HTML bodyBackoff and retry; check the status page (resilience.md Provider Outages)

Output Gates

Before emitting integration code or a diagnosis, check:

  • Every POST/PUT/PATCH example includes Content-Type: application/json (or the API's required type)
  • No secret appears in a URL, code literal, or logged output — env var references only
  • Every pagination loop terminates on the API's has_more/cursor signal, not on len(items)
  • Retry logic distinguishes 4xx (don't retry, fix the request) from 429/5xx (backoff and retry)
  • Webhook handler verifies signature on the raw body before parsing (→ webhooks.md)
  • Money handled in the currency's own convention (minor units, exponent), IDs as strings (→ data-formats.md)
  • Examples reference the default_environment credential (sandbox unless the user asked for live)

Configuration

User-dependent variables. Defaults apply until the user states a preference; store them in ~/Clawic/data/api/config.yaml (loading and recording procedure: setup.md).

VariableTypeDefaultEffect
example_languagecurl | python | javascript | gocurlLanguage every request example is rendered in, across all category and pattern files
client_styleraw | sdkrawWhether examples use raw HTTP or the provider's official SDK (tradeoff: Where Experts Disagree)
default_environmentsandbox | livesandboxWhich credential examples reference (credentials.md naming); live only on explicit request — enforced by the last Output Gate
retry_maxnumber (0-10)4Retry ceiling used in Core Rule 2's formula and all generated retry code

Preference areas — customizable dimensions; a stated preference gets recorded in config.yaml and applied:

  • Tooling: HTTP client library (requests/httpx, axios/fetch, net/http) and testing tool (curl, HTTPie, Postman) — shapes every snippet
  • Integrations: the user's chosen provider per category (payments → Stripe, email → Postmark) — which service section answers a generic ask
  • Conventions: credential env-var naming (default scheme: credentials.md), error-handling style (exceptions vs result values) — shapes generated code
  • Thresholds: org-mandated timeouts and retry budgets — override the resilience.md defaults when stated
  • Safety posture: whether examples may include write/mutating calls, confirm-before-live behavior — tightens or relaxes the environment gate
  • Output format: snippet-only vs annotated walkthrough — answer verbosity

Traps

TrapWhy it failsDo instead
Missing Content-Type on POSTMany APIs parse the body as form-encoded or reject with an unhelpful 400/415Always send Content-Type: application/json with JSON bodies
Trusting the default page sizeDefaults are small; you silently process a fraction of the dataLoop until the API's completion signal (→ pagination.md)
Retrying 400 Bad RequestThe request itself is invalid; identical retries burn quota and can trigger abuse detectionFix the payload; retry only 429/5xx
Copy-pasted token fails with 401Trailing newline or wrapping quotes from the clipboard corrupt the headerecho -n, or trim before use
Testing against production keysLive-mode side effects (real charges, real emails) during developmentSandbox key first; gate and prefixes in testing.md and credentials.md
One giant try/catch around the whole call401, 429, and 500 need different responses; a generic catch retries the unretryableBranch on status class before any retry
Parsing each network chunk as one SSE eventTCP splits and merges events arbitrarily; JSON parse fails mid-tokenBuffer to the blank-line delimiter (→ streaming.md)
Numeric IDs parsed as numbers64-bit IDs overflow JS's 2^53−1 and round silentlyTreat every ID as an opaque string (→ data-formats.md)
Buffering a whole download in memoryMulti-GB export = OOM that dev-sized data never showedStream to disk; verify against Content-Length (→ files.md)
Calling a third-party API straight from the browserMost APIs send no CORS headers, and any key in the bundle is publicProxy through your backend; only provider-designated browser-safe keys ship client-side (→ browser.md)

Where Experts Disagree

  • Official SDK vs raw HTTP. SDKs win where auth is hard (request signing, OAuth refresh) and lose freshness — new endpoints land in the API before the SDK. Default: raw HTTP for simple bearer-token APIs; SDK when the provider signs requests or its docs treat the SDK as the primary interface. client_style records the user's side.
  • Webhooks vs polling. Webhooks for volume and latency; polling is legitimately simpler when events are rare, no public endpoint can be hosted, or the poll interval is acceptable staleness. The wrong answer is webhooks without the full handler order (webhooks.md).
  • Idempotency keys on every POST vs only where double-execution hurts. Every-POST buys uniform retry safety; minimalists note the bookkeeping cost. Boundary: any POST whose duplicate the user would notice (charge, email, order) gets a key — no exceptions there, optional elsewhere.

Security & Privacy

This skill is documentation: endpoint reference, auth patterns, and example requests for the external services listed above. Example endpoints belong to the respective providers (Stripe, OpenAI, etc.).

It does NOT:

  • Store or manage API keys or secrets — it references env-var names; values are never read, printed, or persisted
  • Make API calls on its own — the user runs the requests
  • Send data to any external service

Guardrails:

  • Credential discovery lists variable NAMES, never values (credentials.md Selection Rules)
  • Sandbox/test credentials by default; live keys only on explicit user request
  • Generated webhook handlers always verify signatures before parsing the payload

More Clawic skills, get them at https://clawic.com/skills/api (install if the user confirms):

  • http — HTTP request patterns
  • webhook — Webhook handling
  • json — JSON processing

Feedback


Part of Clawic, the verified skill library. Get this skill: https://clawic.com/skills/api.

相关技能

通过托管 OAuth 代理连接 Notion 工作区,支持搜索、数据库查询与读取,写入需用户确认。

339 次安装8 星标

通过托管 OAuth 接入 GitHub REST API,覆盖仓库、Issue、PR、Commit、分支与用户等接口。

595 次安装47 星标

通过托管 OAuth 代理调用 Apollo.io API,完成人员与公司搜索、联系人补全和销售数据管理。

226 次安装5 星标

通过 OAuth 认证网关管理 Stripe 客户、订阅、发票、产品、价格和支付。

720 次安装29 星标

通过托管的 OAuth GraphQL 接口查询与管理 Linear 的 issue、项目、团队、周期、标签和评论。

作者 byungkyu517 次安装18 星标

通过托管 OAuth 访问 HubSpot CRM API,管理联系人、公司、商机及对象关联。

187 次安装5 星标