API is the short name for Application Programming Interface and depends on where it’s used; the term API refers to different things. Nowadays, when someone says API, she/he usually means HTTP API, a variation of API built on top of the HTTP (Hypertext Transfer) protocol. Going forward, when we say API, we simply mean HTTP API.
APIs are computer software, just like the calendar app on your smartphone or the browser application you use to surf the web, with a subtle difference: APIs don’t have GUI (Graphical User Interface) like a calendar app. Moreover, APIs are installed on servers rather than your computer, just like any website. APIs are the gateway to software systems.
What does an API do?
APIs, in general, are capable of doing virtually anything, but in practice, they offer a set of features that a company decides to make available to the users. For example, using the Twilio API, you can send text messages to any mobile number in the world! In contrast, Twillio API does not offer an API to send a message via Instagram Messages, so you can’t use Twillio API for that purpose.
API documentation
To find out what an API can do for you, you need to read the documentation for that API. The company that owns the API makes the documentation available online. Documentation is written in plain English (and sometimes in other languages) and contains technical information that helps programmers understand the API and use it.
How are APIs used?
Programmers build APIs and for other programmers to use. They primarily serve software developers for three main reasons:
-
APIs enable web & mobile developers to retrieve the data they need to display information on screen for you.
- When you open the Youtube app or website, the app uses Youtube API to fetch the videos it should show to you.
- When you search for “How to roast vegetables” in Google, the site pulls the search results using Google Search API.
-
APIs enable software developers to use features of other systems.
- When you book a table for dinner online, the booking system most probably uses API from Twilio (A service to send SMS) to send the confirmation text message to you.
- When you search for a funny cat gif to add to your email, Gmail uses the API from Giphy (a company that offers an extensive database of funny gif animations) to load the GIF files for you.
-
APIs enable software developers to build new software using the data available in other systems.
- Our friends at volt.fm use Spotify API to make exciting Spotify profiles, something that Spotify does not offer.
- Buffer (buffer.com) allows you to schedule Instagram posts and publishes the images to Instagram on the set date. It does it using Instagram API.
Are APIs free?
Most APIs are publicly available and free to use; you don’t need to pay to use them. Some APIs are free but to use them; you should sign up for the service, which might also be free. For example, Stripe (an online payment provider) offers API, but you need to create a Stripe account to use their API. Some companies build APIs as a service, and you should pay them to use the API.
Types of API
Developers have been building APIs for more than two decades. Like any other technology, APIs have seen constant improvements in the form of new types, address issues with previous kinds of APIs, or offer unique features that were not available in the past. Currently, the following types of API are used widely in the software industry:
- GraphQL by Facebook: Facebook introduced GraphQL API in 2015 after using it internally for some time. GraphQL approach to data retrieval for APIs was novel, and it quickly became a popular model for API development.
- REST was first introduced in 2000 by Roy Fielding. It’s by far the most popular type of API. REST APIs are available via HTTP protocol and mostly JSON as the data format to send and receive data.
- SOAP APIs are available via HTTP protocol and primarily use XML to exchange data. They’re still in use, but many developers prefer to build REST APIs than SOAP.
What is API Key / Access Token?
To use most APIs (free or paid), you need to obtain an API Key from the API vendor. Using the API Key as a secret that only you and the vendor knows about it, API authorises you to access your information.
For example, you can use your Spotify API Key to fetch your Spotify playlists. If you have access to the Spotify API Key of your cousin, you can see her playlists as well, so API Keys are a sensitive piece of data, and you need to store them safely. If you think your API Key for a service is made available to someone else, contact the API vendor immediately to reset it for you. Some vendors offer a way to reset API keys via web or mobile apps; if it’s available to you, reset your API Key asap. As soon as you reset your API, it becomes invalid, and no one can authenticate themselves as you.