DEV Community

Jon Deavers
Jon Deavers

Posted on

What is an API?

What is an API?

API stands for "application programming interface". APIs allow one application to "talk-to" another, allowing 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 token to access. The instructions for acquiring that token are also found within the API's documentation.

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);
    })
Enter fullscreen mode Exit fullscreen mode

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 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 so check out a site like public-apis.xyz to explore and get creative with a 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 of the websites you read every day. Those 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 and 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!


If you have questions or enjoyed the article let me know in the comments below or stop by my developer profile page and say hello.
https://lucsedirae.github.io/

Top comments (0)