API Documentation and Developer Experience Questions
Documentation and developer experience for API consumers: reference docs for endpoints and fields, OpenAPI-driven and interactive documentation, quickstarts and runnable code samples, doc comments that feed generated reference, changelogs, deprecation notices and migration guides, error messages and error tables that explain themselves, developer portals, sandboxes and onboarding flows. Covers developer experience (DX) as a product concern: time to first successful call, DX and docs-effectiveness metrics and dashboards, diagnosing onboarding drop-off, developer feedback loops, experiments and developer research, documentation standards and CI checks across teams, prioritising DX investment, and reducing support load through better docs and self-service. Designing the API itself (versioning policy, auth, rate limits, webhooks, gateways, SDK engineering) is a separate subject.
You are handing a new public endpoint to external developers. What documentation and artifacts must ship with it for a smooth integration, and what do you check before calling it done?
Sample Answer
Direct answer
A new public endpoint ships with five things: a reference entry generated from the API's machine-readable description, a runnable example that a stranger can copy, the error and limit behaviour spelled out, a changelog entry with versioning notes, and a working sandbox path. It is "done" when someone who did not build it can call it correctly using only those materials, and when an automated check proves the docs match the running code.
What must ship
| Artifact | What it must contain |
|---|---|
| Reference entry | Purpose in one sentence, parameters, request and response schema, auth required. Generated from the OpenAPI file (the standard machine-readable description of a REST API), which also powers an interactive "try it" explorer |
| Request/response examples | One success example with realistic values, plus the common failure examples |
| Error catalogue | Each error code, what causes it, how the caller fixes it |
| Pagination example | A list endpoint shows page one, how to request the next page (cursor: an opaque bookmark for the next page; offset: skip N items), and how the caller knows it reached the end |
| Limits and idempotency | Rate limits and what the client should do on a 429 response (wait, honoring the Retry-After header (its value is either a number of seconds or an HTTP date after which to retry), and retry with backoff, meaning growing delays between attempts). Whether a repeated POST is safe, and the idempotency key (a caller-chosen unique value that makes a retry a no-op) to send |
| Versioning notes | Is this stable or beta, what change would be breaking (removing or renaming a field, changing a type, making an optional input required; adding an optional field is not), how long a deprecated field (one marked for future removal) lives |
| Changelog entry | Dated, says what is new and who is affected (sample below) |
| Sandbox access | A test key and test data so the example works without real side effects |
The same checklist for an internal shared service
Suppose the "public endpoint" is an internal model-serving service used by other teams. The downstream teams need the same items, weighted toward safe integration: rate limits and quotas per team, idempotency and retry rules, the full error-code table, the payload schema including maximum sizes, and versioning notes (which model version answers, when it changes). Internal consumers cannot ask you in a hallway at scale, so the docs replace that conversation.
Definition-of-done checks
- Clean-room run: someone outside the team follows the docs on a fresh machine and makes a successful call.
- Docs match code: a contract test in CI (continuous integration, the automated build run on every change) compares real responses to the OpenAPI schema. If the code changes and the spec does not, the build fails. This is how docs stay in sync with the implementation.
- Examples execute: every sample is run automatically against the sandbox.
- Failure paths documented: for each error code you can trigger, the docs show it.
- Links and generated explorer work: the interactive page loads and "try it" reaches the sandbox.
Worked example
A new GET /orders endpoint. The reference says it returns data (a list) and next_cursor. The pagination example shows: first call GET /orders?limit=2 returns two orders and "next_cursor": "c_9"; second call GET /orders?limit=2&cursor=c_9 returns one order and "next_cursor": null, meaning done. The error table lists 401 (bad key), 429 (slow down, retry after the time given in the Retry-After header, a number of seconds or an HTTP date) and 422 (bad limit). If a reviewer's clean-room run cannot explain what null means, the doc is not done.
Sample changelog entry
2025-03-04 Added: GET /orders (list orders, cursor pagination). Stable.
Affects: new endpoint only, no action needed for existing integrations.
2025-03-04 Deprecated: field `orders[].total` (use `total_cents`).
Still returned until 2025-09-04. Affects: clients reading `total`.
A contract test in miniature. The OpenAPI file says next_cursor is a string or null. The test calls the sandbox GET /orders?limit=2 and checks that the response has exactly the documented fields with the documented types. If a developer renames next_cursor to cursor in the code but not in the spec, the check finds a missing documented field and fails the build. A clean-room run means a fresh machine with none of the team's existing keys, tools or setup, so hidden assumptions surface. Quotas are longer-horizon usage caps (for example, per month), distinct from per-minute rate limits, and a payload is the body of a request or response.
Pitfalls
- Reference without examples: complete but unusable for a beginner.
- Examples showing only the happy path: the first real problem is an error nobody documented.
- Hand-maintained docs beside a fast-changing API: they diverge quietly. Generate what can be generated and test the rest.
You are launching a REST API to external developers and confusion is already the top complaint from the beta users. What would your documentation set contain, in what order do you build it, and how do you decide when it is good enough to ship?
Sample Answer
Direct answer
Treat "confusion" as a symptom to diagnose, not a reason to write more pages. I would ship a small, layered docs set (quickstart, authentication guide, reference generated from the API description, errors and limits, task guides, samples, changelog), build it in the order a newcomer meets it, and call it good enough only when developers who have never seen the API can complete a first call unaided within a target time.
Step 0: find what the beta users are actually confused about (first days)
Tag the beta support tickets and forum posts by theme, then watch 3 to 5 developers try the API cold while you stay silent. The themes decide the build order below. Confusion at "how do I get a key" needs a different fix than confusion at "why did I get a 422" (HTTP status 422 means the request was well-formed but a value was rejected). Three to five is enough for this exploratory pass because the biggest stumbling blocks repeat across people; the ship gate below uses five for a slightly firmer read.
What the documentation set contains (in build order)
- Quickstart (first, highest value): one page, from "no account" to "first successful call" with copy-paste code. Written against a sandbox (a safe test copy of the API with fake data, so nothing real can break).
- Authentication guide: how to get a key, where to send it, what a wrong key looks like, how to rotate it. A wrong key should look like this in the docs:
401 {"error": {"code": "invalid_api_key", "message": "API key is missing or invalid."}}. (An API key is a secret string that identifies the caller.) - API reference, generated from an OpenAPI file (OpenAPI is the standard machine-readable description of a REST API: paths, parameters, schemas). Generating it keeps the reference accurate and lets you offer an interactive API explorer ("try it" console) for free.
- Errors, limits and conventions: every error code with cause and fix, rate limits (how many calls per minute are allowed), pagination (returning long lists in pages), idempotency (a retry-safe request key so a repeated POST does not create two orders), versioning policy (how versions are numbered and how long old ones keep working).
- Task guides for the 3 to 5 jobs developers really do ("create a customer and charge them"), each a complete flow, not an endpoint list.
- Sample apps and a Postman collection (a saved set of ready-made requests): quick wins that let developers see the API working before writing any code.
- Changelog (dated list of what changed) and deprecation notices (advance warnings that something will be removed), plus a status page (a public page showing whether the API is up right now) so "is it me or you" has an answer.
Deciding it is good enough to ship
Do not use "all pages written". Use gates:
- Unaided run: 5 developers new to the API each reach a first successful call using only the docs. "Needs help" means the developer asks the observer a question, opens the support channel, or is stuck on one step for more than about five minutes. If more than one of the five needs help at the same step, fix that step and re-test.
- Reference completeness: every endpoint has a description, at least one request and response example, and its error responses listed. The spec is checked in CI (continuous integration, the automated build that runs on every change) so it cannot drift from the code.
- Samples run: every code sample is executed automatically.
- Support loop ready: a channel and an owner exist for the docs bug reports you will get on day one.
Worked example: KPIs (key performance indicators) to judge launch success
Launch KPIs (key performance indicators, the numbers you judge success by) each need a numerator, denominator and window:
| KPI | Definition | Illustrative reading |
|---|---|---|
| Time to first successful call | median (middle value) minutes from signup to first 2xx response (2xx is any HTTP success status such as 200) | 40 minutes at beta, target under 10 |
| Activation rate | signups making a successful call within 7 days, divided by signups | 15 of 100 (15%) at beta |
| Docs-related tickets per 1,000 active developers | tickets tagged docs or how-to in the month, divided by active developers times 1,000 | falls if the quickstart works |
| Docs search with no result | searches returning nothing, divided by all searches | shows missing pages |
(The readings are illustrative, not measurements.) Normalising tickets per 1,000 developers matters: raw ticket counts rise simply because adoption grows.
Trade-offs and pitfalls
- Writing the full reference first feels thorough, but the reference is the least useful page for a lost beginner. Quickstart first.
- Generated reference alone is not documentation: it says what each field is, never why or in what order.
- A tidy docs site with no owner rots within a quarter. Ownership and the CI gate are part of the deliverable.
- I would ship with a known gap list rather than wait for perfection, provided the quickstart and the top task guide pass the unaided test. If the unaided test still fails at the authentication step, do not launch: fix that first, because every user hits it.
You are asked to review the reference page for a single API endpoint before it ships. What must that page contain for a developer who has never seen the API, and how does reference content differ from a getting-started guide?
Sample Answer
Direct answer
An endpoint reference page is the lookup page for one operation of the API. A developer who has never seen the API should be able to make a correct call from it, and handle every outcome, without reading anything else. So it must state what the call does, how to authenticate, every input with type, default and allowed range, a realistic request and response, every error with what to do about it, and the limits that apply. A getting-started guide is organised around a goal ("get a first result in five minutes") and walks one happy path. Reference is organised around the API's structure and is exhaustive.
What the page must contain
- Method, path, one-sentence purpose.
POST /v1/predict: "Returns a prediction for one input." Also the base URL for each environment. - Authentication and permissions. Header format and which key scope or role the call needs (a key scope is the set of actions a given key may perform, for example read-only versus read-write).
- Inputs table. Name, type, required or optional, default, valid range or allowed values, meaning, units.
- Request and response example. Realistic, copy-pasteable, and consistent with the tables. Every response field explained.
- Errors. Each status code the endpoint can return, the body it carries, the cause, and the caller's action (fix the request, retry, wait).
- Limits and behaviour. Rate limit, payload size cap (the maximum request body size), timeout, whether retrying is safe (idempotent means repeating the call has the same effect as making it once), pagination for lists (returning a long list in pages, with a way to ask for the next page).
- Stability. Version,
deprecatedmarker (a flag saying the endpoint is scheduled for removal), link to the changelog (the dated list of what changed in each release).
Reference versus getting-started
| Reference | Getting-started guide | |
|---|---|---|
| Organised by | API structure (endpoint by endpoint) | The reader's goal |
| Reader | Someone who knows what they need and looks it up | Someone new who needs momentum |
| Coverage | Complete: every field, every error | Minimal: one path that works |
| Explanation | Precise and terse | Narrative, explains why each step |
Contract-level sections (written once, linked from every endpoint)
- Authentication overview (how keys are issued, rotated, scoped).
- Rate limits: the numbers, the response headers, and the
429 Too Many Requestsbehaviour includingRetry-After(a response header saying how long to wait before trying again, as a number of seconds or as an HTTP date). - Error format shared by all endpoints.
- Versioning and deprecation policy: how much notice, and how a deprecation is signalled (docs banner, response header).
- SLA (service-level agreement, the published uptime or latency promise) and a status page link.
Reusable endpoint template
METHOD /path One-sentence purpose
Auth Header + required scope
Parameters name | type | required | default | range | description
Request example Realistic, copy-pasteable
Response Fields + example
Errors status | code | cause | what the caller does
Limits Rate, size, timeout, retry-safety
Stability Version, deprecated?, changelog link
Worked example (model inference)
POST /v1/predict, auth Authorization: Bearer <key>. Body field text: string, required, 1 to 2000 characters. top_k: integer, optional, default 1, range 1 to 5. Success 200 returns label, score (0 to 1) and model_version. Failures: 400 (malformed body: the request could not even be parsed, such as broken JSON), 422 (well-formed but invalid: text empty or too long, names the field), 429 (rate limited, wait as long as Retry-After says), 503 (model loading, retry with backoff, meaning wait and retry with growing delays). Payload cap and timeout are stated on the page, not left to be discovered.
What the filled-in page looks like (abridged)
POST /v1/predict Returns a prediction for one input.
Auth Authorization: Bearer <key> Scope: predict:invoke
Body text string required 1-2000 chars Text to classify
top_k integer optional default 1, range 1-5
200 OK {"label": "positive", "score": 0.93, "model_version": "2024-05"}
Errors
status | code | cause | caller does
400 | invalid_json | body is not valid JSON | fix the request
422 | text_too_long | text over 2000 characters | shorten text
429 | rate_limited | over 60 requests/minute | wait as `Retry-After` says
503 | model_loading | model warming up | retry, backing off
Limits 60 requests/minute per key. Body up to 32 KB. Timeout 10 s.
Retrying is safe (read-only, idempotent).
Stability v1, stable. Not deprecated. Changelog: /changelog
The numbers above are illustrative placeholders for a fictional endpoint. Two sample notices that belong on the contract-level pages:
- Rate-limit notice: "Exceeding the limit returns 429 with a
Retry-After: 12header. Wait 12 seconds, then retry." (Retry-Aftermay also carry an HTTP date, such asRetry-After: Wed, 21 Oct 2026 07:28:00 GMT, so the page should say which form the API sends and clients should accept both.) - Deprecation notice: "
GET /v1/predict-legacyis deprecated as of 2025-01-15 and will be removed on 2025-07-15. UsePOST /v1/predict. Responses now carry aDeprecationheader."
Pitfalls
- Field lists without types, defaults or ranges.
- Only the success case documented.
- An example whose values do not satisfy the page's own schema.
- Tutorial prose creeping into reference until nobody can scan it.
How would you measure time to first successful call for a public API, for both SDK and direct HTTP users? Define what counts as success, what you would instrument from first docs view onward, and how you would report it without an average hiding the slow tail.
Sample Answer
Direct answer
An SDK (software development kit) is a client library in a language like Python that wraps the raw HTTP calls; "direct HTTP" means calling the API yourself with curl or an HTTP library. Time to first successful call (TTFC, also called time to first "hello world") is the elapsed time from a developer's first docs view to their first successful, authenticated request to a real endpoint. Define success precisely, capture events that survive across sessions and devices, compute it per developer, and report a distribution (percentiles and completion rates, split by SDK versus direct HTTP), never a single average.
1. What counts as success
- Success = the first HTTP 2xx response from a non-trivial endpoint, made with a key that developer created. A health check or ping does not count, or the number flatters you.
- For a model API, use the stricter time to first meaningful result: the first response that contains a real prediction.
- Start of the clock = first docs view (as asked), stored as one anonymous identifier. Optionally also report signup-to-first-call, which isolates the product's own share.
- Developers who never succeed are censored (their true time is unknown because they have not finished yet). Count them in the denominator, never drop them.
2. What to instrument
| Event | Source | Note |
|---|---|---|
docs_viewed (first) | Docs site | Sets an anonymous ID |
signup_completed | Auth service | Links anonymous ID to account ID |
key_created | Console | Links account to key ID |
sdk_installed | Optional install ping | Package download counts alone cannot be tied to a person |
first_request (any status) | API gateway logs (the server-side record of every request) | Shows failures before the win |
first_2xx | API gateway logs | Server-side, so it cannot be blocked by an ad blocker |
Two design points. Cross-session identity: the anonymous ID is aliased (linked, so the two IDs count as one person) to the account ID at signup, then to the key ID, so a developer who returns three days later is one journey. SDK versus HTTP: the SDK sends an identifying User-Agent (a header every HTTP client sends naming the software making the call) with name and version; a raw client shows as curl or a language HTTP library. Segment on that at the gateway. Server-side events plus consent-aware client events keep it privacy-safe.
3. Report the distribution, not the mean
Worked example. Times in minutes from first docs view to first 2xx for 16 developers (illustrative, pinned so you can reproduce it):
import math
# minutes from first docs view to first HTTP 2xx; None = never succeeded in 7 days
sdk = [3, 4, 4, 5, 6, 7, 9, 12]
http = [6, 9, 14, 22, 35, 95, 1500, None]
def pct(vals, p):
vals = sorted(vals)
k = math.ceil(p / 100 * len(vals)) # nearest-rank percentile
return vals[k - 1]
def report(name, xs):
done = [x for x in xs if x is not None]
print(f"{name}: n={len(xs)} succeeded={len(done)} "
f"within10m={sum(x <= 10 for x in done)/len(xs):.0%} "
f"within60m={sum(x <= 60 for x in done)/len(xs):.0%} "
f"median={pct(done,50)} p90={pct(done,90)} mean={sum(done)/len(done):.1f}")
report("SDK ", sdk)
report("HTTP", http)
report("ALL ", sdk + http)
SDK : n=8 succeeded=8 within10m=88% within60m=100% median=5 p90=12 mean=6.2
HTTP: n=8 succeeded=7 within10m=25% within60m=62% median=22 p90=1500 mean=240.1
ALL : n=16 succeeded=15 within10m=56% within60m=81% median=9 p90=95 mean=115.4
How to read it: pct sorts the times and returns the value at the nearest rank (with 7 values, p90 is the ceil(0.9 x 7) = 7th, the largest); report counts everyone in the denominator (so the never-succeeded developer lowers the within-10m and within-60m rates) and prints each statistic. A percentile is the value below which that share of developers fall.
The HTTP mean (240 minutes) is dragged up by one 1500-minute outlier and says nothing useful; the median (22) plus p90 (the time by which 90% of successful developers finished) and the within-10-minute rate show the real picture: SDK users are fast, direct HTTP users are the problem. Note the HTTP p90 is 1500, the same outlier: with only 7 finishers, nearest-rank p90 is just the maximum, so p90 needs a real sample (tens or hundreds of developers) to be informative; here the median (22) and the completion rates carry the message. Report by weekly signup cohort (developers grouped by the week they signed up) so changes are visible.
4. Gaming and guards
- Health-check or test-account calls (including your own employees): exclude internal accounts and require a non-trivial endpoint.
- Multiple keys or accounts resetting the clock: anchor to the earliest docs view for the person, not the key.
- Bots and scrapers: require a completed signup.
- Shipping a "hello" endpoint to game the number: pair the metric with a 7-day activation rate (share of signups making a call) and with later retention (share still calling weeks later).
This is the first funnel stage; the funnel also gives install rate and drop-off per step, and the metric pairs with end-to-end integration tracking (docs view to production traffic) using the same identity chain.
Design a quickstart that gets an integrator to a first successful API call in under five minutes. What is in it, in what order, and how do you test that it really works for someone who has never seen the product?
Sample Answer
Direct answer
A quickstart (the shortest guide that takes a new developer to one working call) has one job: one working call, with the shortest path to it. Order it as: what you need, get a key, set it, make the call, see the expected output, then the next step. Everything else (concepts, all parameters, alternatives) goes elsewhere behind a link. You prove it works by watching someone who has never seen the product follow it cold on a clean machine, timing them and noting every hesitation, then re-running the same steps automatically on a schedule.
Illustrative excerpt (for a fictional "Acme Messages" API)
Send your first message in 5 minutes
1. Get a sandbox key. (A sandbox is a safe test copy of the API with fake data, so nothing real is charged or sent.) Open the dashboard and click Create test key. No card needed. Test keys start with
sk_test_.2. Save the key.
bashexport ACME_API_KEY="sk_test_..."3. Make the call. cURL is a command-line tool that sends HTTP requests, preinstalled on most systems.
bashcurl -i https://api.example.com/v1/messages \ -H "Authorization: Bearer $ACME_API_KEY" \ -H "Content-Type: application/json" \ -d '{"to": "test@example.com", "text": "Hello"}'4. Check the result. (The
-iflag makes cURL print the response status line and headers before the body; without it only the body appears and the reader cannot see the status.) You should seeHTTP 201(any status starting with 2, called 2xx, means success) and a body like{"id": "msg_123", "status": "queued"}(illustrative). If you see401, the key is wrong: fix it.5. Next. Same call in Python or Node with the SDK (a client library that wraps the raw HTTP call in your language), then webhooks (calls our server makes to yours when something happens, such as a message being delivered).
Why this order
- Credentials before code, because a missing key is where people most often stall.
- Copy-paste first, SDK second. A raw call proves the account works with no toolchain; the SDK tab follows for people who want it.
- Show the expected output so the reader can tell success from silent failure.
- Hardest-to-guess facts inline (base URL, auth header format), never "see the docs".
- Cut anything not needed for the first call: concepts, every parameter, production settings.
Testing that it really works
- Cold-read test. Recruit two or three people who fit the audience and have never seen the product. Give them only the URL. "Cold" means no prior briefing. Watch silently, record where they pause, mis-type or open another tab. Every stall is a doc bug.
- Time it from opening the page to the first
2xx. The five-minute target is checked, not assumed. - Automate it. A CI (continuous integration) job runs the quickstart's exact commands against the sandbox each day and fails if the output stops matching. Docs that broke silently are the usual cause of stalls.
- Fresh environment. Run on a clean container (a fresh, disposable virtual machine-like environment with nothing pre-installed) or new laptop profile so an installed tool on your own machine does not hide a missing prerequisite.
Pitfalls
- Steps that assume prior state ("using your existing project").
- A key that needs a sales approval or credit card before the first call.
- Screenshots of a dashboard that has since changed.
Unlock Full Question Bank
Get access to all 31 API Documentation and Developer Experience interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.