Mike's Notes
Another great visual explanation from Nikki Siapno, who writes the weekly Level Up Coding newsletter. It's worth subscribing to.
Resources
- https://www.linkedin.com/in/nikkisiapno/
- https://blog.levelupcoding.com/
- https://blog.levelupcoding.com/p/luc-83-8-common-mistakes-to-avoid-in-api-design
References
- Reference
Repository
- Home > Ajabbi Research > Library > Subscriptions > Level Up Coding
- Home > Handbook >
Last Updated
28/04/2025
8 Common Mistakes to Avoid in API Design
Nikki Siapno, is an Engineering Manager at Canva and founder of Level Up Coding.
Clean, reliable APIs are a hallmark of strong engineering teams.
They don't happen by accident — they happen by design.
Let's walk through 8 critical mistakes to watch for when crafting APIs that stand the test of time.
1) Not Validating User Inputs
Input validation is your API’s first line of defense.
Accepting unvalidated data leaves you vulnerable to injection attacks, corrupted databases, and confusing downstream errors. Always validate inputs on the server side; not just for type and format, but also for business logic. Assume nothing about client behavior.
Tip: Use schema validation libraries or frameworks to enforce strict rules at your API boundaries.
2) Weak Security
Security can't be an afterthought. Common oversights include exposing sensitive data, improperly handling authentication tokens, or missing encryption on data in transit. A single weak endpoint can compromise your entire system.
Tip: Apply principles like least privilege, secure authentication (OAuth 2.0, OpenID Connect), encrypted communication (TLS), and regular security audits across your API surface.
3) Overcomplicating the API
A powerful API isn’t necessarily a complex one.
When you overload endpoints with too many responsibilities, mix resources and actions, or create deeply nested payloads, you make your API harder to learn, harder to use, and harder to maintain.
Tip: Stick to clear, predictable patterns. One resource → one endpoint. One action → one HTTP method.
4) Lack of Clear Documentation
The best API in the world won't gain adoption without great docs.
Unclear documentation forces developers to guess how your API works — leading to mistakes, frustration, and support tickets.
Tip: Invest in easy-to-navigate documentation, examples, and usage guides. Tools like Swagger/OpenAPI and Postman can help you automatically generate high-quality docs from your API definitions.
5) Poor Error Handling
Errors are inevitable — unclear errors are unforgivable.
Vague 500 errors, inconsistent error formats, and missing error codes make debugging a nightmare for users.
Tip: Standardize your error responses. Include meaningful HTTP status codes, error messages, and even error IDs that developers can reference for troubleshooting.
6) Not Rate Limiting
Without rate limiting, a single client can unintentionally (or maliciously) overwhelm your API and bring your system down. This isn’t just a problem for high-traffic APIs — any public-facing service needs basic protections against spikes.
Tip: Implement sensible rate limits (eg; 1,000 requests/minute per API key) and return clear error messages (HTTP 429) when limits are exceeded.
7) Not Implementing Versioning
APIs evolve, but your users shouldn’t suffer every time you make a change. Without versioning, even minor updates can break client applications that depend on your previous behavior.
Tip: Plan for API versioning from day one. Common strategies include path versioning (/v1/users) or header-based versioning (Accept: application/vnd.company.v1+json).
8) Ignoring Performance Optimization
An API might work fine at low scale, but poor performance can quietly become a huge bottleneck as adoption grows. Inefficient queries, redundant data transfers, and lack of caching can grind systems to a halt.
Tip: Monitor and optimize your most critical endpoints. Techniques like pagination, compression, selective fields (fields=id,name), and caching (ETags, HTTP caching) make a big difference.
Final Thoughts
Your API is a product — even if it’s "internal." Treat it like one.
Clear contracts, secure practices, thoughtful UX, and strong documentation aren’t just "nice to have"; they determine whether developers love integrating with your systems or dread it.
Every decision you make at the design stage pays compounding dividends later. Start strong, and you’ll save yourself (and your users) a lot of pain.
No comments:
Post a Comment