blog posts

API

What is an API?

The API is used frequently in programmer conversations. It may confuse those who are new to the programming world. Given this, you may be wondering what an API is. What is its use? These are the questions that usually occupy the minds of novice programmers. And the bad news is that the Internet world is full of confusing information about it.

Suppose you need to view your bank account balance. So for this purpose, when you are behind a red light in your car, you use your mobile bank. You could do the same thing through the bank’s website. It does not matter which bank software you use to do this. In fact, you sent a request to your bank, and received a response, which is the amount of your balance. In both methods, the bank API is used to receive information.

API stands for Application Programming Interface. Simply put, an API is a part of a program that is responsible for providing information. After receiving a request for a software, it sends a response with the requested information to that software.

Differences between API and website

As you know, in general, the Internet is a collection of servers. The pages of different sites are located on one of these servers, which we call remote servers. From a specific perspective, the performance of these remote servers is very similar to it. In fact, you can turn your personal laptop into a local server. When you enter an URL such as https://ded9.com into your browser, a request is sent from your PC browser to the ded9 remote server. When the browser receives the server response, it translates and displays the HTML code inside it.

From a browser perspective, the ded9 remote server is an API. From this point of view, the browser itself is a client or user. This means that every time you enter an URL in your browser, you are using an API. Note, however, that the remote server is not an API. It is a program that runs on a part of a remote server computer. This program receives requests on the server and sends the answer in the form of answers to users or clients.

How the API serves users

You may have heard the names of sites that offer their services in the form of APIs to their users. For example, Instagram provides an API that allows programmers to access an account’s followers and other information. This helps developers use it to build applications such as follower and follower. Most of the world’s largest companies offer a variety of APIs to their users for a variety of uses.

Access APIs

Simply put, when a company provides an API to its users, it means that it provides one or more URLs that respond to user requests in response to relevant information. Of course, this does not mean that like a web page, these responses contain graphic information. This means you can even access information by entering URLs in your browser. It response is usually sent in JSON format. JSON information can easily be used in code by programmers. Consider the following example:

In this example, we use the ip-api site API and request information from a specific ip. This site has provided us with ip information. Keep in mind that usually how to use each API and how to request information from it in the API documentation is fully taught and provided to users. We said we can request information from any API by entering the URL.

Conclusion

Many applications and sites make one or more APIs available to developers to use their services in their applications. Telegram, for example, has provided an API for developers to write Telegram robots. Instagram has also introduced a type of API that is used to write unfollow and like apps. Using the it, developers can send a request to the URL provided by the application to receive information and receive the desired information via a response message.