In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "what is the difference between API and SDK". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The first thing we need to understand is that API is related to communication and is a protocol defined by the dialogue between applications (services) and other applications (services). In the above example, you can simply understand that API is a bridge between OCR applications and cloud services.
So what exactly is API?
The full name of API is Application Programming Interface, that is, "application program interface".
It generally refers to some predefined functions that provide applications and developers with the ability to access a set of programs based on some software or hardware without having to access the source code or understand the details of the internal working mechanism.
Take Java as an example, when you want to implement an array sorting function, do you write a sorting algorithm first, or do you directly use the Arrays.sort () function? I think you have the answer in your heart.
Abstract
Second, we need to understand that another important feature of API is abstraction.
What does abstraction mean?
Take this OCR application as an example, when we use the text recognition capabilities provided by the cloud (such as Baidu character recognition), there may be thousands of codes behind it, such as machine learning code that provides recognition capabilities, back-end codes that provide Web capabilities, and so on.
But as a developer of APP, do you need to see how the code is written? Don't you know the source code behind it can't call the character recognition ability provided by Baidu? Of course not.
Usually, the service provider has provided you with documentation telling you how to invoke the service, as long as you follow his request.
Therefore, between your APP and OCR services, API abstracts all the complex logic and simplifies the invocation process, which makes you only need to think about getting the data you need.
Standardization
API is standardized, which means that there are industry standards on how to define API, such as SOAP, REST, GraphQL, and so on.
I wrote about what RESTful API is in "your first SpringBoot Book" [1]. Interested friends can click to read it. This is an introduction to SpringBoot that I am working on. It is not finished yet. Readers are welcome to give their own suggestions.
Constituent elements of API
So what does API usually consist of?
First, we need to send some data to the cloud, the so-called "request".
We need to complete the request from the local application to the cloud in several steps, taking REST as an example.
For a REST API call request, the first step is to specify the transfer method, which usually corresponds to the HTTP method, as shown in the following figure:
When you want to upload an image, you usually use the POST method, and then pass some parameters, including the content of the request (the image itself). Then add the address that needs to be requested to form a complete request. As shown in the following figure:
After that, the server will return the data to you in the form of JSON, which will also be noted in the documentation of the cloud service you use.
SDK
With all that said, you should know something about API, so the question is, as a developer, how do you call API in an actual project?
You have to construct the HTTP request, concatenate the URL, add the required parameters, and deal with the returned JSON object. Is it troublesome?
Trouble.
Is there any good way to simplify these operations so that I only need to give a picture and return the results to me?
Of course there is, and this is what we're going to talk about SDK.
The full name of SDK is Software Development Kit, which is a software development kit.
Generally speaking, it is a collection of development tools for some software engineers to build application software for specific software packages, software frameworks, hardware platforms, operating systems, etc.
Generally speaking, it is the toolkit provided by the third-party service provider to realize a certain function of the product software. For example, JDK is a kind of SDK.
Take the above OCR application as an example, if we use a vendor's SDK service, then we do not even need to build the HTTP request, only call a method, the possible code is shown in the following figure.
OCRResult res = ocrClient.ocr ("pic.jpg") .getResult
By calling this line of code, SDK automatically encapsulates the API request, and in response, the result you get may not necessarily be a JSON object, but it may also be code, such as OCRResult in the above code snippet, because SDK has also deserialized the JSON object into the object you need, such as a Java Model.
SDK is equivalent to the development of integrated tool environment, and API is the data interface. API can be requested in the "environment" provided by SDK. Similarly, the "environment" here is an abstract concept. If you don't use SDK, you can call API directly, but it's up to the developer to implement the environment.
Difference
In fact, we have learned from the above that API is more like a subset of SDK in more situations. The differences between them are as follows:
API is usually a function with specific functions, while SDK is a collection of many functional functions, more like a toolkit. API usually acts as a data interface, and SDK is equivalent to a tool environment, usually calling APl in the context of SDK. SDK has a higher level of encapsulation than API.
This is the end of the content of "what's the difference between API and SDK". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.