What is API?

In the field of software development, the term API is often heard, but most beginner programmers are not very familiar with the nature of this term, in this regard, in this post, we intend to learn in detail about the nature and operation of API, but first of all, we need a We have an introduction.Before the pervasiveness of computer systems in various industries, humans were considered to be the ones who were supposed to have the most interaction with computer software, so that regardless of what the software was doing, from editing images to sending emails, etc. Man was the center of attention as the entity that was supposed to work with the said software, so that he interacted with the software through the User Interface or UI for short (just as, for example, today, through the user interface of the desktop environment of the operating system, various tasks are performed we give.)With the passage of time and the advancement of technology, this need was felt so that instead of human interaction with software, the software itself could interact with each other without human intervention, and this was despite the fact that a computer system, unlike humans, did not have eyes and ears to see. The user interface can, for example, click on a certain button to get the desired data, in addition to the fact that a software, like humans, did not need to have a beautiful and user-friendly user interface (UI) to communicate with another software, and this is where the concept of API came into being. Formed.API stands for Application Programming Interface, which can literally be translated as “software programming interface”. In short, an API is like a UI, except that instead of humans, a computer system is supposed to interact with it. In fact, since the word Interface can be translated as “interface” in Farsi, it can be said that API is an interface between two software or applications (it is necessary to explain that in this discussion words such as software, application, system, etc. .. can be used interchangeably and do not have a specific semantic difference.)To better understand this issue, let’s consider something like electricity in such a way that electricity can be considered as a service that is provided to us through an electrical outlet rather than powering a laptop, a fan, a vacuum cleaner and anything that is needed for work. need to provide electricity.If we want to make an analogy in this regard, a service like Elektriste is like the same service that a software company like Google provides us; For example, it allows us to access Google Maps data. Now, the mobile application that we have designed has the same role as a laptop, fan or vacuum cleaner, which in the previous example needed electricity to work, but in this area, this application needs Google Map data to work.To clarify this modification, we will first give an example of the API of the Windows operating system. Suppose we are a developer who plans to write a desktop software for the Windows operating system, which does not need to be explained. One of the parts of the software is its user interface (UI) which is exposed to the user through different windows.Let’s assume that the Microsoft company did not offer a dedicated Windows API for developers interested in developing software for this operating system, in such an environment, every developer would be forced toand to design windows according to his own taste, and this issue would lead to the loss of the apparent integrity between different software, but this is while Windows has something called Windowing API, which is an SDK that has the task to It handles all the issues related to the appearance of a window, such as the close button, resizing the window, etc., and developers only need to specify things such as the initial size, title, and contents inside the window, and leave the rest of the settings to the API (in You will get to know the concept of SDK further.)Such an event is called the Layer of Abstraction, so that the Windowing API of the Windows operating system is an abstraction layer that is placed between the developer and the operating system so that the developer does not get involved in technical issues, thousands of lines of code that are needed to create a simple window, etc. and implement your needs with just a few lines of simple code (in the example of electricity supply, there is exactly this abstract layer in such a way that we, as humans, only deal with the electrical outlet and what happens inside the outlet, the phase wires and What color the zeros are, how the energy comes from the electrical post to the meter head, and… has nothing to do with us.)Now that we are familiar with the concept of Layer of Abstraction, there is no need to explain that if the Ministry of Energy changes the infrastructure, instead of the electricity coming from the dam, it will introduce the electricity from the combined cycle power plants into the electricity transmission network or the equipment placed inside the substations. Renovate electricity transmission and such works, as long as the energy needed by homes is provided, all these changes will not make any difference to the consumer.In the field of software development, let’s say that the service that we, as a developer, used to use the related API with Java language was on Amazon’s AWS servers, but the said company decides to rewrite it with Node.js and offer it on Microsoft’s Azure servers. In such a situation, as long as the so-called Endpoint related to that API does not change, it will not make any difference for developers.In the same way, API provider services such as Google or Facebook can easily upgrade their servers as long as they do not change their standards and do not disrupt the work of developers who previously used their services. physically change their data centers, switch between different cloud services, etc.For example, suppose there is an application named “A” whose developer has made it possible for other developers to use its API. Now let’s assume that we have written an application under the title “B” while the application “A” in a certain framework allows the application “B” to use the facilities it has (by visiting the ProgrammableWeb site, you can see a comprehensive list of APIs). Get various services offered by prominent companies such as Google, Facebook, Twitter, etc.) At the same time, while using API, a series of standards must be considered, some of the most important of which are:– The data exchanged through the API is structured: in other words, the request from software “B” is made in the framework of a standard format that is already defined by the developers of software “A”. – The result of interacting with the API is predictable: in fact, the requests that are sent to the “A” software must be in a specific framework, and therefore the response to such requests will always be clear and predictable.