DEV Community

Sospeter Mong'are
Sospeter Mong'are

Posted on

What is an API

API stands for Application Program Interface.

  • It acts as an interface between two programs or two systems.
  • It could also be a software which builds a connection between two different applications.
  • Organizations share some data with the public through their APIs

When an organization decides to make some data publicly available, they publish in the form of endpoints so that it is available for others to pull that data.
Now, let's take a look at the simple diagram to get a better understanding. Here, there is a lot of communication going on between the database and the web server.

API description

Then, between the web server and the API. And finally, between the API and the web application by means of the internet. If one web application wants to access the other application's data or functionality, like, for example, if we want to pull these stock prices for our application from another web application, we can do so by means of APIs.

Accessing Stock Price Data

The API acts as a middleman between the two applications.
Another example is when we check for the weather on our phone using the weather app. We are using an API to access the data by hitting the web server, and in turn, accessing the database, and then fetching the data back to the app.

Accessing weather data

So when the request is sent from the app to the API, it communicates with the servers and the database, and fetches the data back in the form of a response. So when a request is sent, we need to receive a response. These are two simple examples of APIs.

In today's modern world, instead of creating similar functionalities over and over again, many organizations make use of APIs provided by other organizations to use in their projects. This is all about what an API is.

Types of APIs
Now that we know what an API is, let's understand the different types of APIs that are available. Here, by APIs, we are referring to web APIs. And these APIs use HTTP protocol, that is Hypertext Transfer Protocol, which is the same protocol we use for our webpages using any browser.

So APIs are categorized into four types based on the access levels and their scope of use. Open. Partner, Internal and Composite APIs.

1. Public APIs or open APIs.
These are also called external APIs. These APIs are available for anybody to use so they need no or low authorization and authentication. So some of these are free and some come on a subscription basis based on the number of calls made to the APIs.
So what's the advantage for the business that owns these APIs?
Their data is made available to other third party businesses or developers which make their APIs more valuable. When we think from the developers or other business perspective, the data is readily available with very few restrictions.

2. Partner APIs.
These APIs are available only to those businesses which are in collaboration with the business that provide these APIs. Like only if they're partnering together. So these APIs need stronger authentication and authorizations to avoid public usage of these APIs. They might have license keys as well for more security reasons.
The advantage for businesses providing partner APIs is that they can share information only with specific people. This way they have better control over how this information is used and with whom it is shared.

3. Private APIs or internal APIs.
As the name implies, these APIs are internally used by organization and not for public use. These are used when there is communication between systems or applications within the organization.
When a new system is built, it interacts with the other existing systems using these APIs. The last one is composite APIs.

4. Composite APIs
This API combine multiple API requests into a bundle and allow users to get one single response from different servers. These APIs are used when the developer needs to fetch data from multiple servers or data sources.

The advantage of using these APIs is that they reduce the number of API calls thus reducing the server loads, which in turn improves the performance and speed.

So these are the different types of APIs that are used. It is important to understand the differences between these, so that you can know how to work with it.

Top comments (0)