endueendue

API Design

Use when someone wants to create or change an API. Gives the endpoints, errors and key decisions, shows what happens when a request is repeated, and checks each change against current callers.

v3.0.0

Ce que fait cette compétence

Les instructions complètes que suit votre agent. Rien ici n’est caché derrière une connexion.

API design

Design an API around its callers, and show what happens when a request is sent twice.

When to use

Use it to create or change an API. Use documentation to explain an existing one, product-spec-writing to decide what the product does, and database-query for tables or SQL. For one question about a method or status, answer in chat. If asked for a spec file such as OpenAPI, save only that, with decisions and open questions in chat.

How to work

  1. Give each caller's job one operation, and drop the rest. Use REST unless asked otherwise. Keep the user's naming, version and error format.
  2. For each write that could be repeated, set who makes its key, the key's scope, how key and result are saved together, and the reply to a repeat, to the same key with different content, and to a repeat during the first request. Retries reuse the first key, so an ID that changes on each send can't be the key. Keep keys longer than all the tries: (1 + retries) × wait.
  3. Page every list that can grow: default and maximum size, sort order with a tie-breaker, cursor and last-page sign.
  4. Give each change to an existing API the first label that fits. Breaks: a current caller fails. Changes meaning: a caller works but misreads a value. Adds: something new. Ask if callers accept it. Replace the first two with a new field or operation. Keep the old one until every caller has a confirmed move date.
  5. Pick the 1–3 decisions hardest to change later. Compare 2–3 real options for each.

The result

Always use these sections, in this order, with "None" in an empty one.

  1. Cover: the design and its main decision. The big number is requests sent → results saved (4 → 1), if any can be repeated. Key facts: "Design only, not tested", and how many operations and known breaking changes there are.
  2. Request, retry and saved result: the main visual. e-lanes with rows for client, API and stored data. Show the write whose repeat does most harm, in 6 steps with real values and status codes: send with a key; claim it; save; no reply, so resend with the same key (say how often); return the first reply; still one result (class="hi"). If none can be repeated, show the most used call and its likeliest error.
  3. Operations: a table: job and caller; method and path, with access and input in an <em>; success, with error IDs in an <em>. Then that call's request and response in e-code: lines under 40 characters, tokens as ….
  4. Retry rules: a list of step 2's choices and the calculation.
  5. Decisions: a table: decision; choice and why; other options, with the cost and what would change the choice in an <em>.
  6. Errors: a table: ID (E1…), status and code; when; whether to retry and what to do.
  7. Current callers: a table: change, label, what to do.
  8. Rules and open questions: a list of rules (R1…) marked Supplied or Assumed, then questions with who answers and what each affects.

Build the page

Save one .html file (under 7,000 characters) with save_output. Copy the markup below with every part (leads and sources too), changing only text and numbers. Plain <p>, <br>, <ul> and <ol> are fine, but nothing else: no CSS, scripts, images, fonts or outside links. Keep <style> as is: endue adds its design there. Set lang and write every heading, label, status and verdict, even those named above, in that language only. In text and code, write &lt; for < and &amp; for &.

If the task sets another format, use it with the same sections in the same order. If you can't save files, give them in chat. After saving, reply with only the conclusion and what needs attention.

<!doctype html><html lang="ko"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Title</title><style>/*endue-kit*/</style></head><body><main class="e">
<header class="e-cover"><p>topic · date</p><h1>Conclusion, up to 60 characters (30 in Korean or Japanese)</h1><p>The main reason</p><ul><li>key fact</li></ul><div class="e-big"><b>12%</b><span>what it measures</span></div></header>
<section><h2>Heading</h2><p class="e-lead">The point in one sentence</p><!-- blocks --></section>
<footer class="e-src"><b>Sources</b><ol><li>source, date</li></ol></footer>
</main></body></html>
  • The big number proves the conclusion in up to 12 characters. Without one, leave out e-big.
  • Variables take plain numbers (1240 or 0.5, not 1,240). --max is the block's largest value. Show every value as text too. Counts in sentences must match the blocks.
  • Put hi only on what proves the block's point. Use good, warn and bad only when clear, with a word beside them. Say what each change is compared with.

Blocks to use here:

  • Steps by role: <div class="e-lanes" style="--n:3"><div><b>Customer</b><p style="--s:1"><b>1.</b> asks</p></div><div><b>Support</b><p class="ask" style="--s:2"><b>2.</b> in 7 days?</p></div></div>. One row per role. --n is the number of steps (up to 6) and --s is the step's column. ask is a decision.
  • Table, up to 5 columns: <div class="e-table"><table><thead><tr><th>Task</th><th class="n">Cost</th></tr></thead><tbody><tr class="hi"><td>text</td><td class="n">1,200</td></tr><tr class="total"><td>Total</td><td class="n">1,200</td></tr></tbody></table></div>. n is for numbers. <em> in a cell adds a small line below.
  • Code: <pre class="e-code"><code>18 kept</code><code><del>19 removed</del></code><code><ins><i>1</i>19 added</ins></code></pre>. Each line gets its own <code>. Use <del>, <ins>, or <mark> for a line to look at. <i>1</i> at the start of a line is a marker in the margin, not its line number.

Before you finish

  • Each error ID used is in the error table once.
  • IDs, times and amounts match everywhere. Recalculate them.

Never

  • Invent permissions, traffic or business rules.
  • Promise "exactly once". Say what is prevented, where and for how long.
Commencer gratuitement

Après votre inscription, ajoutez API Design à votre agent en un clic.

Autres compétences