DEV Community

Vikram Sharma
Vikram Sharma

Posted on • Updated on

A Gentle Introduction to APIs

It is likely that you’ve seen the abbreviation API before. If you’ve ever wondered what is an API, we’ll try to explain to you everything you need to know about them in this article.

What is an API (Application Programming Interface)?

An API stands for Application Programming Interface. It refers to a set of programming instructions that enables the interaction between software components. Basically, an API service is a collection of specifications that computer systems use to “talk” to each other and share functionalities.

If you’re still wondering about what is the meaning of an API, you can think of it as one computer making a phone call to another for a defined query that sends back a response.

How do APIs work?

After talking about what is an API service, let’s now describe how APIs work. Foremost, it is important to mention that API is neither a database nor a server; rather, it is the code that controls the access points to the server.

For example, if you type https://www.wikipedia.org/ into your web browser, the browser connects to the Internet and sends a request to the website’s server. Then, the server interprets the received data and sends back a response to the browser, which also interprets the results and displays the required information in a human-readable format. This is how an API works—all these actions take place via an API.

Essentially, the interface that enables the web browser, also referred to as a client, and the website’s server to communicate is what is called an Application Programming Interface. Therefore, whenever you visit a website on the Internet, you’re sending and receiving data to a remote server using an API.

To provide more explanation https://blog.api.rakuten.net/what-is-an-api on what is an API, let’s use a familiar example of ordering food in a restaurant. If you’re in a restaurant, you select what you want to eat from the provided menu. While the kitchen is the “server” that will prepare your meal, there is an important missing link to relay your order to the kitchen and get you served at your table.

So, a waiter (or an API) comes in and takes your order (or request) and instructs the kitchen (or the server) about what you need. Consequently, the waiter delivers to you the meal (or the response).

Just like you’d consume the food without caring about the intricacies of preparing it, users usually consume APIs without really knowing what is taking place behind the scenes.

Different types of APIs

There are several methods for classifying APIs into different types. In this article, we’re going to talk about the following two main methods for classifying APIs:

  • Open APIs—also called public APIs, implying that they are publicly available and anyone can access them without any restrictions.
  • Partner APIs—these APIs are made available under partnership agreements, implying that you need to be granted a license before accessing them.
  • Internal APIs—also called private APIs, implying that they can only be used within an organization.

APIs by specifications or protocols

The objective of API specifications is to stipulate rules or procedures that standardize the exchange of data between computing infrastructure. In the case of APIs, standardization implies the capability of disparate systems, created using various programming languages or various technologies, to interact with one another flawlessly.

Further, the classification of APIs by specifications can be divided into two main types:

  • Web service APIs
  • Web APIs

Web service APIs

Essentially, a web service refers to an application or a data source that is available over the Internet and uses an address, such as an URL, to allow access to its services. A web service is characterized by the provision of open standards and protocols that support interoperable communication between diverse software applications.

While there are several types of web service APIs, we’ll talk about two of the most common ones:

  • SOAP (Simple Object Access Protocol)—this is a protocol that supports the structured exchange of data in the XML (extensible markup language) format. So, if you want to know about what is SOAP API, you’ll need to understand how the XML data format works.
  • REST (Representational State Transfer)—it is a set of software architectural principles, and not a protocol, per se. REST is regarded as a simpler alternative to SOAP. RESTful APIs, which refer to APIs that comply with the REST design principles, make their data available as resources, which can be accessed using URLs that point to those resources. Unlike SOAP that supports only a single data format, REST supports a wide range of data formats, including plain text, HTML, XML, JSON, and YAML. Because of its simplicity and ability to support multiple formats, REST is a prevailing choice for creating APIs nowadays. So, if you want to know what is REST API used for, the possibilities are endless.

Web APIs

Essentially, a web API is an open-sourced concept, and not a technology, that can be utilized to create HTTP-based APIs. As the name suggests, it refers to an API available over the web, supports the HTTP protocol, and returns JSON or XML data type by default.

It is important to note that a web API can either be RESTful or not. Programmers can create web APIs using various technologies, such as .NET and Java.

Common API terms

Here is an explanation of some common terms related to the use of APIs:

  • API key It refers to a unique identification code that is used to authenticate the user or application wanting to be given API access. An API key helps in controlling and tracking how it is being used, which can avert malicious users or fraudulent activities. Some APIs require unique keys before making a request, while others do not require.

    • API call It refers to making a request to the API for data retrieval, just like we’ve explained earlier.
    • API endpoint it refers to the end or touchpoint of the communication interaction between an API and a server. An endpoint can be considered as the URL of a service or a server. Simply, every endpoint is the point of entry where an API can access the resources it requires from a server to accomplish its stipulated tasks. As we’ve seen above, every API works using requests and responses. Whenever an API sends a request to a server, a response is always issued. The place where an API dispatches a request and where the response comes from is what is referred to as an endpoint.
  • API token it refers to an authentication scheme that uses cryptic strings, time-limited tokens, or other types of tokens to grant a user or an application API access. In token-based authentication, the API usually generates a piece of data that is used to prove the identity of the user or the application.

What are the benefits of using an API?

One of the greatest benefits of using APIs is that they make developers’ lives a lot easier. For example, let’s say you want to create an application that displays users’ geolocation details based on their IP address.

If APIs were not available, developers would be obligated to do the hard work of creating such complex applications by themselves. However, the API creators have done all this work, allowing you to fetch the useful features and integrate them into your environment without many hurdles.

Furthermore, APIs allow developers to leverage the advanced capabilities of technology powerhouses. For example, the above-mentioned IBMWatsonTTS API lets you harness the sophisticated IBM’s machine learning technology to convert text into natural-sounding speech, something which could be difficult to realize with your own resources. What’s more, if there is any improved functionality, the API consumers can take advantage of it automatically and integrate it into their applications.

APIs also save on development costs and time. Programmers can create new applications, add new features to their applications, or complete other tasks simply by relying on the services of third-party providers. As such, developers may not need to deal with the source code or spend time trying to comprehend how the externally sourced solution works. Simply, they fetch their features and incorporate them into applications. In other words, APIs conceal the intricacies and inner details of systems, which greatly boost the productivity of developers.
Conclusion

If you have read this article until this far, then you should have an elaborate understanding about what APIs are and why they are such a big thing in the world of technology.

Consequently, you can go to any API documentation and start consuming it. Importantly, before performing API integration to create a new application or add features to an existing application, you should carry out sufficient API testing.

If you can test and see that it works according to your requirements, then API management will be an easy task. With proper management, the API will assist in taking the capabilities of your application to the next level.

References

  1. What is an API Rakuten API Blog
  2. Wikipedia Page on API (https://en.wikipedia.org/wiki/Application_programming_interface)
  3. A basic introduction to APIs for absolute beginners on Freecodecamp.
  4. Programmable Web Article on API

Top comments (1)

Collapse
 
dontpanicux profile image
Blake Arnsdorff

This is a great breakdown of APIs; really helpful to get a baseline understand of what they are and how they can be used / save lives. Thanks for putting this together and I’m glad I happened upon it on LinkedIn today.