I would like to know the exact differences between API and DLL. Thank you.
10 Answers
Pretty much the only connection between the two terms is that if you do native Windows programming, APIs you use or write will usually manifest as DLL files. But neither is this the only concrete form an API can take, nor does every DLL represent an API.
API means "Application Programming Interface" - it's an abstract term for a collection of code entities (functions, classes, etc. - depends on the programming language) that's intended to be used by programmers at large to access the functionality of an application or library.
A DLL is a file format on Windows that contains executable code as a way to modularize applications.

- 93
- 9

- 342,105
- 78
- 482
- 720
-
-
So one more doubt, APIs are contained in DLLs, is that correct?? APIs are merely functions which can be called by user processes, what about this? – imahan Dec 06 '10 at 11:23
-
4@imahan: again: API is an abstract term. If you do Windows programming in C then yes, your APIs will generally be functions in DLL files. If you do Java programming, APIs are classes contained in JAR files. Most platforms have their own mechanisms. – Michael Borgwardt Dec 06 '10 at 11:39
-
This is the best answer imo. Worth noting that APIs can also be used as a guideline for implementers of the code library, not just for clients of it. cf. Mono as an alternative .Net Framework class library. Same API, diff. implementation. – Steve Townsend Dec 06 '10 at 15:32
An application programming interface (API) is an interface implemented by a software program that enables it to interact with other software. It facilitates interaction between different software programs similar to the way the user interface facilitates interaction between humans and computers. - Wikipedia
A Dynamic Link Library (DLL) is a one way of providing an API. (Interface to the programmer) You may have various other methods, like Web services.

- 20,548
- 30
- 97
- 138
-
So, my next question is : Are APIs contained in a DLL? That is in other words, are APIs merely functions which can be called? – imahan Dec 06 '10 at 11:11
-
1Well, This is an example. This is from Sharepoint API. http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splist.aspx You can see the a lot of methods that supports programmer (So this is a programmer interface). But this is delivered as a DLL file. I mean the every API should be presented (delivered) to the user in some format. A DLL is one format to do that :) – Chathuranga Chandrasekara Dec 06 '10 at 11:15
-
5@imahan: you're missing the main point: API is an *abstract* term. DLL is a concrete, technical file format. – Michael Borgwardt Dec 06 '10 at 11:17
A DLL is a library of code, and API is an interface to a library of code.

- 601,492
- 42
- 1,072
- 1,490
DLL = Dynamic-link library
API = Application programming interface
A DLL is just a file on Windows systems that has some code in that can be used by other executable files. An API is a way of using one piece of software, or a software library, to be used with another. For example there is a Windows Registry API that allows you to use the registry, but the code that runs when you use the API is stored in a DLL.

- 8,335
- 6
- 30
- 43
Updates: DLL (Dynamic Link Library) is a code component (some what like the Beans in Java). DLLs contains the methods or functions or routines or whatever you call those code fragments. And an API is an interface between an application and that DLL. Most of the time DLLs are used to provide services to other applications, these DLLs are called Server DLLs and if a DLL is requesting some service by using the API call or its dynamic invocation then it is said to be the Client DLL. So simple think, APIs are nothing but the methods or functions which are accessible from outside of that DLL. Hope you got the idea now.

- 13,031
- 8
- 59
- 87
-
Of course i can browse through wikipedia and find out answers, I am here because i didn't understand what is said there! So kindly answer to my qusetion, ""Are APIs contained in a DLL? That is in other words, are APIs merely functions which can be called?"" thank you – imahan Dec 06 '10 at 11:14
-
@imahan, API are interfaces, you can't use them unless it's implemented. So, DLL contains `implemented` APIs. See my updated answer. – Buhake Sindi Dec 06 '10 at 11:20
API are the header files (.h) which contain function and class declarations (input and output parameters), the implementation of these declaration i.e definitions of class or functions will be in particular dlls.
But to connect (dynamic linking) both these .h and .dll files, you require .lib files, these files will resolve the address of function definition during run-time and that particular dll files are loaded. Hence, libraries contain (APIs(.h), lib and dll files).
APIs make application development independent of underlying library implementations.
Example:
if you write a program in C to print "Hello World". And if you run the same program in windows and Linux.
Both these executable will use different system libraries to display it on screen, as C language provides set of APIs like "STDIO.h","STDLIB.h", You need not worry about the underlying library implementations.
So you can think, API as header files, which connect function/class declarations with function/class definitions. Hence, the name "Application program interface".

- 1,182
- 1
- 13
- 26
You will have to be specific. DLL can stand for:
- Data Link Layer,
- Dynamic Link Library (Shared library on Windows Platform). It can also be a resource library too.
An API (Application Programming Interface) is an interface that's implemented by software programs to interact with other sotware. E.g. JDBC api is needed if a database connection is required in java.
From Wikipedia:
An API is implemented by applications, libraries, and operating systems to determine their vocabularies and calling conventions, and is used to access their services.
The purpose of a DLL (Dynamic libraries almost always offer some form of sharing, allowing the same library to be used by multiple programs at the same time).
In essence, the WINAPI
(Windows API) are all implemented in DLL files, such as mmsystem.dll
for MMSYSTEM Sound API.
References:

- 87,898
- 29
- 167
- 228
-
so APIs are functions that can be called and also APIs reside inside a DLL, is that correct?? – imahan Dec 06 '10 at 11:27
-
@imahan, yes...API are "skeletal" (for lack of better word) functions, that it's implementation is found inside a DLL. If you want to use the `MMYSTEM` Sound API in Windows, you will have to use the implemented API found inside the `mmsystem.dll` library else you're calling a skeleton method. – Buhake Sindi Dec 06 '10 at 11:45
An API is an interface for communication of different components of an application, where dll is a library file which contains code so that your program can use using your API

- 1
- 1
Every DLL has some (is an?) interface (API) because otherwise it would be useless, but not every API is a DLL as in example You can have Web Api where You are using remote endpoints using in example HTTP protocol - not even a file like in DLL case

- 57
- 8
A simplified answer.
API
is always (by definition) an application programming interface. It's a collection of methods that can be used as an interface to an app, a web service, etc.
DLL
is a shared library file of the same format as executable. It contains code and data to be shared between other EXEs so you don't have to recompile them every time a DLL is updated. DLLs, for example, allow you upgrade Windows versions and keep the applications running on the latest version. It may contain code that's reusable by one or more executables, like an API. One the other hand, it may contain only data, like icons (.icl) and fonts (.fon).

- 1,513
- 16
- 27