Hello! Welcome to your next lesson in the Fundamental Design Principles module.
In our last session, we focused on the "Tell, Don't Ask" principle. We saw how creating methods that encapsulate behavior (e.g., account.withdraw(amount)) leads to more robust objects than simply exposing state with getters and setters. The public methods of a class form its API, and by applying "Tell, Don't Ask," you were already practicing good, small-scale API design.
Today, we're going to broaden that perspective. As a Java Spring Boot developer, you're constantly building and consuming larger-scale APIs, most commonly REST APIs that communicate over the network. In system design interviews, demonstrating a strong grasp of what makes a good API is crucial. This lesson will focus on exactly that.
Our learning outcome for today is to explain the importance of designing a clear and stable API (Application Programming Interface).
We'll explore why API design is so critical, what defines a "clear" and "stable" API, and the key characteristics that separate a great API from a frustrating one.
1. What is an API and Why Does It Matter So Much?
At its core, an API is a contract that allows software components to communicate. Let's start with a quick, practical definition relevant to your work with web services.
API Design in System Design Interviews w/ Meta Staff Engineer
The video 'API Design in System Design Interviews' from Hello Interview gives a straightforward definition of an API using a client-server model you'll recognize from your Spring Boot experience.
Watch from 01:22 to 02:34. This segment clearly defines an API and illustrates its role in communication between a client, server, and database.
Now that we have a shared definition, let's address the core question: why is good API design so important? A poorly designed API isn't just a minor inconvenience; it can become a significant technical and business liability.
Joshua Bloch, a key architect of the Java Collections Framework, gives a powerful explanation of this in a classic talk at Google.
How To Design A Good API and Why it Matters
In this clip from 'How To Design A Good API and Why it Matters,' Joshua Bloch explains why APIs are one of a company's most important assets or greatest liabilities.
Watch from 02:00 to 04:32. Pay close attention to his points on: The investment developers make in learning an API. How a bad API can cause an unending stream of support issues. The crucial idea that once an API is public, you are stuck with it.
Bloch’s point is critical: once people start using your API, you can't easily change it without breaking their code. You get one chance to get it right.
To solidify this, let's look at a concise article that summarizes the key business and technical drivers for good API design.
API Design Best Practices for Scalable and Secure APIs
The article 'API Design Best Practices' clearly outlines the main reasons why good API design is crucial.
Read the introductory section and the part titled 'Why Does Good API Design Matter?'. It covers four key benefits: improved developer experience, scalability, reduced technical debt, and enhanced security.
In summary, good API design matters because it:
- Improves Developer Experience (DX): An intuitive API is a pleasure to use, accelerating development for your consumers (and even your future self!).
- Supports Scalability: A well-structured API is easier to maintain, scale, and integrate with other services.
- Reduces Technical Debt: Getting the design right upfront prevents costly workarounds and future refactoring nightmares.
- Enhances Security: A clear, consistent design makes it easier to implement and enforce security policies.
2. Characteristics of a Clear and Stable API
So, what makes an API "clear" and "stable"? These terms describe an API that is easy to understand, predictable, reliable, and evolves gracefully. Let's break this down into practical principles, many of which are essential for acing system design interviews.

The Foundation: A Good API is Easy to Use and Hard to Misuse
Joshua Bloch provides a fantastic summary of the high-level goals of any good API.
How To Design A Good API and Why it Matters
Let's return to Joshua Bloch's talk, where he outlines the essential characteristics of a well-designed API.
Watch from 05:51 to 07:15. This short segment lists the key qualities to strive for, including being easy to learn, hard to misuse, and easy to evolve.
Now, let's explore the concrete practices that help us achieve these qualities.
Clarity: Making the API Understandable and Predictable
A clear API feels intuitive. A developer should be able to guess how to use it with minimal documentation.
1. A Self-Describing and Consistent Structure
The names and structure of your API should communicate intent. For REST APIs, this means:
- Use nouns for resources: Endpoints should represent entities, not actions (e.g.,
/users,/orders). - Use HTTP methods for actions: The verb defines what you're doing to the resource (
GET,POST,DELETE, etc.).
This video gives a perfect, practical demonstration of this principle.
API Design in System Design Interviews w/ Meta Staff Engineer
The 'Hello Interview' video provides a clear, interview-focused explanation of how to design RESTful URLs and use HTTP methods correctly.
Watch from 03:59 to 08:31. Focus on how REST combines plural nouns for resources (e.g., /events) with HTTP verbs (GET, POST) to create a clear, predictable interface.
2. Follows the Principle of Least Astonishment
An API's behavior should never surprise the user. A method or endpoint should do what its name implies, without unexpected side effects.
How To Design A Good API and Why it Matters
Bloch provides a memorable example of an API that violates this principle, leading to hard-to-find bugs.
Watch from 48:29 to 49:48. Notice how the Thread.interrupted() method in Java has a surprising side effect that its name doesn't suggest.
3. Has Comprehensive Documentation
No matter how clear your API is, it needs great documentation. Documentation is the user manual, and it's non-negotiable for a good developer experience.
8 Unmissable Best Practices for API Design in 2025
The article '8 Unmissable Best Practices for API Design' emphasizes that documentation is the primary user interface for your API.
Read section 7, 'Comprehensive Documentation and Developer Experience.' It highlights how companies like Stripe and Twilio set the standard with interactive, developer-focused documentation.
Stability: Making the API Reliable and Evolvable
A stable API provides a dependable contract. Consumers can trust that it will behave consistently and that they won't face unexpected breaking changes.
1. A Clear Versioning Strategy
APIs must evolve. A versioning strategy allows you to introduce changes—especially breaking changes—without disrupting existing clients.

