What is an API (Application Programming Interface) - everything you need to know

Tien Nguyen

When you hang around with programmers, you might have heard about APIs and how they can be used to perform certain tasks and retrieve some data. But what are they exactly, and why were they created ?


What are APIs ?

The term API stands for Application Programming Interface, and it is a way for different programs to work together in various ways.

API is not a programming language. API functions are similar to other regular functions.

API has been around for a long time, used in many different types of applications and software. The latest generation of APIs - Web API can be used for any system (operating system, database, web-based system, application library, ..) even computer hardware.

Let's start with a really simple, non-IT related example. When you go to the restaurant to order some food, you interact with the waiter. You can order food and drinks, ask questions about the menu, request and pay the bill. In this example, the waiter is such as a guard, or a shield protecting you from complicated stuff that happens behind the scenes. You don’t have to worry about the stove, ovens, dishes, managing stocks and ingredients or dispensing beverages. He is the interface between you and all of the services that the restaurant offers, giving you a way to communicate with the restaurant while still shielding you from all the complexity behind the scenes.

In that way, the waiter can be seen as the API of the restaurant. And through this example, you intuitively understand why they are useful.


How do APIs work?

In the restaurant example, the waiter can provide you information on the status of your order, without you having to go to the kitchen yourself.

The API is essentially a doorway into our application. Using this doorway, other third parties applications can get access to all of the data and the feature we built without us needing to provide any custom code.

Let’s say this custom app wants to access some of the data or the features that we have built. It will send an API request. API request is sent in a form of simple HTTP message.

There are some common types of HTTP methods that we could use: Post, Get, Put, Patch, Delete. This methods correspond with CRUD Operations, which stands for: Create, Read, Update and Delete

  • Post method create something on the web application
  • Get request read information from the application
  • Put updates information on the application.
  • Patch also updates information on the application. The difference is Put will replace information while Patch will modify the information.
  • Delete will delete the information

In this example we are using HTTP Get message to request information.

Once the API request has been sent, the application will send back a response. The response will be sent back to the custom app usually in  a JSON or XML Format

That’s the basic level of how APIs work.

To get a better understanding of this, let’s use something more relatable. For instance, we have a weather app with a huge network of weather stations set up all around the world. Our custom app is now a mobile app. For most of us, building a worldwide network of weather stations and compiling all of that information is nearly impossible. But this is the beauty of API. Anyone can build a mobile app and then use an API to request the data from an already existing weather application. Our mobile app sends an API Get request to the weather application. Here is an example of an API request using the open weather map API.

We have  a simple URL here

https://api.openweathermap.org/data/2.5/weather?q={city name}&appid={API key}

This URL contains some fields. One field is where the app would enter the city and the other field is something called API. An API key is usually required so the application can keep track of the number of requests being sent and also make sure that you’re not spamming them.

Once the application receives this request, it will respond with the requested data. We can programme our mobile app to take this information and display it in a nice user interface.


Types of APIs

If based on the sub-sector in the information technology industry, the API has the following types

Web API

This type of API is very common, large websites all design web-apps with an API system platform to help you connect, get data or sometimes update data into the system. Big websites like Facebook, Google all provide API systems. It allows you to connect, retrieve or update data to the system. The vast majority of web-based APIs are designed according to RESTful standards. Usually the data format is JSON, XML or any other data type.

API on Operating System

Windows as well as Linux provide API documents that specify functions, methods, and connection protocols. As a result, programmers can create application software that interacts with the operating system.

API of application library (framework)

The API describes as well as specifies the desired operations that the library provides. An API can have many different operational implementations. An API can also make it possible for a program written in one language to use libraries written in another language.

If based on access rights, APIs can be divided into the following categories

Open API

Available, public, unrestricted access.

Partner API

Specific permissions or permits are required to access.

Internal API

For internal systems only (e.g. company, organization). Various in-house development teams can use them to improve products or services that are exclusively for company employees.


API protocols and architectures

REST (RESTful API)

Stand for representational state transfer and delivers data using a lightweight JSON format. Most public API uses it because of its fast performance, dependability and ability to scale by reusing modular components without affecting the system as whole.

SOAP (Simple Object Access Protocol)

This API has been around since the late 1990s and uses XML (Extensible Markup Language) to transfer data. It requires strict rules and advanced security that require more bandwidth.

This protocol doesn’t have the ability to cache, and has strict communication and needs. Every piece of information about an interface before any calls are even processed.

XML-RPC (Extensible Markup language - Remote Procedure Calls)

It also requires a specific XML format and in this, a client performs a RPC by sending a HTTP request to a server that implements XML-RPC and receives the HTTP responses

JSON- RPC

It is very similar to XML-RPC and works in a similar way of action, except that this protocol uses JSON instead of XML format. The client here is typically a software that calls on a single method of a remote system.


CONCLUSION

Overall, APIs are an important tool for businesses across many industries. APIs give companies the opportunity to scale, drive innovation, and reach a wider audience. As Forbes puts it, “Winning or losing increasingly depends on how well they connect to outside applications, devices, and services,” and from a technical standpoint, APIs allow for that connectivity to happen. As can be seen, APIs are driving a new wave of innovation focused on shared services. Hidemyacc software has Open API which is published on the internet and shared freely, allowing the owner of a network-accessible service to give a universal access to consumers.


Download Hidemyacc and start your 7-day trial now!

DOWNLOAD

If you have any further questions, comments, or suggestions, feel free to contact us via Telegram, Skype, or Facebook Messenger support.

Read more