API和SDK有什麼區別?


191

當我意識到我無法真正分辨APISDK之間的區別時,我正在瀏覽各種API和SDK。

從概念上講,這兩種方法都是程序與另一軟件(包括其他軟件是Web服務,最終用戶應用程序,OS服務或守護程序)交互並控制另一軟件提供的資源的一種方式,或內核設備驅動程序。

那麼,SDK和API在語義上有什麼區別?

188

I think it rather falls along the lines of "All SDKs are APIs but not all APIs are SDKs".

An SDK seems to be a complete set of APIs that allow you to perform most any action you would need to for creating applications. In addition an SDK may include other tools for developing for the platform/item that it is for.

An API on the other hand is just a series of related methods that may be good for a specific purpose.

As an example, the JDK (Java Development Kit) contains the API as well as the compilers, runtimes, and other miscellaneous tools. The Java API is simply all the libraries that make up the core language that you can work with out of the box.


7

An SDK could be nothing but an API (files to help interface with another app), but usually includes other code to help with debugging and other pieces for your IDE.

I'm all out of acronyms.


93
  • API = Application Programming Interface
  • SDK = Software Development Kit

So the real difference is: an API is no more nor less than an interface to "some service", while an SDK is a set of tools, components and/or classes for a specific purpose. An SDK in fact presents you with an API to interface with. But you might use an API without having the underlying components, for example when the API is provided through a web service.

Examples of APIs:

Examples of SDKs:


5

Everything mentioned before is true, but about SDK I would like to add that a software development kit is (or should be) a really complete package with (almost) all the necessary tools for the development process, while API is "just" an interface to interact with.


19

"SDK" is collective in a larger sense than "API".

You typically find only one SDK to cover an entire platform. There's one MacOS X SDK and one iOS SDK, for example, and those each contain the API's for many different areas of functionality.

"API" was originally used as a collective term as well, and it's still often used that way (MAPI, WSAPI, etc.), but it's usually limited to some particular technology. The scope implied by the "API" seems to have diminished over the years; people used to talk about the "Mac Toolbox API" or the "Windows API," both of which obviously contained a lot of functionality. These days, it's not uncommon to hear "API" used to mean a single system function; a new version of an operating system might be said to contain hundreds of new API's, and what's meant is hundreds of new system calls.

Neither term is very precise without some context.


26

API → documented interface (at a certain point in time, and for a certain audience. Documentation might be incomplete and/or unavailable to the general public and this might be on purpose, but this does not dimish the fact it was meant to be documented for third parties to use it.)

SDK → interface documentation ( + examples & tools )


15

What is API?

API is an interface that allows software programs to interact with each other. It defines a set of rules that should be followed by the programs to communicate with each other. APIs generally specify how the routines, data structures, etc. should be defined in order for two applications to communicate. APIs differ in the functionality provided by them. There are general APIs that provide library functionalities of a programming language such as the Java API. There are also APIs that provides specific functionalities such as the Google Maps API. There are also language dependent APIs, which could only be used by a specific programming language. Furthermore, there are language independent APIs that could be used with several programming languages. APIs needs to be implemented very carefully by exposing only the required functionality or data to the outside, while keeping the other parts of the application inaccessible. Usage of APIs has become very popular in the internet. It has become very common to allow some of the functionality and data through an API to the outside on the Web. This functionality can be combined to offer an improved functionality to the users.

What is SDK?

SDK is a set of tools that can be used to develop software applications targeting a specific platform. SDKs include tools, libraries, documentation and sample code that would help a programmer to develop an application. Most of the SDKs could be downloaded from the internet and many of the SDKs are provided free to encourage the programmers to use the SDK‘s programming language. Some widely used SDKs are Java SDK (JDK) that includes all the libraries, debugging utilities, etc., which would make writing programs much easier in Java. SDKs make the life of a software developer easy, since there is no need to look for components/ tools that are compatible with each other and all of them are integrated in to a single package that is easy to install.

What is the difference between API and SDK?

API is an interface that allows software programs to interact with each other, whereas a SDK is a set of tools that can be used to develop software applications targeting a specific platform. The simplest version of a SDK could be an API that contains some files required to interact with a specific programming language. So an API can be seen as a simple SDK without all the debugging support, etc.


-3

I would like to compare this way.

If you are a Developer using Microsoft Tools:

API = Microsoft.Net Framework Vs SDK = Visual Studio

If you are a Developer using Java:

API = Java RunTime Vs SDK = Any tool that would provide the Development Kit (JDK)

I guess an SDK would necessarily have to rely on a corresponding API - there is no SDK without an API.


-3

Here is a simple analogy... APIs are like words that you can use, and SDKs are like sentences that have been put together for you.


-4

As applications are developed and enhanced by interfacing them with other applications there is a need to allow other applications (logic) to interface with the core logic - this is done via a defined set of APIs. SDK is used to create / craft code that uses APIs to interact with other applications.


1

My two cents: I believe the term API is often used incorrectly.

An API is an Application Programming Interface.

Although kind of an awkward name, it means it's an interface. So an application might have an API to allow other applications to communicate with it. And a piece of software (e.g. a class in an OO system) might offer an API to allow other modules in the system to communicate with it.

However often the term API is used as a synonym of "library". I don't think that's a correct use of the word. Part of the library is an API to allow code to use it, but the library isn't an API.

And an SDK is a kind of library, so that's where the confusion might be.


1

Lots of the other answers explain that an SDK is tooling, but none of them directly comes out and says that an API is a specification.

The API for compoonent X is all the information that you need in order to write some other component that will interact with X. An SDK for component X may contain library routines that make it easier for you to write that component, but the libraries are not the API: They are merely an embodiment of the API.