An application programming interface, or API, is a concept that enables and simplifies communication between software programs. It defines the way and format in which data can be extracted from or sent to an application.
What are Application Programming Interfaces used for?
An API enables communication between different programs and applications by allowing information to be sent, requested, deleted, or modified.
This structure makes it possible to modularize complex software applications by making individual program parts self-contained and then communicating with each other via a programming interface. This means that the individual functionalities of the code are clearly separated from each other and can be easily exchanged or changed.
Docker containers, for example, are based on this principle. These containers can be started on different computers in a cluster and execute individual sections of code. To turn this into a functioning application, they receive data from other containers and send their own results to downstream containers via APIs.
Which Applications use APIs?
We already encounter programming interfaces in many places. For example, calling up a website is nothing more than querying an application programming interface on the provider’s web server. It is therefore not surprising that many websites offer APIs with which you can access their data. Such an interface for data retrieval is offered, for example:
- Google Maps
By offering APIs, websites also protect themselves from so-called web scraping. For many users, it is interesting to automatically read information from a website. If the provider does not offer an interface for this, it is not uncommon to resort to scraping the website. To do this, a bot calls up the page and reads it out within a few milliseconds. This can result in immense loads for the website and thus a loss of performance.
In the e-commerce environment, for example, an interface to Paypal is used to be able to offer the customer this payment option. There is a defined structure for how the store can send data to Paypal. This means that this payment option can be integrated quickly and easily into various e-commerce stores.
Online weather information sites also rely on the use of programming interfaces to provide their service. Websites, such as wetter.com, offer the possibility of retrieving a weather forecast for almost any location in the world. Providing the information is not entirely straightforward, as it involves consulting various regional weather services and collating their data centrally.
Application Programming Interfaces are used to standardize this process. This allows websites to receive regional data automatically and in a predefined data structure.
What are the Types of Programming Interfaces?
Basically, there are different ways to divide programming interfaces into groups. Most frequently, APIs are differentiated in terms of their accessibility, i.e. who is granted access to the data. A distinction is made between the following three types:
- Internal API: These are programming interfaces that are intended exclusively for use within a company. They are not visible to external users, and certainly not retrievable. For example, data from the internal Customer Relationship Management (CRM) tool can be accessed by the sales department via an API. Under no circumstances should this sensitive information be allowed to reach outsiders.
- Partner / Customer API: These programming interfaces hold data that should be accessible to a selected group of people. Authentication plays an important role here, as it ensures that a user is actually authorized to view the information. Some online stores, for example, offer the option of retrieving the customer’s own orders or delivery information via API so that the customer can use it in his own environment. In these applications, it must be ensured that each customer sees only the orders associated with their customer number.
- Public / Open Source API: Application Programming Interfaces of this type are available to the public via the Internet. The data is of general interest, which is why the operator provides public access. However, depending on the usage, fees may be charged for data off-take to maintain the infrastructure provided. Public APIs include, for example, the Google Maps interface.
In addition to distinguishing by accessibility, some sources also use interface orientation to create different groups:
- Function-oriented: Interfaces from this group enable a program to gain direct access to the hardware of a device to enable special functions there. For example, requests can be made for components of the hardware via the operating system API.
- File-oriented: This allows requests that access the hard drives of the computer and allow specific files or directories to be output. Access permissions are managed through the operating system.
- Object-oriented: In many programming languages, as in Python, complex applications are divided into different classes. Object-oriented interfaces allow communications between these classes, also called objects, and are much more flexible than function-oriented interfaces.
- Protocol-oriented: Protocol-oriented application programming interfaces are completely independent of operating systems and hardware because they work using protocols and libraries.
What are the Advantages of APIs?
There are countless advantages that can be realized with the use of programming interfaces. A large part of them can be summarized by the fact that, with the help of interfaces, applications are no longer as error-prone, are much easier to maintain, and thus require less expensive infrastructure. We will explain how these advantages come about in the following sections.
Application Programming Interfaces enable the modularization of software applications, such as Docker uses. For this purpose, the complete application is rewritten into smaller subtasks so that this part can run autonomously. Communication with upstream and downstream process steps works exclusively via application programming interfaces.
On the one hand, this offers the advantage that computationally intensive process steps can be switched to more powerful computers and others to less expensive components in the cluster. In addition, the overall application is very error-resistant. As long as all individual components receive the correct inputs via an interface and output the correct outputs via an interface, the overall program functions without problems.
This architecture makes it easier to maintain the sub-applications, renew them or even replace them with completely new systems.
How does a REST API work?
The content we see on the Internet is based almost exclusively on API queries. In the early days of the Internet, the Simple Object Access Protocol, or SOAP for short, was used for this purpose, which sent XML documents. At the beginning of the 2000s, however, the REST interfaces (Representational State Transfer) became established as the basis for web services.
The problem points with the use of SOAP were that strict specifications had to be observed for server communication and the handling of XML is also rather cumbersome. REST, on the other hand, uses much clearer JSON files. In addition, it offers flexible formatting and is very performant in data transfer, which plays a major role in today’s web.
This is what you should take with you
- An application programming interface, or API, is a concept that enables software programs to communicate with each other.
- They are used, for example, in the construction of websites.
- The use of such interfaces is advantageous because it allows programs to be modularized.
What is Apache Airflow?
Apache Airflow explained with architecture and application examples.
What is Apache Kafka?
Structure of Apache Kafka explained with possible fields of application.
What is the Star Schema?
Description of the star scheme compared to the snowflake scheme.
What is Apache Spark?
Explanation of Apache Spark with a comparison to Hadoop.
What is a Database Schema?
Explanation of database schemas by example.
What is Presto?
Explanation of Apache Presto compared to Apache Spark.
OLTP: What is Online Transaction Processing?
Explanation of OLTP including its features and differences from OLAP.
Overview of important SQL commands
Common SQL commands explained with the help of examples.
OLAP: What is Online Analytical Processing?
Introduction to Online Analytical Processing with an explanation of the OLAP Cube.
What is a YAML File?
Explanation of YAML files and their use in Python.
Other Articles on the Topic of API
- There is more information about Application Programming Interfaces on the AWS site.