What is an API
API stands for Application programming interface. To explain this concept I like to use a metaphor. Imagine going to your local bakery. At the counter you ask for the things that you want to buy. The guy at the counter will pack these items for you. You only get the specific bread that you want.
Just like ordering a bread, an application programming interface is a way to ask for things from someone else. On the internet API’s deliver the information to you that you ask from them.
Developers use API’s as way to get information from other services on the internet. Let’s say you are a web developer and want to know the weather in a certain city. You can use a weather API for this. The API will be requested to give the current temperature in city X. In milliseconds the API will lookup the temperature in a database and sends you the current temperature in city X.
To get a more in-depth understanding of API’s I will explain the technical details below. Scroll down to see some examples of API’s.
API’s are here for speed, security, and consistency
Most of the times API’s are created by organisations to exchange information with clients or machines. API’s make in fast, secure, and consistant for organisations to share their information. Why? Read the explanation of each concept below:
Fast: Let’s imagine you are a bank and you want to share information about the stock market. Many years ago, someone at the bank could call you and tell you the current stock prices. This banking guy has a hard job since the information changes all the time. Nowadays, an API could automate this process. Just in milliseconds someone at home could use an API to request the stock prices at that time. No person is needed.
Secure: Let’s stick to the banking example. The guy that calls the stock investor to present the stock prices – could by mistake – share some sensitive information about the bank. This is impossible with an API. The API shares only predefined information. There is no middle-man between the information and the client/computer.
Consistant : probably you can guess this already. API’s use some predefined format to deliver the information to you. For example in an excel sheet or JSON format.
How does an API work?
To really understand the concept on an API we need to get a bit more technical. API’s needs to be implemented by developers. Although API’s are fairly easy to implement, some small coding experience is needed.
Once implemented you are able to request for information. Requests need to be in a predefined format. Mainly JSON format. See the JSON request example below:
city-name: "New York City",
This piece of JSON information is send to the API. It understands this information. Subsequently, the requested information is send back to the user in JSON format.
Process of an API
The diagram below explains all the different steps of an API in detail
The steps in this diagram are:
- You implement the code on your website in your preferred programming language.
- If the code runs and the data is presented in the right format, the JSON data is send to the server of the application programming interface.
- The API only works for authorised users. Some API’s are not free or limit the amount of requests per month.
- If authorised, your requested data is processed.
- The requests is looked up in a database.
- The requested information is send back to your website (in JSON format).
Examples of API’s
I am the founder of www.theapicompany.com. We create easy and simple API’s for web developers. Below I like to show you two of our API’s
1. Device detection API (click here)
2. Geolocation API (click here)
The geolocation API detects the location of someone on your website. This tool detects the city, timezone, currency, and IP-address of the user. Image the many applications of this. For example, an advertiser only shows ads to persons in the city of the shop. Alternatively, automatic conversion of prices in a web-shop based on the local valuta of the customer.
An Application Programming interface is used to share information between services. This is done fast, secure and consistant. Try the device detection API or Geolocation API. Happy coding 🙂