算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
api-design【设计与创意】Design clean and consistent APIs. Use when the user says "design an API", "API design review", "design these endpoints", "REST API for X", "GraphQL schema", "API contract", "how should this endpoint work", "review my API design", or wants to create or improve an API interface - even if they don't explicitly say "API design".
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
name: api-design description: > Design clean and consistent APIs. Use when the user says "design an API", "API design review", "design these endpoints", "REST API for X", "GraphQL schema", "API contract", "how should this endpoint work", "review my API design", or wants to create or improve an API interface
Based on "A Philosophy of Software Design" by John Ousterhout. Ousterhout's key principle: modules should be deep - simple interface, powerful implementation. Applied to APIs: the surface area exposed to callers should be as small as possible, while the behavior provided should be as rich as possible. A leaky abstraction (where callers need to understand implementation details) is a design failure.
Before designing any endpoint, state what the API enables:
Ousterhout: if callers need to know how the API works internally to use it correctly, the API is leaky.
REST:
/users, /orders not /getUsers, /createOrder/users/{id}/orders (orders owned by a user)GraphQL:
For each endpoint:
Endpoint: [METHOD] /path/{param}
Purpose: [one sentence]
Auth: [required scope or token type]
Request:
Path params: [required identifiers]
Query params: [optional filters, pagination]
Body: [JSON schema with required/optional fields]
Response (200):
[JSON schema]
Errors:
400 - [validation failure - which fields, why]
401 - [unauthenticated]
403 - [unauthorized - caller lacks permission]
404 - [resource not found]
409 - [conflict - e.g. duplicate]
422 - [unprocessable entity - valid syntax, invalid semantics]
500 - [internal error]
Pick conventions and apply them everywhere:
2026-03-03T14:30:00Z){ error: { code, message, details } }Inconsistency is the top complaint from API consumers.
Ousterhout's information hiding principle: don't expose implementation artifacts.
Every public API needs a versioning strategy before it ships:
/v1/users (most common, most visible)API-Version: 2026-01-011. Verbs in resource paths
Bad: POST /createUser, GET /getUserById
Good: POST /users, GET /users/{id}
2. Inconsistent error shapes
Bad: Some endpoints return { error: "message" }, others return { message: "error" }.
Good: One error schema, applied everywhere.
3. Leaking implementation details
Bad: /api/db/users_table/row/42
Good: /api/users/42
4. No versioning plan on day 1 Bad: Ship v1 with no versioning, then break callers when you need to change the contract. Good: Version from the first public release. Breaking changes require a new version.