Your API docs explain rate limits in a paragraph. Show them instead.
Most API docs handle the hard concepts the same way: a paragraph of text, maybe a table, and a hope that the developer gets it.
Developers don't read docs. They scan them, copy a snippet, and come back when something breaks. When it breaks, it's usually one of four things: a rate limit, a webhook, a surprise bill, or a quickstart that didn't work.
Here's how to explain each of those clearly, with a little code you can use either way.
1. Rate limits: show the bucket draining
"100 requests per minute" sounds simple until someone sends 100 requests in the first second and gets throttled for 59 seconds. Most APIs use a token bucket, and once someone watches one drain and refill, it makes sense.
class TokenBucket {
constructor(capacity, refillPerSec) {
this.capacity = capacity;
this.tokens = capacity;
this.refillPerSec = refillPerSec;
this.last = Date.now();
}
take() {
const now = Date.now();
const elapsed = (now - this.last) / 1000;
this.tokens = Math.min(this.capacity, this.tokens + elapsed * this.refillPerSec);
this.last = now;
if (this.tokens >= 1) {
this.tokens -= 1;
return true;
}
return false; // this is your 429
}
}
Docs tip: say which algorithm you use, which headers report remaining quota, and whether Retry-After is in seconds or a date.
2. Webhooks: show the full round trip
The two biggest sources of webhook support tickets are signature checks and retries. Put a working verification snippet right next to the explanation:
import crypto from "node:crypto";
function verifySignature(rawBody, signatureHeader, secret) {
const expected = crypto
.createHmac("sha256", secret)
.update(rawBody)
.digest("hex");
const a = Buffer.from(expected);
const b = Buffer.from(signatureHeader);
return a.length === b.length && crypto.timingSafeEqual(a, b);
}
Then say these three things clearly:
- Verify against the raw body. Parsed JSON re-serialized will not match.
- Retries happen, so handlers must be idempotent. Store the event ID and skip duplicates. (I walked through a retry demo for exactly this in Give your webhook docs a retry button.)
- Give the retry schedule. "We retry" is not a schedule.
3. Usage pricing: do the math for them
"$0.002 per call after 1,000 free calls" means nothing until someone multiplies it. At 50,000 calls a month, that's 49,000 x $0.002 = $98.
Put that number on the page, along with a few volumes your real customers hit. Nobody likes being surprised by an invoice.
4. Quickstarts: one copy, one paste, one success
A good quickstart gets someone to a 200 response in under five minutes in their language. Use tabs for curl, JS, and Python. Prefill the base URL, and mark the one line they need to change, which is usually the API key.
The pattern
Every one of these gets clearer when it's interactive. Developers trust what they can poke at. I build Framer components that do exactly this for devtool sites: a Rate Limiter Visualizer, a Webhook Playground, a Usage Pricing Calculator, and an SDK Quickstart Builder. The ideas above work with or without them, though.
Which part of API docs causes you the most pain? Rate limits, webhooks, or pricing pages? Tell me in the comments.
Comments
No comments yet. Start the discussion.