What is an API?

An intro to what API's are and what we might use them for

What is an API?

Photo by Jiroe on Unsplash

API stands for Application Programming Interface. In software development we tend to use these interfaces to make a request, or multiple requests, for some kind of DATA.

Now that we are getting into more technical topics and issues within programming let's start with a technical description of what an API is:

  • An API acts as an interface between two different applications so that they can communicate with each other. An API is a method by which the third-party vendors can write programs that interface easily with other programs

Ok, new to programming here ... What does that mean?

Put a little more simply, some of the cool things that API's let you achieve without a lot of difficulty is the ability to communicate with other applications written in different frameworks or even completely different programming language. We may be using two or even several different languages but still have the ability to "talk" with the other program and make a request for some type of information. Another great thing about API's is you can integrate features, products, and services from already existing ones into your application without taking all that time to build them yourself. Or reusing ones you have previously written yourself. Anything that can make our productivity as developers faster can be a helpful tool in our toolbox (toolbox icon?), and API's are definitely one of those tools!

Types of APIs

There are three main overarching types of APIs:

  • Private
  • Public/Partner
  • External

Private APIs

APIs built purposely for use within an organization. They are classified as an "in-house" application for employees to automate business processes and delivery. Unless you work at the company, you will not have access to these internal API's

Public/Partner APIs

APIs that are openly promoted but available for known developers or business partners. These usually represent software integrations between organizations.

External APIs

These are completely external APIs, which are available to any third-party developer and are mostly designed or built for end-users/customers. These are the type of API's we probably use the most often when starting out with web development

What do we do with API’s?

API’s today are abundant and can help developers build and prototype projects/applications faster and more easily. API’s data can be used to find directions (Google Maps API), give us Users location data (Geolocation API), Manipulation of video and audio (Web Audio API, HTMLMediaElement API) or simply updating HTML and CSS data on the browser DOM (Document Object Model) plus many more.

Some additional API examples include

  • Client-Side Storage(localStorage, sessionStorage, indexedDB)
  • Device API’s (Microcontrollers, Vibration API)
  • Data API's (any API that can provide us large amounts of sample data to test applications)

Real World Example:

Let’s try an analogy (How about an example?), have you ever been to a restaurant? The process of ordering food work’s very much like an API. The Restaurant Server acts as our API. The Customer or end user travels to where they want to eat, think of this as the address or URL of the Restaurant. We often refer to this as the API Endpoint. A Customer places an Order, this can be thought of as our Request or Query. The restaurant server/cashier receives the Order and passes it on to the Chef in back of house, this part can be thought of as the logic that happens behind the scenes or on the API Server. Our food (this will be our DATA) is prepared by the Chef, the API server processes the Request Query. We don’t know the exact details, nor do we need to know the recipe, the order of how our food (data) is put together etc... All we really care about is eating a tasty meal. When the Food (our requested DATA) is ready, which takes some undetermined amount of time (any request to an API is an ASYNCHRONOUS operation in JavaScript), the Food (the API’s Response Object to our query) is sent with the restaurant server and delivered to the Customer (end User). That completes our transaction and we can eat our meal and go on our way.

API_restaurant.png

Why do we use API’s?

  • Quick development
  • Provide sample data for testing
  • Abstraction
  • Security (Privacy and Authentication)

One of the most popular things that we use API's for is helping us build more interesting applications and dynamic web pages quickly. By utilizing API's that are already out there and available to us we can use them to help us get current up to date information about the weather forecast, stock information or even upcoming flight information. Having the ability to access data such as this, because of the data and functionality provided by the API, we can build our own custom weather, stock ticker or flight tracking/booking applications. Or even bring in prebuilt widgets and use them as a piece in our own larger applications.

We don't really know HOW the API is gathering the requested data, we just get all this information and we can use it how we like. This idea of "hiding" the "HOW" or logic behind the API is what we refer to as abstraction. Are they filtering or sorting some or all of that data? Or maybe it accesses information from other API's, possibly multiple API's? We don't know do we? We don't need to know all the details, we just have to know how to make the request for the data we are interested in.

This is just a start into the bigger world of API's and what we can do with them as developers. We will continue to talk about and use them in future articles.

Hopefully this article on API's and how we as developers might utilize them was helpful. Thanks for reading, until next time!