API Platform & Lifecycle · Developer Experience
SDK Generation
Typed client libraries from your spec: generators, customization and release process.
SDKs reduce integration effort and errors: typed models, auth, retries with backoff, pagination helpers, idempotency keys and error classes. Generate them from the spec with OpenAPI Generator (open source) or commercial generators (Speakeasy, Stainless, Fern) that produce idiomatic code. Treat SDKs as products: semantic versioning, changelogs, deprecation warnings, and automated releases when the spec changes.
SDK approaches
| Criterion | OpenAPI Generator | Commercial generators | Hand-written SDKs |
|---|---|---|---|
| Cost | Free | Paid | Engineering time |
| Idiomatic output | Varies by language | High | Highest |
| Retries/pagination built in | Limited | Yes | Custom |
| Keeps up with spec | Automated | Automated | Manual (drifts) |
import Acme from "@acme/sdk";
const client = new Acme({ apiKey: process.env.ACME_API_KEY, maxRetries: 2, timeout: 10_000 });
const order = await client.orders.create(
{ items: [{ sku: "MUG-01", quantity: 2 }] },
{ idempotencyKey: crypto.randomUUID() },
);
for await (const o of client.orders.list({ status: "paid" })) { // auto-pagination
console.log(o.id);
}
from acme import Acme, RateLimitError
client = Acme(api_key=os.environ["ACME_API_KEY"], max_retries=2, timeout=10.0)
try:
order = client.orders.create(items=[{"sku": "MUG-01", "quantity": 2}], idempotency_key=str(uuid4()))
except RateLimitError as e:
time.sleep(e.retry_after)
for o in client.orders.list(status="paid"): # auto-pagination
print(o.id)
npx @openapitools/openapi-generator-cli generate \
-i api/openapi.yaml -g typescript-fetch -o sdks/typescript \
--additional-properties=npmName=@acme/sdk,supportsES6=true
Common pitfalls
- Generated SDKs without retries/timeouts.
- Breaking SDK releases for additive API changes.
- SDK and API version numbers confused.
Key points
- Generate from the spec
- Built-in retries, pagination, idempotency
- Version SDKs independently with semver
Further reading: OpenAPI Generator
Practice questions
What features should a good API SDK include beyond typed methods?
Answer
Auth handling, timeouts, retries with backoff for retryable errors, idempotency key support, pagination iterators, typed errors and telemetry hooks.
Why version SDKs separately from the API?
Answer
SDK releases include client-side changes (bug fixes, new helpers) that don't change the API, and breaking SDK changes may happen without an API change; semver communicates that.
Open in the app to mark lessons complete, take notes and track your progress.