算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
stripe-inspired-api-design-rules【设计与创意】JSON HTTP API design rules distilled from Stripe — resource modeling, identifier schemes, URL structure, request/response wire format, pagination, errors, idempotency, versioning, naming, webhooks, and authentication. Triggers on tasks involving OpenAPI specs, API design reviews, schema decisions, endpoint shaping, error envelope design, webhook deli…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
A reference distillation of the design conventions behind Stripe's API — the most widely admired and copied JSON HTTP API in the industry. Contains 52 actionable rules across 8 categories, prioritised by how irreversibly a wrong decision cascades through every endpoint, every SDK, and every client integration. Each rule explains the WHY, shows incorrect-vs-correct code, and links to the canonical source.
Reach for this skill when:
Critical / Warning / Suggestion / Positive)The rules are general — they apply to any JSON HTTP API, not just APIs imitating Stripe. Triggers include "API design", "OpenAPI", "endpoint", "schema", "webhook", "idempotency", "pagination", "API versioning", and reviews of YAML/JSON spec files.
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Resource Modeling & Identifiers | CRITICAL | resource- |
| 2 | URL Structure & HTTP Semantics | CRITICAL | url- |
| 3 | Request & Response Format | HIGH | format- |
| 4 | Errors & Status Codes | HIGH | error- |
| 5 | Idempotency & Safe Retries | HIGH | idem- |
| 6 | Versioning & Backwards Compatibility | HIGH | ver- |
| 7 | Naming, Polymorphism & Metadata | MEDIUM-HIGH | naming- |
| 8 | Authentication, Webhooks & Search | MEDIUM-HIGH | ops- |
Earlier categories cascade harder: a wrong choice in resource modeling (numeric IDs, no object discriminator) propagates to every endpoint forever; a wrong choice in webhook event naming is a single category to fix.
resource-prefixed-string-ids — Use Prefixed String IDs for Every Resourceresource-object-discriminator — Include a Read-Only object Discriminator on Every Resourceresource-opaque-ids — Treat IDs as Opaque Strings up to 255 Charactersresource-unix-seconds-timestamps — Use Unix Seconds (Integer) for All Datetimesresource-iso-date-only — Use ISO 8601 Date Strings for Date-Only Valuesresource-birthdate-hash — Represent Birth Dates as {day, month, year} Hashesresource-integer-minor-units — Use Integer Minor Units for Money, Never Floatsresource-currency-field-not-name — Colocate a currency Field; Never Bake Currency into Field Namesresource-decimal-suffix-strings — Use _decimal String Suffix for Precise Decimals That Can't Be Integersurl-plural-collections — Pluralize Collection URLs; Singularize Object Typesurl-post-for-updates — Use POST for Updates (Not PUT or PATCH)url-action-verbs-as-subpaths — Express Non-CRUD Actions as Imperative Sub-Pathsurl-no-bulk-endpoints — One Object Per Request — No Bulk Endpointsurl-version-in-path-and-header — Version in URL Path and Stripe-Version Headerurl-dedicated-search-endpoint — Use a Dedicated /search Endpoint for Complex Queriesformat-form-encoded-requests — Accept Form-Encoded Requests, Always Return JSONformat-bracket-notation-nesting — Use Bracket Notation for Nested Fields in Form Bodiesformat-list-envelope — Return Lists in a {object, url, has_more, data} Envelopeformat-cursor-pagination — Paginate by Cursor (starting_after/ending_before), Not by Offsetformat-no-total-counts — Use has_more Boolean; Never Return Total Countsformat-expand-parameter — Expand Related Objects with expand[] in One Round Tripformat-dot-notation-expansion — Allow Dot-Notation for Nested Expansion (Max Depth 4)error-top-level-object — Always Wrap Failures in a Top-Level error Objecterror-four-type-enum — Use a Small Fixed type Enum, Don't Proliferate Typeserror-message-mandatory-code-optional — Require message; Make code Optional and Only for Programmatic Handlingerror-lowercase-snake-case-codes — Use Lowercase snake_case for Error Codes, Not SCREAMING_SNAKE_CASEerror-http-status-mapping — Map Error Types to HTTP Status Codes Consistentlyerror-doc-url-on-every-error — Include doc_url Links and Request IDs on Every Erroridem-key-header — Accept Idempotency-Key Header on All Mutating Requestsidem-scoped-per-account — Scope Idempotency Keys per Account, Not Globallyidem-24h-ttl — Keep Idempotency Keys for 24 Hours, Reap at 72idem-fail-on-key-reuse — Return 409 When a Key Is Reused with Different Paramsidem-recovery-points — Use Recovery Points for Multi-Step Idempotent Operationsver-dated-versions — Use Dated Versions (YYYY-MM-DD), Not v1/v2/v3ver-account-pinning — Pin Each Account to Its First-Request Versionver-additive-changes — Define What Counts as a Backwards-Compatible Changever-version-change-modules — Encapsulate Each Breaking Change in a Version-Change Modulever-tolerate-unknown — Document That Clients Must Tolerate Unknown Fields, Events, and Enum Valuesnaming-snake-case-wire-format — Use snake_case for All Wire Identifiersnaming-american-english — Use American English Spelling (canceled, Not cancelled)naming-simple-unambiguous — Names — Simple, Unambiguous, No Leading Digits, No Jargonnaming-type-discriminator-polymorphism — Discriminate Polymorphic Types with a type Field and Sibling Objectsnaming-metadata-pattern — Provide a metadata Pass-Through with Strict Limitsnaming-boolean-past-tense — Booleans — Past-Tense Verbs and Plain Adjectives, Not is_/has_ Prefixesnaming-enums-over-booleans — Prefer Enums over Booleans for New Status/Flag Fieldsops-prefixed-api-keys — Prefix API Keys with Scope and Mode (sk_live_, pk_test_, rk_)ops-https-only-basic-auth — Enforce HTTPS Only and Use HTTP Basic Auth with the Key as Usernameops-on-behalf-of-header — Use a Dedicated On-Behalf-Of Header for Multi-Tenant Callsops-webhook-event-envelope — Webhook Events Use a Fixed {id, object, type, data, created} Envelopeops-webhook-event-naming — Event Type Naming — <resource>.<past_tense_action>ops-webhook-signature — Sign Webhook Deliveries with HMAC and a Timestamp Tolerance Windowops-webhook-at-least-once-handlers-idempotent — Document At-Least-Once Delivery; Handlers Must Dedupe on event.idFor a focused question ("should this field be a boolean or an enum?"), jump directly to the relevant rule (naming-enums-over-booleans) — each rule is self-contained with the WHY, code examples, and the canonical source.
For a full API review or audit, work through the categories top-to-bottom. The order matches Stripe's own design priority: get resource modeling and URL structure right first; format, errors, idempotency, and versioning are the next layer; naming and operational surface come last because they're the easiest to evolve.
For producing a structured findings report (the kind an inspector tool emits), cite rules by their slug — resource-unix-seconds-timestamps, format-no-total-counts — so each finding traces back to a specific, defensible source.
Read section definitions for the cascade-impact rationale behind the category ordering, or the rule template when adding a new rule.
| File | Description |
|---|---|
| references/_sections.md | Category definitions and ordering by design-propagation impact |
| assets/templates/_template.md | Template for authoring new rules |
| metadata.json | Version and reference URLs |
| gotchas.md | Failure points discovered when applying the rules |