Framework Vs. API

Solution 1:

Design Patterns provide the following definitions:

  • toolkits: "often an application will incorporate classes from one or more libraries of predefined classes called toolkits. A toolkit is a set of related and reusable classes designed to provide useful, general-purpose functionality".
  • frameworks: "a framework is a set of cooperating classes that make up a reusable design for a specific class of software".

The key here is that while toolkits (APIs) can be useful in many domains, frameworks are geared to solve issues for specific classes of problems, that can be customized "by creating application specific subclasses of abstract classes of the framework".

Moreover, and maybe more importantly, "the framework dictates the architecture of your application": Inversion Of Control is one of the characteristics of frameworks (see Martin Fowler on this); instead of having your application call specific APIs to implement a specific behavior, it's the framework that calls your code.

Solution 2:

I've always thought the framework was the whole thing, internal code, API's, etc.

While the API is just the bit you use when you want to make use of the framework.

In other words, the .NET framework consists of the .NET libraries, all the languages and so on. The API is just the way you call the functions.