I was watching Ali’s instructional video on API recently, so I just made some notes.
- First of all, what is the API, our API here refers to the computer, but not elsewhere. API (Application Programming Interface, application programming interface) is some predefined functions , or refers to the agreement between different components of the software system. The purpose is to provide applications and developers with the ability to access a set of routines based on certain software or hardware without having to access the original code or understand the details of the internal working mechanism . API can be just a clearly defined interface that can provide specific services for other software. It can be as small as a small, that is, it can contain only a specific function, or it can be large, and it can contain hundreds of global functions, Method constants and so on. The implementation of the API can be shared or private.
- API classification:
In today's society, there are three reasons why people use APIs: 1. Quickly expand functions. 2. Improve development efficiency. 3. Reduce the degree of coupling between modules.
In the classification of APIs, mainly about Web API:
Regarding the content contained in the HTTP request, this can be found on the Internet, so I won’t say much here.
API request method, the so-called request method is to tell the server what action the client wants it to take. There are four common request methods, listed below:
Because the author is talking about the HTTP request mechanism, it is necessary to talk about the request header and request body of the HTTP protocol:
Request header: It provides the meta-information of the request. It is a simple list of items, including the time when the client sends the request, the size of the request body, and identity authentication.
Request body: contains the data that the client wants to send to the server.
For example, when we visit a web page, we are calling the API. After we successfully call the API, in addition to returning the information we need, it will also include a status code, and the processing success will return 2XX;
When we fail to call the API successfully, an error code will be returned. The server-side error code is 5XX, indicating that the service is unavailable.
The 403 error that we usually encounter on the web page is actually an API call error.
Reference: Error code table https://help.aliyun.com/document_detail/43906.html