What Is an API and Why Should I Use One?

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.

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:

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).
Raw JSON data in Chrome
Raw JSON data in Firefox
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}`);
}
}
getJson('https://www.reddit.com/r/all/.json');

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.”

  • 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)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store