concept api in category software development

This is an excerpt from Manning's book The Mikado Method.
A large-scale improvement will lead you to change several parts of a system. This is the true essence of a structural improvement, where you break up heavily entangled code and mazes of dependencies, extracting APIs from what weren’t meant to be APIs, and dealing with the ripple effects of a large change.
Breaking out functionality as described in the previous examples may make your code comply with cohesion principles or enable you to do what you want, but there might still be some work left to do. Maybe the extracted code contains too many classes or too much information for the consumer of that library. Maybe parts of the implementation shouldn’t, or couldn’t, be provided. Maybe the implementation of the package changes a lot, but the API of that package is rather stable. Maybe there are to be several implementations of that API.

This is an excerpt from Manning's book Test Driven: Practical TDD and Acceptance TDD for Java Developers.
When we write a test in the first step of the TDD cycle, we’re really doing more than just writing a test. We’re making design decisions. We’re designing the API—the interface for accessing the functionality we’re testing. By writing the test before the code it’s testing, we are forcing ourselves to think hard about how we want the code to be used. It’s a bit like putting together a jigsaw puzzle. As illustrated by figure 1.5, it’s difficult to get the piece you need if you don’t know the pieces with which it should connect.
And it fails. It fails because I thought (don’t ask why) that the groupCount method would give me the number of occurrences of the pattern in the data, not the number of groups identified in the regular expression itself. Well, at least I found that out before writing the whole implementation based on my incorrect assumption about the API.