Introduction
Application Programming Interface (English: Application Programming Interface, abbreviated as: API), also known as Application Programming Interface, is a convention for the connection of different components of a software system. Due to the increasing scale of software in recent years, it is often necessary to divide complex systems into small components. The design of programming interfaces is very important. In the practice of programming, the design of programming interface must first reasonably divide the responsibilities of the software system. A good interface design can reduce the interdependence of various parts of the system, improve the cohesion of the constituent units, and reduce the degree of coupling between the constituent units, thereby improving the maintainability and scalability of the system.
Purpose
The main purpose of the API is to provide applications and developers with the ability to access a set of routines without having to access the source code or understand the details of the internal working mechanism. The software that provides the functions defined by the API is called the implementation of this API. API is an interface, so it is an abstraction.
Principle
During data encapsulation, each layer in the network layer will interact with each other and provide services through an interface. The interface between the application layer and the user is called It is the Application Programming Interface (API, Application Programming Interface). API is actually a collection of functions, which can also be said to be a collection of definitions and protocols. Regardless of that collection, its essence is to shield users from implementation details and complexity through abstraction.
From the user's point of view, the application program interface is represented as a series of API functions. Users can use these functions for network application development. From a network perspective, the application program interface provides users with a set of methods. Users can use this set of methods to send service requests, information, and data to the application layer. Each layer in the network responds in turn, and finally completes the network data transmission.
Program introduction
As the scale of software becomes larger and larger, it is necessary to divide complex systems into small components, and the design of programming interfaces is very important. In the practice of programming, the design of the programming interface must first allow the system's responsibilities to be reasonably divided. A good interface design can reduce the interdependence of various parts of the system, improve the cohesion of the constituent units, and reduce the degree of coupling between the constituent units, thereby improving the maintainability and scalability of the system.
The main purpose of the API is to provide applications and developers with the ability to access a set of routines without having to access the source code or understand the details of the internal working mechanism. The software that provides the functions defined by the API is called the implementation of this API. API is an interface, so it is an abstraction. A reference implementation of an API is the implementation created by the designer of the API, or one which other implementations of the API are expected to be compared against.
For example, a set of API definition calls in the graphics library The way to draw icon functions to display icons on the screen. Called in the program, connected to this group of APIs when compiling, and calling the implementation (library) of the API to display the icon when executing.
System classification
The API of the operating system can be used to allocate memory or access files. Many systems and applications provide API interfaces and implementations, such as graphics systems, databases, networks, Web services, and even certain games.
A set of APIs is often part of a software development kit (SDK). SDK can also include other tools or hardware. The two terms are not completely equivalent.
API is divided into system-level APIs (for Windows, Linux, Unix, etc.) and non-operating system-level APIs. Custom API. As an effective code encapsulation mode, the API development mode of Microsoft Windows has been used by many commercial application development companies for reference, and some commercial application system API functions have been developed and released to facilitate third-party extensions. Such as APIs developed by Google, Apple Computer, and Nokia and other mobile phones.
API has many different designs. Interfaces for fast execution usually include functions, constants, variables, and data structures. There are also other ways, such as through an interpreter, or providing an abstraction layer to hide information related to the implementation of the API, to ensure that the code that uses the API does not need to be changed to adapt to the implementation change.
API: Application Program Interface (API: Application Program Interface) Application Program Interface (API: application programming interface) is a collection of definitions, procedures and protocols, through the API interface to achieve mutual computer software Communication. One of the main functions of the API is to provide a common set of functions. Programmers develop application programs by using API functions, which can avoid writing useless programs to ease programming tasks. API is also a kind of middleware, providing data sharing for various platforms. According to the data sharing performance between different software applications on a single or distributed platform, APIs can be divided into four types: Remote Procedure Call (RPC): The process (or task) that acts on the shared data buffer is used to achieve inter-program communication. Communication. Standard Query Language (SQL): It is a standard query language for accessing data, which realizes data sharing between applications through a general database. File transfer: File transfer realizes data sharing between applications by sending formatted files. Information delivery: refers to small formatted information between loosely coupled or tightly coupled applications, and data sharing is achieved through direct communication between programs. The standards currently applied to APIs include the ANSI standard SQL API. In addition, some other types of standards are still under development. API can be applied to all computer platforms and operating systems. These APIs connect data in different formats (such as shared data buffers, database structures, file frames). Each data format requires different data commands and parameters to achieve correct data communication, but at the same time different types of errors will be generated. Therefore, in addition to the knowledge required to perform data sharing tasks, these types of APIs must also solve many network parameter problems and possible error conditions, that is, each application must know whether it has strong performance to support inter-program communication. On the contrary, because this API only deals with one information format, the information delivery API in this situation only provides a small subset of commands, network parameters, and error conditions. Because of this, the API delivery method greatly reduces the complexity of the system, so when the application needs to share data through multiple platforms, the information delivery API type is an ideal choice. API is distinct from graphical user interface (GUI) or command interface: API interface belongs to a kind of operating system or program interface, while the latter two belong to direct user interface. Sometimes companies use APIs as their public open system. In other words, the company develops its own system interface standard. When operations such as system integration, customization, and program applications are required, all members of the company can call the source code through the interface standard. The interface standard is called an open API. .
Common Application Program Interfaces
There are many application program interfaces in the application layer, and they are developing rapidly, such as socket, FTP, HTTP and telnet. These interfaces can be divided into four categories:
Remote Procedure Call Protocol (RPC)
Data query interface
File interface
Data communication interface
Socket is sometimes called "Berkeley Socket". It is the first application program interface developed by Berkeley. There are two commonly used socket types: streaming socket (SOCK_STREAM) and datagram socket (SOCK_DGRAM).
Streaming socket is a connection-oriented socket for connection-oriented TCP service applications.
Datagram socket is a connectionless socket, corresponding to the connectionless UDP service application.
In the sense of user interface, there is also the TLI interface of the transport layer, which was developed by AT&T and is sometimes called XTI. It is an application program interface provided by the transport layer for users and can be used for application development at the transport layer.