13-17yrs, 18 & over, 8-12yrs, Blog, career exploration, Technology

API and its importance to Technology Users

Application Programing Interface (API) is a set of functions and procedures that allow applications that access the features or data of an operating system, application, or other service to be created. Consumers that use technology, especially technology that involves communication between two or more parties, are encouraged to learn more and be aware of applications that utilize API. In a time when the world relies on modern technology, it is important for technology users to learn of the true importance and use of specific data applications and programs. Many consumers are intimidated by the complexity of some programs and applications. Although, no one should be intimidated by these things as they are quite simple to understand. It is extremely helpful to know how specific applications work as you can use them to your advantage.


Discord is a texting platform similar to Google Hangouts or WhatsApp. It has features that make it unique, including bots that are created by anyone to perform tasks through the app itself. Discord bots can be used to play mini-games and moderate Discord servers which has increased their popularity among Discord users. Bots can be made public to allow Discord users to add the bot to their server and access its features, but bots can also be made private so only their owners can add it to new servers. Essentially, bots can allow users to access information, access features not readily available, or they make it easier to access data.

Application Programming Interface

An Application Programming Interface is one of the ways the Bot can connect to external services to get data. In Layman’s terms, two applications communicate with each other in order to satisfy the request you made. Since a Discord bot will not store much data like the weather or news, the simplest way to get recent and updated info would be through an API. 

Benefits of API in Discord

It is extremely helpful when using Discord. It allows users to take some stress off of their minds as it allows bots to regulate gameplay and chatting. This is extremely beneficial when playing mini-games as the bot can regulate and report scores. Using an API is also important when moderating chat rooms as bots can detect any inappropriate activity before removing or blocking any users that violate guidelines. An API can even update news reports for users, which will be shown in Example 1. 

Connecting Services

A module is required to request the data, as well as an API key which gives us permission to access the data. The key also records the calls/requests we make to the API and can be used to limit the number of calls to it. The module is what takes the load of making the request, in my example I will use superagent, a simple and powerful module that makes HTTPS requests to call the API data.

Example 1

An API call using JavaScript and superagent would look like this:

require(`superagent`).get(`http://newsapi.org/v2/top-headlines?country=${COUNTRY}&apiKey=${API_KEY}`); require(`superagent`) // What we need to make the API requesthttp://newsapi.org/ // The link we get the API data from, the other information is specifying what data we are looking for.

The module will request the data from the newsapi.org and give us the data, which in this case is the top news of the given country. We can organize this data and connect it with the discord.js library to give the requester the information. Calling the API will give us the information below for the date of 06/23/2020 at 10:40 A.M. CST, the date is important for this API since it is updated frequently.

click here for full image

That looks confusing and messy since this is the raw data and there is no formatting, if we format the data that we receive it is much easier to read.

click here for full image

The Result of an API Request

The benefit of making an API request is for this service (a Discord bot) to connect with external services and get data that will be useful in completing a function. This command function is to keep everyone updated on the latest events affecting their county and making them stay safe with the information they are given. 

Additional Possibilities 

All APIs aren’t always for information such as news, some can be for fun, such as the giphy, which gives us GIFs to keywords. They are modern services that are simple and useful in completing a function or feature. A Discord bot is just an example of a service that can make an API request. Websites and applications can make requests to show information or save information. Another API that I have used (Google) allows me to update my website every hour with the latest data and information.

Final Product

Using the news API and my Discord bot Jonin, I am able to show the latest news of any country, an example is shown below. The request will only send data, usually in the specified format like JSON, using the data to send information in a formatted way is a good way to keep the UI easy to understand.

click here for full image

Spread the love