APIs are the Key!

Will Gibson
4 min readApr 7, 2020

--

Photo by Shane Avery on Unsplash

While almost being completely ubiquitous throughout the functionality of the applications we rely on in many aspects of our daily lives, it seems that APIs or Application Programming Interfaces have remained relatively unknown amongst the average user.

In the following, I will cover the basics of defining an API while explaining how they work, as well as their benefits to the technology ecosystem from my experience researching and implementing a new API during the development of the first team project in the Full Stack Developer Program at UC Berkeley Extension.

Please note, having a month or so of coding under my belt a this point most of my knowledge and learning has come from working with Web APIs specifically so that’s where the focus of this piece will be… for now.

What is an API?

While some of us may have a vague understanding of what an API is and what does, for those that are not familiar feel free to reference the description provided from our dear friends at Wikipedia who define an API as,

“a computing interface to a software component or a system, that defines how other components or systems can use it. It defines the kinds of calls or requests that can be made, how to make them, the data formats that should be used, the conventions to follow, etc. It can also provide extension mechanisms so that users can extend existing functionality in various ways and to varying degrees”.

While daunting at first glance, connecting the abstract definition above to real-world examples is not as difficult as it seems. Think about any application that incorporates third-party data or functionality so it’s available to its users, such as Pay with Paypal in the checkout process for an eCommerce site or available flight departure/arrival times and updated prices on travel booking sites like Priceline. These are examples of developers leveraging APIs provided from the source’s site to directly feed their page or application.

How Do APIs Work?

Essentially APIs are simply a set of instructions and documentation for how developers can access resources and information from another application or source outside of their own, typically by using a query URL and specific number of search parameters. By using functions leveraging AJAX calls (JavaScript method for requesting information from an API) and parsing their responses, developers can easily incorporate information that is loaded by the browser dynamically to the client’s web page, or what’s referred to as the Document Object Model (DOM) from the API provider.

Below is an example of the query URL, AJAX call, and parsing of the API response used in my project application to dynamically create a video source link to embed on the DOM.

function youtubeResponse(selectedGame){
var queryURL = "https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=1&q=" + videoType + selectedGame + "&type=video&key=AIzaSyAjs8I4xGPzoBBcuCk4afKvx-IRoVaQX0A"

console.log(queryURL);
$.ajax({
url: queryURL,
method: "GET"
}).then(function(response){

var videoId = response.items[0].id.videoId;

return "https://www.youtube.com/embed/" + videoId;
})
}

APIs: Value Added to the Ecosystem

APIs create a rare set of win-win-win circumstances for all stakeholders (users, developers, and API providers) involved with the creation and consumption of applications.

Users Win

The clear beneficiary of the advantages APIs produce are the end user being able to utilize information from sometimes many different sources all in one application. Imagine having to call an Uber or Lyft without Google Map’s capability or having to create a new account and enter the same information for every application you use (as was customary not too long ago) by not being able to Log In with Facebook or Google. These conveniences drive users to engage with applications more than otherwise if the friction of switching applications were present.

Developers Win

Having the ability to easily implement functionality benefits the developer by reducing the time of development from building features from scratch. It also ensures data integrity and cost compared to manually scraping information from a source site. Developers also benefit from users enjoying the ease of the application and integrating it into their regular routine.

API Providers Win

Lastly, if you’re wondering why source’s go through the effort to provide APIs to their information or pre-built features at all, it’s typically because under their permission it allows them to control the terms in which 3rd parties access their APIs (through credentials known as keys). This is also coupled with the benefit of their brand being used by more users on more platforms and the network effects that come with users connecting with them in more places as well.

Summary

In conclusion, while being relegated to the back of the house in terms of bringing many beloved features to the modern world of applications, APIs serve a critical need in the development process have been a master key of sorts unlocking tremendous value across the web.

--

--