In software development, a very important concept to know is API which stands for Application Programming Interface. An API is a piece of software that connects 2 different applications. It basically enables one application to talk to another, and thus information is shared between them both.
Let’s use an analogy: imagine you are at a restaurant and you want to order food. Your food request must arrive at the kitchen so that the chefs know what meal they need to prepare. Instead of having to walk to the kitchen to deliver your request and afterwards walking once again to get the meal, what do you do? You call the waiter. The waiter is going to note your order and deliver your request to the chefs. Later, he or she will bring the prepared meal to you and you can finally eat.
An API has the exact same function as that of the waiter in a restaurant. It will receive a request from an application and send it to another software, which will then process that information and usually send some data back to the first application.
Let’s describe a real example to make it more clear: imagine you are willing to book a flight from one city to another. You can check on every aircraft company’s website for the best flight that suits your requirements (not only the city of departure and arrival, but the dates, the seats’ comfort, and so on…). Every single website is going to connect to its database, respectively, in order to search for available flights.
Now, what if you were doing this in a 3rd party app, for example, where the app does not have direct access to the companies’ database? This task would have to be done via the airline’s API, which would carry the request from the user and would return the needed information. In this way, the app does not have direct access to the databases, but it can receive data from them through the use of an API. Therefore, the user does not have to go to the kitchen to get his meal, but the waiter will bring it to him.
But why are APIs so important? Well, we can talk about two major reasons.
First, it is a major time-saver and, therefore, money-saver. If you were developing an app that featured a location tracking system, such as Uber for example, you would have to build everything from scratch (including the maps from all around the globe, calculating the best routes and so on). Using Google Maps’ API for instance, you can skip all of this huge amount of work, since they have already done it. You just need to use it for your purpose.
Second, using an API is a safer way of managing data. Without it, every single customer would have access to the restaurant’s kitchen; they could make a mess with the pans, they could make the floor dirty… That is why the requests must be sent by the waiters.
Some examples of API are listed below:
- Open Weather Map: an online service that provides weather data including forecasts and historical data. Their API provides access to weather maps and forecasts for multiple cities across the world.
- API-FOOTBALL: the most popular API for football (soccer) data. It covers over 300 major and minor football leagues. Get live scores, pre-match odds, events, line-ups, standings, stats, and much more.
- The Cocktail DB: an API that provides a crowd-sourced database of beverages and cocktails from around the world. The API allows you to search for cocktails by: categories, glasses-type (example: flute vs standard cocktail glass), ingredients, alcoholic-type (alcoholic vs non-alcoholic).
- Yahoo Finance: provides financial news & data as well as online tools for personal finance management. It is one of the most popular media properties for financial stock data.
- Love Calculator: Learn the compatibility between you and the name of your crush using the love calculator API. Simply insert your name and your partner/love/crush’s name and the API calculates the percentage and compatibility result between you two.
- URL Shortener Service: a simple API that converts URLs to short links. Just paste a link to cut it!
- NasaAPI: an API that queries NASA’s database and returns statistics about: asteroid stats, closest asteroids, earth imagery, pictures of asteroids, Mars rover photos, and more.
- Numbers: an API for interesting facts about numbers. Provides trivia, math, date, and year facts about numbers.