API (abbreviation for Application Programming Interface) is an application programming interface that allows services to interact, access, and exchange data.
In essence, the API acts as an intermediary between two applications or services - it provides solutions (classes, functions, structures) implemented in the one service, and creates an environment for creating a new application using these solutions.
Explanation for dummies: for example, the set of commands that a dog is trained to use is an API. If we know these commands, we can easily interact with the dog (it understands what we want from it) and train it. If we do not have access to such an API, we will have to re-train the dog in commands (which will take a long time and success is not guaranteed), or it will simply not execute our commands.
An example of using the API that is familiar to most Internet users is registering on a site using a social network account. Thanks to the API, a site can connect to the social network database and get the information it needs.
The most common on the World Wide Web is the so-called Web APIs, which are used as a platform for creating HTTP services. Among them are:
- RPC (Remote Procedure Call) - remote procedure call,
- SOAP (Simple Object Access Protocol) - a simple protocol for accessing objects,
- REST (Representational State Transfer) - transmitting the state of a presentation.
API can be divided by the type of service that they have: applications, websites, and operating systems. For example, most operating systems (Unix, Windows, macOS, etc.) have an API that makes it possible to program services for these systems.
Also, the API can be divided by type of access:
- Internal APIs (available to the company's internal developers and employees, used to optimize workflows and reduce costs),
- Partner APIs (available to business partners and consumers of the product or service, used to optimize processes and development),
- Public APIs (available to everyone, used to create new services and promote the existing direction).
Pros and cons of working with the API
There are many advantages to using the API:
- The main advantage of working with the API is saving time when developing your own services. The programmer gets ready-made solutions and does not need to spend time writing code for functionality that has been implemented for a long time.
- The API may take into account nuances that a third-party developer may not take into account or simply may not know
- The API gives applications a certain consistency and predictability - the same function can be implemented in different applications using the API in a way that is clear and familiar to all users.
- The API gives third-party developers access to closed services.
But there are also disadvantages:
- If changes and improvements are made to the main service, they may not be immediately available in the API,
- Ready-made solutions are available to the developer, they don't know how they are implemented or what the source code looks like,
- APIs are primarily intended for general use. it may not be suitable for creating any special functionality.
Using the API in practice
The most common ways to use various APIs by developers and companies around the world:
- Adding to their services the functionality of social networks and instant messengers, currency calculators, weather, etc. A standard working solution that does not require months of programming.
- Access to a popular service or data warehouse in compliance with all security requirements.
- Internal needs of the company, for example, the development of a mobile application for the site, followed by the systematization of all data.
The API allows developers to use the existing functionality of one application to refine another. The users of the World Wide Web are most familiar with the functions implemented using social networking APIs:
- The Facebook API allows you to log in on third-party platforms using your account, pay for purchases in the application, gain access to the data of large and medium Instagram Business accounts, manage community pages and publish content on them, receive advertising statistics, manage ads and audience, launch live streams,
- Using the Twitter API, you can display the tweet feed on the site, manage the profile and account settings, automatically create and manage advertising campaigns on Twitter,
- VK API allows you to track user activity in communities, create bots, collect statistics on community actions, automatically moderate content, automate work with products (for example, import from an external database), receive text publications from VKontakte for given keywords, etc..,
- Telegram Bot API is an HTTP interface for working with bots in Telegram,
- The YouTube API allows you to embed a video on the site, create playlists, embed the player in the application, and receive data on user activity.
The following APIs are also popular:
Yandex API - all popular Yandex services have their own APIs (Webmaster, Yandex.Metrica, Direct, Market, Audience, Maps, etc.) that allow you to:
- get information about products presented on Yandex. Market and create applications for automated placement,
- Automate the creation of Metrica counters, setting goals, and getting statistics,
- create applications for managing advertising companies, automate the process of creating advertising campaigns and manage them through the interface of your own application,
- configure a variety of audience segments that can be used to serve ads,
- Use map data,
- publish train or plane schedules on the website or in the application,
- automate the creation and sending of delivery orders,
- embed a Yandex.Translate to a mobile app or web service for end-users,
- automate the validation of semantic markup, etc.
Google API - the company also provides developers with several dozen APIs for solving a variety of tasks:
- Working with Android devices and applications,
- Calendar Event Management,
- Manage your Google Shopping products and account,
- Manage files in Google Drive, including uploading, downloading, searching, changing permissions,
- View and manage Google Analytics data,
- Reading and editing files in Documents,
If we think of the API as a way to simplify the code, we can say that the jQuery library, written in the jаvascript programming language, is also a kind of API, because it offers developers a way to simplify the code several times (5-6 lines instead of 30).