Explaining APIs

Objectives
After completing this lesson, you will be able to:

After completing this lesson, you will be able to:

  • Explain what APIs are and why they are needed
  • Outline the benefits of APIs
  • Describe the anatomy of APIs

Business Introduction to APIs

You may face some challenges when transforming your business to an intelligent, sustainable enterprise. For example, you need to integrate applications and business processes in a diverse landscape of cloud-based or hybrid-based systems. You also have solutions from non-SAP suppliers, in which case, you need to integrate from SAP to non-SAP processes. You can use the SAP Integration Suite to integrate SAP to SAP processes, and non-SAP to SAP. Your company can also commercialize and manage your APIs through the SAP Integration Suite.

APIs Overview

Application Programming Interfaces

API is an acronym for "Application Programming Interface". It’s the mediator (represented by a piece of software) between applications/websites and you as a user. Therefore, it is vital for communication between different instances to exchange information.

You encounter APIs in everyday life without you realizing it. An example is Google Search: Every time you enter something into the search bar, Google's backend service looks up your keywords in its database and lists your request's results on the website. Actually, the website displays the API's result. An indicator for this is the URL of the respective search.

When thinking of a search for "SAP", the URL states: www.google.com/search?q=sap.

Now let us slice this one down:

Here www.google.com is the server address, /search indicates the feature you intend to use or better the API you want to call, which in this case is the Google Search API, and q (for query) tells it that now a value for query is handed over, which is the search term.

The same applies to SAP's help page (https://help.sap.com). When entering API into the search bar, the following URL comes up: https://help.sap.com/docs/search?q=api.

However, an API call doesn't necessarily have to be initiated by a computer. Voice assistance systems are also an example of the integration and use of APIs. Asking your voice assistant to search for something actually provides the assistant with your query. This query is then stored as text and added as the query to the API call. Afterward, the assistant gives out the API’s result via audio voice.

So, no matter what you do with any of your connected devices, you are using several APIs per hour without noticing. This is why APIs are such an important topic, because they are omnipresent and enable users and developers to focus on "what" needs to be done and not "how". Or have you ever thought about how your WhatsApp message gets sent to a recipient?

Therefore, as the name suggests, an API is just one of many types of interfaces used to trigger specific functions, for example, playing music. You might already be familiar with other types of interfaces, such as GUI (Graphical User Interface), which we use to navigate across applications/websites with the help of a mouse/touchscreen.

Benefits of APIs

The Need for APIs

APIs are indispensable for IT architectures nowadays. Although access from frontends to backends, interface management, and point-to-point communication have been substantial parts of IT architectures for years, APIs have revolutionized how applications and websites communicate. Therefore, APIs have brought many benefits to building and managing IT landscapes. The most important ones, and therefore key reasons why companies need to implement them in their IT architecture, can be summarized as follows:

APIs, at their core, separate communication from the task. Thus, if a service communicates through an API, the user (or consumer) of the API is entirely focused on the features the API provides. The user only uses the API’s features without thinking about the job itself. The focus is based on the request and the result (response) and nothing else.

Anatomy of APIs

API Types

For defining and implementing APIs, different global standards are available for use. A few of these are listed below (however, the most commonly used are REST APIs):

With REST APIs as the most popular API type, we will briefly dig a little deeper into REST APIs functions. When working with APIs, you usually speak of resources. This means that typically you either want to:

  • create something (like adding a new entry to a guestbook)
  • read or get something from the API (remember your Google Search: here you tried to get a list of websites)
  • update or change something (usually when you have created something which needs to be changed, like the status of something or if you made a typo)
  • delete something.

Together these actions are abbreviated as: CRUD.

For REST APIs these verbs are very similar to:

CRUDREST
READGET
CREATEPOST
UPDATEPUT / PATCH
DELETEDELETE

You may notice that "update" has two possible verbs: PUT & PATCH.

Patch only changes a part of the resource you are referring to. Think of your guestbook entry, where you correct one word only and would inform the guestbook that word number 42 needs to be swapped. This would be a patch - a spot on repair or change. PUT, on the other hand, would be changing the whole text, even if it is mostly the same but with the error corrected (think of clearing the whole text and pasting everything in again).

Usually, when looking at an API's specification, these verbs are displayed as illustrated below (retrieved from an example deployment on the SAP BTP Integration Suite). An API does not necessarily support all verbs.

Save progress to your learning plan by logging in or creating an account