What is an API?

What is an API?

API stands for “application programming interface.” APIs allow one application to “talk-to” another to allow for the transfer of stored data or instructions. API’s are everywhere in your daily life, from the embedded YouTube videos on social media applications to the smart speaker on your kitchen counter. They make it possible for software developed at different times by different people to interact and, thereby, increase functionality and productivity.


How does an API work?

For the following example, we will be working in JavaScript (jQuery enabled) with The One API (a fun Lord of the Rings Themed API). Consult the API documentation for specific instructions on usage. Many APIs require an authenticating id tokenkey to access. The instructions for acquiring that token are also found within the API’s documentation.

In order to call an API, the “caller” has to send unique identifying information as an identifier to the API service provider. This identifier is called an API key.

Consider the following code:

The URL string below is the path of your API and can be found in API documentation.

const lotrQuote = "https://the-one-api.dev/v2/quote/";
$.ajax({
    url: lotrQuote,
    method: "GET"
    }).then(function(response){
        console.log(response);
    })

In this example, the variable lotrQuote is defined as a string that contains an API route. When called by the jQuery .ajax method in line 2, the API is queried and returns either JSON or XML data. That data is then passed into our .then callback function and rendered to the console in its raw form.


Examples of APIs

There are tons of APIs available to the public that are free to use. Check out sites like public-apis.xyz to explore and get creative with the wide variety of options. Here are a few examples of common public APIs that you may already be familiar with in your day-to-day life:

-Google’s public API suite - Google has an overwhelming collection of public APIs that developers can try for free. They do have pretty strict security on their id keys and free usage is capped by a daily limit so test sparingly. This suite facilitates all the embedded “Google Maps” you see on other developers’ apps and websites. And that’s just the tip of the iceberg, so dive in.

-Mailchimp’s Marketing API - Mailchimp is an email marketing platform that powers the email marketing needs of many common websites. These sites and apps are able to make use of Mailchimp’s platform by utilizing the power of their marketing API.

-OpenWeather API - OpenWeather is a free, open weather data API that can be used to power anything from small widgets to whole applications. According to the reporting site Built With, many news organizations use OpenWeather on their sites.


Experiment

Simply messing around with free API’s can teach you a lot about your language’s syntax and programming concepts in general. Create something fun and useful today!