8 Unmissable Best Practices for API Design in 2025
This article explains why versioning is essential for long-term API maintenance and stability.
Read section 4, 'API Versioning Strategy.' It describes the most common approaches, such as URI and header-based versioning.
2. Robust and Predictable Error Handling
Failures will happen. A stable API fails predictably by using standard HTTP status codes and providing meaningful error messages. This allows client applications to handle errors gracefully.
API Design in System Design Interviews w/ Meta Staff Engineer
The 'Hello Interview' video explains how to use HTTP status codes to communicate the outcome of a request, which is a key part of the API contract.
Watch from 11:21 to 12:39 (the part on responses). The speaker gives practical advice for interviews: grouping codes into 2xx (success), 4xx (client error), and 5xx (server error) buckets is often sufficient.
3. Designed for Performance
A slow API is an unstable API. Good design considers performance from the start. One of the most common issues is returning too much data. Pagination is the standard solution for this.
API Design in System Design Interviews w/ Meta Staff Engineer
Let's revisit the 'Hello Interview' video for a quick explanation of pagination.
Watch the segment on pagination from 21:55 to 24:30. Understand the difference between offset-based and cursor-based pagination.
Test your understanding!
An engineer on your team proposes a new API endpoint for retrieving blog post comments. The design is:
GET /api?entity=comment&postId=123&sort=asc
And a successful response looks like this:HTTP 200 OK
[
{ "commentId": 7, "text": "Great post!" },
{ "commentId": 9, "text": "Thanks for sharing." }
]
Based on the principles of a clear and stable API, what are at least three critiques or suggestions for improvement you would make?
Show answer
Here are several potential critiques based on the principles we've discussed:
-
Unclear URL Structure: The URL
GET /api?entity=comment...is not RESTful. It uses a generic endpoint with query parameters to specify the resource. A much clearer, resource-oriented approach would beGET /api/posts/123/comments. This structure immediately tells the developer that we are fetching comments belonging to a specific post. -
No Versioning: The endpoint
GET /api/posts/123/commentshas no version number. This makes it difficult to evolve the API later without breaking existing clients. A better design would beGET /api/v1/posts/123/comments. -
Missing Pagination: The endpoint returns all comments for a post. If a post has thousands of comments, this will lead to a huge response payload and poor performance. The API should support pagination, for example:
GET /api/v1/posts/123/comments?page=1&limit=25. -
Inconsistent Naming: The response field is
commentId, but the query parameter ispostId. While not a major error, striving for consistency (e.g., usingiduniversally, orpostIdandcommentIdconsistently) improves clarity. -
Ambiguous Sorting: The parameter
sort=ascis ambiguous. Ascending by what? Date? ID? A better design specifies the field:sort=createdAt:asc.
Conclusion
In this lesson, we've explored why designing clear and stable APIs is one of the most important responsibilities for a software engineer. A well-designed API acts as a force multiplier, enabling other developers to build on your work efficiently and reliably. A poorly designed one creates a legacy of technical debt and frustration.
Key Takeaways:
- APIs are a long-term contract: Once published, they are very hard to change. "When in doubt, leave it out."
- Clarity is paramount: A clear API is self-describing, consistent, predictable, and well-documented. It follows established conventions like RESTful principles to reduce cognitive load on developers.
- Stability ensures reliability: A stable API is one that developers can trust. It evolves gracefully through versioning, fails predictably with clear error codes, and performs well under load by using techniques like pagination.
- Good design is about empathy: Ultimately, you are designing an interface for other developers. A great API shows empathy for its users.
In our next lesson, we will discuss the concept of an immutable object and its benefits. This is directly related to API design. When you pass data through an API, using immutable objects for your request and response models is a powerful technique to enhance stability and prevent entire classes of bugs, especially in the concurrent environments common in backend services.