What Is an API and Why Should I Use One?

By Tyler Elliot Bettilyon

Image result for API

Have you ever been asked, “Can’t you just use an API for that?” and thought to yourself “What the hell is an API?”

Perhaps you started off by Googling “APIs” and quickly found yourself drowning in acronyms, jargon, and unhelpful exposition. Do I need to take a REST or should I be using SOAP to clean off my data? What is a WSDL, and why do I need to put one in my SOAP? Is an RPC like an RPG and how do I level up? Confusion is a common experience for the growing body of people who are suddenly being asked to know more about tools that have historically been restricted to the realm of the “software engineer”.

This article will help you understand what API’s are without the pervasive (and unhelpful) jargon surrounding them. I will also include a code sample that you can run, right here in your browser, to access one of my favorite publicly available APIs — the Reddit API. Despite the code examples, I am writing this article with non-software engineers in mind. This article is for the sales analysts, executives, HR specialists, and others with no programming background, but who have a growing need to interact with and understand the growing world of Web APIs.

What Problem Do APIs Solve?

As computer programs continue their bid become the de facto medium of business, people who have never had any formal programming training are increasingly expected to have a higher level of software literacy. From sales analysts to HR representatives we are all being asked to make “data driven” decisions; simultaneously more and more company data is being housed “in the cloud” by Customer Relationship Management (CRM) systems like Salesforce, Oracle On Demand, Sage CRM, and countless competitors. Business metrics which might once have been hosted in an in-house database (or in a series of spreadsheets) is being shipped to these third parties and locked behind web interfaces that are often opaque and notoriously frustrating to use. APIs are built as an attempt to free the data from the clutches of these web interfaces, but come with their own set of challenges.

CRM companies these days all seem to promise that they have an “easy to use API” and that their customers can use this API to fetch and process the data collected by the CRM. Unfortunately, while many of these API’s truly are “easy to use” for software engineers (it’s worth noting that some are impossible to use even for veteran engineers) they are often unusable by anyone in outside the software engineering department; sometimes because of a lack of programming knowledge and sometimes because of corporate bureaucracy. Regardless of the reason, this bottleneck is a severe hindrance for people who need the data most, such as data analytics teams. This bottleneck is such a big problem that many organizations are paying for another web service like Tableau to fetch their data from their CRM in order to effectively use the data to answer important business queries related to their customer data.

The fact that organizations are being forced to pay both a CRM to keep their data and a third party to view their data begs the question of the “ease of use” of these APIs; in many cases the convoluted path that data follows from the point-of-sale to the CRM to the online data-analytics platform further obfuscates the “source of truth” for business data which, ironically, makes it even harder to make “data driven” decisions. The people who need accurate data the most are being locked out of accessing it because of this complex web of data transmission.

What Is An API?

An Application Programming Interface (API), is an unfortunately overloaded term which might refer to several different things depending on the context. Wikipedia gives a broad definition:

In computer programming, an application programming interface (API) is a set of subroutine definitions, protocols, and tools for building application software. In general terms, it is a set of clearly defined methods of communication between various software components” (Links and emphasis original to Wikipedia)

In general, APIs define the rules that programmers must follow in order to interact with a programming language, a software library, or any other software tool. Lately though, the term API is most often used to describe a particular kind of web interface. These Web APIs are a set of rules for interacting with a webserver (such as a Salesforce server), with the most common use case being data retrieval. API’s provide mechanisms for CRM customers to access and manipulate data stored by the API provider (Salesforce in this example). The user makes a “request” to a Salesforce webserver, that webserver accesses a Salesforce database (with the customers data), and returns it to the requester in a “response”.

This same request/response cycle is used when you access webpages in your browser. The major difference between an “API request” and a “webpage request” is what kind of data is provided in the response. A website returns HTML, CSS, and JavaScript which work together with your browser to render a webpage. Web APIs respond with data in a raw format, not intended to be rendered by a browser into a user experience. JSON and XML are the most common formats used for this raw data, and they are both flexible text formats for storing data. Nearly all programming languages have libraries that can “parse” JSON and XML, making them friendly choices for developers. Most modern APIs favor JSON over XML.

