Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between API and framework

Tags:

frameworks

api

People also ask

What is the difference between API and library and framework?

you could use a library in a variety of projects. A framework is a collection of patterns and libraries to help with building an application. An API is an interface for other programs to interact with your program without having direct access.

What's an API framework?

API frameworks are code libraries that provide commonly-used functionality when building your own web application programming interfaces (APIs).

Is a Web framework an API?

Web API is an API as the name suggests, it can be accessed over the web using the HTTP protocol. It is a framework that helps you to create and develop HTTP based RESTFUL services. The web API can be developed by using different technologies such as java, ASP.NET, etc.

Is Java API a framework?

Conclusion. Both API and Framework in Java help to build robust applications. The difference between API and Framework in Java is that Java API is an interface to a set of components that encapsulates functionalities while a framework is a set of classes, tools, and related components that help to develop the project.


A framework is a group of classes, interfaces and other pre-compiled code upon which or by the use of which applications can be built.

The API is the public face of a framework. A well designed framework only exposes those classes, interfaces, etc that are needed to use the framework. Code that supports the operation of the framework but that is not necessary to users of the framework is kept internal to the framework's assemblies/dlls. This keeps the public face of the framework small and encourages a "pit of success," or the quality of a framework which makes it simple to do the right thing.

(I provide an example from the .NET world) The SqlConnection class is used to connect to a Sql Server instance. Its public API is pretty simple:

using (SqlConnection connection = new SqlConnection(connectionString))
{
    connection.Open();
    // Do work here; connection closed on following line.
}

However, this class depends on around 200 methods within the System.Data framework (in this case, an assembly), 3/4 of which are internal and not part of the public API of System.Data. Because the framework's API is kept simple, it becomes easy to use SqlConnection properly. If the user was required to deal with SqlConnectionFactory, SqlDebugContext, DbConnectionPoolGroup or any of the other internal classes required by the SqlConnection class, it would become exponentially more difficult to use SqlConnection properly. Because the API only exposes a small percentage of the framework, it is easier to create and use a connection.


An API is an interface to a (set of) component(s) encapsulating a functionality. For instance, the GoogleMaps API, the DirectX or OpenGL APIs.

A framework is more a set of tools, components aimed at helping the developer to develop his/her project in a given Frame. The framework usually sets some coding standards, provides useful components, ... For instance, Symfony/Cake are PHP web application frameworks. JUnit is a framework for unit tests in Java, ...

Frameworks can often bundle/provide a unified interface to some APIs.

Some APIs can be internally built using a framework.


  1. API - application programming interface -> the contract you must obey when using a library's API
  2. library - a set of classes/modules that solve a specific problem -> has an API
  3. framework - a "bigger" set of libraries with a set of rules on how to use them

Since every library has an API, no point in giving examples.

A popular Java library for time is Joda time.

A popular Java framework is the Spring framework.

You must obey a lot of rules to use Spring well. You don't have to obey as many rules to use Joda time.


An API is something code has, not something it is. A framework has an API, but it is not itself an API.