API in Mobile Development: What It Is and What It's For in Simple Terms
Find out what API for mobile application development is, how it works, and why and how you should start implementing it now.
Join the DZone community and get the full member experience.Join For Free
At present, IT is one of the most rapidly developed industries. The process of development is always an accumulation of a great amount of knowledge, which must continuously be generalized and systematized. The process of systematization, in its turn, results in the expansion of basic vocabulary.
Why is this important to mention? The wider the basic vocabulary is, the more difficult it is to delve into the details for a person who does not belong to the industry.
Everything is clear with techies (contractors). They work with technologies and use the terms constantly since it significantly speeds up communication within teams. For a businessman (a client), all these buzzwords raise only additional questions of the following type:
Why is this necessary?
Why does it cost so much?
Can we do without it?
We often face questions, which can be qualified as typical. One of them is "Why do we need API for a mobile application?"
To make the understanding of this issue easy, let’s discover what API (Application Programming Interface) is by using simple terms that are easy to understand. We’ll find out what functional tasks it has and why a mobile app cannot do without it.
The interface is the best word to start with when dealing with the notion of API. The interface is a primitive concept, which has a wider meaning. To make things simple, let’s not delve into the engineering and software aspects, but let's turn to the general topics.
Answer this question: What functional tasks does the automobile perform?
Most likely the first thing that will occur to you is moving a person from point A to point B. In general, it is really the basic function of an automobile; transportation of some things or earning money is a minor possible feature.
The second question: What makes the vehicle move, speed up, and slow down?
Not going into too much detail, we can say that an automobile as a means of transportation consists of multiple interconnected components. At the upper level, there are 3 components: the body, the understructure, and the engine. Each of these components in its turn consists of the more narrowly specialized devices and mechanisms, which work hand in hand with each other. As a result, we get what we need from the vehicle.
A modern car is rather a serious engineering solution, however, a driver does not need necessarily to deal with all these; it is simply hidden from view. As you now understand, it is hidden behind the interface ☺
You’ve understood right, the steering wheel, foot throttle, gearbox, climate control equipment, and even your favorite car stereo are parts of the interface, which are provided to the driver to manage all of this complexity.
Interfaces are quite common in our life. Take a look at the following:
- A person operating some machine has various controls, buttons, a display, and so on at his disposal.
- You switch the TV channels with remote control.
- You use the voice dial on your smartphone.
- You play video games with a joystick.
- You play the piano, even so!
Taking into consideration the examples above, let’s try to find a definition of this notion.
Interface — It is a border between two systems, which is a set of rules, methods, and restrictions regulating how the systems interact with each other.
If we continue with the automobile example, two systems can be identified: a man and a vehicle. The latter sets certain rules, which allows a man to operate it following the rules.
API and RESTful API
Having dealt with the basic component of the term, let’s continue to decipher the two remaining words — Application Programming. The name itself hints that the term belongs to the software sphere. If compared to the automobile, we can come to the conclusion that API stands for 2 systems and the rules. The systems, in this case, are programming modules, web services, and so on.
In fact, we could have finished with API at this point, but not to mention RESTfull API will be wrong. The matter is that API describes a phenomenon. The RESTfull API (or simply the REST API), in its turn, is one of the approaches to implementing API for mobile application development.
It’s essential to understand this since API is often used in communication for short, but it’s supposed to be realized by means of RESTfull API.
Having now been armed with knowledge about what an interface is and even having touched a bit more narrowly the specialized term RESTfull API, we can easily answer the main question:
Why does a mobile app need API?
Let’s start with anatomy. A mobile application consists not only of the visual part — UI- user interface, but a number of questions should be solved in the course of mobile development. They may include questions on where to store the information about the users, the messages, the orders, etc.
The solution should also have certain functions like accepting payments, authorizing the user, sending SMS during the registration, or sending PUSH notifications when an event occurs.
There are plenty of tasks, but which one (or maybe all of them) is the reason to create API for a mobile app? The answer is none. It can all be realized without an API within a single smartphone.
In fact, the major cause is the multi-user nature of a mobile app. As soon as more than one user appears, the problem of data sharing sets in.
Imagine a situation when a user changes their name. If the data were stored only on their smartphone, another user would not be able to know about the change.
Except for data sharing, there are other problems such as, what should be done if the smartphone is lost or reset, and how do you cope with hundreds of devices’ support?
All of these problems are solved through the business logic centralization and, to access it, API is designed (to be more precise — RESTfull API, as we know already).
SMS aggregators can also be taken as an example; their main function is to send SMS. The developer, in this case, does not need to delve into the whole complexity of mobile networks, but all they need to do is to integrate an app with an SMS integrator and call the necessary API for sending.
To perform its functions, a mobile app turns to the external server, which centralizes the whole business logic (it’s also called Backend).
API is necessary to access the server, meaning a certain set of rules is needed, which will allow the client and the app to be precise and access it.
Practically, it looks like this; you want to make an order, for instance, your iOS or Android app will then send a command to the server with the help of API to create an order. The server will fulfill the request and save all the info into the database. Therefore, the information about the order will be available to the other users.
Hope this article will help you let go of the question of API once and forever.
All the best!
Published at DZone with permission of Oleksandra Liubytska. See the original article here.
Opinions expressed by DZone contributors are their own.