Steps 1–3 are the same for both kinds of requests: 1. You send an HTTP request to a webserver. 2. That server queries its internal database. 3. The database gives the server the requested data. 4. The data is returned to you in an HTTP response as HTML/CSS/JS to display (website) or as JSON/XML (web API).

Because a web API uses an HTTP request you can query a public API (meaning one that does not require authentication/login) directly in your browser. Reddit has a public JSON API which delivers the “raw data” without any of the CSS, HTML, and JavaScript that is used to create a user interface. Try opening this link in a new tab: https://www.reddit.com/r/all/.json (you can add /.json to any Reddit url). You’ll see a specific kind of formatted text, this is JSON or JavaScript Object Notation, and it’s a more raw version of the information you can see at https://www.reddit.com/r/all/. In Chrome the JSON looks like this:

Raw JSON data in Chrome

Firefox has added tools to make JSON more user friendly by making the data easier to read and adding a layer of interactivity to exploring the raw data. You should see something like this:

Raw JSON data in Firefox

This raw data represents the posts on https://www.reddit.com/r/all and is meant to be parsed by a computer program rather than a person. The program doesn’t have to be complex, lets look at a simple example, even if you’re not a programmer:

async function getJson(url) {
  let r = await fetch(url);
  let responseJSON = await r.json();
  for(post of responseJSON.data.children) {
    let d = post.data;
    console.log(`Title: ${d.title}\nUrl:${d.url}`);

This example defines a “function” which uses other built in JavaScript functions to “fetch” the same data that we were just examining from https://www.reddit.com/r/all/.json. Here, fetch is both an English verb, and a built in function that JavaScript provides to help developers make HTTP requests. We “await” the data, which takes some amount of time to be fetched from Reddit and sent to us. Then we loop over the “children” logging the title and url of each individual child to the console. In this case, each “child” is a post on Reddit — that fact is part of the definition of the Reddit API. Each API must define its own format for the data that it serves; developers typically read documentation provided by the API “maintainer” (Reddit in this case) in order to learn the data format and use it properly.

I encourage you to open the “developer console” in Chrome or Firefox and paste that code into the console. (hot keys to open the console are: ctrl+shift+j or cmd+shift+j in Chrome, ctrl+shift+k or cmd+shift+k in Firefox). Make sure you do this in a brand new tab without a website loaded in it, otherwise you might get an error. When you paste the code and hit enter you should see something like this:

While some programs that use a web API are quite complex, many are actually rather simple. You’ve just successfully run your first API Integration!

Why Use APIs?

For Reddit, the availability of the raw data has made it possible for 3rd party developers to release phone apps that display the same data with custom presentation. Many other API’s are built with the intentions to allow 3rd party developers to build interesting applications using company data. Spotify even showcases some such apps on their website. Apps that “consume” the API data are sometimes called API Integrations. For example, a product manager might ask a software engineer to “Write an API integration that consumes the Salesforce API and saves the data into our on-site analytics database.”

Some APIs, like the Reddit and Spotify APIs, are designed to expand the reach of the organization by making their data available to users, and enabling external developers to build products that are in some way reliant on the business, and so keep customers coming back. For example, Spotify featured the “artist explorer” in the hopes that users will find new artists, build new playlists, and therefore continue (or start) using Spotify.

Other APIs, like the Salesforce API, are part of a package that is sold to companies. Businesses that pay for Salesforce services see the existence of an API as an added value, because they can have their own software engineers build integrations that do two things:

  • Send data from their in-house software programs (such as a webserver or point of sale system) to Salesforce directly, updating the data “in the cloud”
  • Pull data “from the cloud” to their in house software systems (such as a reporting system or internal database)

Because the APIs simply provide data, there are no limits on how a company can then go on to use that data. Furthermore, these programs can be automated to run on a schedule reducing the need for someone to navigate the complex steps of exporting data manually via the Salesforce web interface. As businesses scale up, many find that the initial cost of building such an integration can save employees time and sanity by removing the need to interact regularly with a complex and sometimes frustrating web interface.

Another benefit of Web APIs is that, because they are built around the HTTP protocol, nearly any programming language can be used to access them. Python, R, Java, JavaScript, Ruby, and every other general purpose programming language has at least one HTTP library to make this process easier. However, more specialist languages like SQL do not have HTTP libraries.

As software continues to become ubiquitous CRM companies expect to see the number of API integrations built against their APIs to increase dramatically. Especially as basic programming literacy continues to rise, employees in many different departments outside of the software team may find great value in writing a few API integrations themselves. Often, the code needed for these integrations is short and relatively simple like the JavaScript example we saw above; with a little bit of learning and a little bit of perseverance you too can write short programs to query and interact with the APIs your business pays for!

0 0 votes
Article Rating
Notify of
Newest Most Voted
Inline Feedbacks
View all comments
fila shoes
4 years ago

A lot of thanks for all of the efforts on this web page. My aunt enjoys going through investigations and it’s really easy to understand why. We all know all relating to the dynamic means you create insightful items on the web blog and as well invigorate participation from website visitors about this point so our girl is without question being taught a lot. Have fun with the remaining portion of the year. You have been conducting a good job.

Adidas Originals NMD X Yeezy 350 Boost Mens Running Shoes Olive Green

I intended to write you a very small remark to finally thank you as before relating to the marvelous thoughts you’ve shared on this site. This has been certainly particularly open-handed with you to provide openly exactly what a number of people might have offered for sale for an e book to help make some money on their own, specifically given that you could have tried it in the event you desired. Those tricks as well served like the good way to realize that other people online have the same interest just as my very own to realize a little… Read more »

yeezy boost 350 v2
4 years ago

I’m also commenting to let you know of the beneficial experience my wife’s girl undergone viewing the blog. She discovered plenty of issues, which included how it is like to have an incredible giving character to make certain people just fully understand specific advanced things. You truly did more than readers’ desires. Many thanks for producing these necessary, safe, informative and also fun tips on that topic to Gloria.

4 years ago

I wanted to write you the very little remark to give thanks once again regarding the pretty views you have contributed above. It was quite surprisingly generous of you to convey without restraint exactly what most of us could possibly have advertised as an e book in making some dough for their own end, particularly considering the fact that you might well have done it if you wanted. The ideas also acted as a fantastic way to comprehend other individuals have similar zeal much like my own to know the truth whole lot more in regard to this condition. I’m… Read more »

Adidas NMD XR1 White Line

Thanks so much for providing individuals with an exceptionally marvellous chance to read critical reviews from this blog. It can be so beneficial plus full of fun for me personally and my office fellow workers to search your website nearly 3 times a week to learn the latest items you have got. Of course, I am also at all times contented with the eye-popping thoughts you give. Selected 3 areas on this page are indeed the most impressive we’ve ever had.

Adidas Originals NMD XR1 Olive

I just wanted to write down a message so as to express gratitude to you for all the precious points you are showing on this website. My prolonged internet search has at the end been recognized with high-quality strategies to exchange with my contacts. I ‘d say that we readers actually are very much endowed to be in a really good community with very many brilliant individuals with beneficial opinions. I feel somewhat happy to have seen your website page and look forward to so many more fun moments reading here. Thanks again for all the details.

adidas yeezy
4 years ago

I simply wanted to say thanks once again. I do not know what I would have gone through without the type of information contributed by you on such subject matter. Certainly was a very scary concern for me, nevertheless considering a skilled avenue you managed the issue forced me to cry with happiness. Extremely happy for your work and in addition have high hopes you know what an amazing job you happen to be carrying out teaching many others through your blog post. More than likely you have never come across all of us.