Surely you have heard a thousand times about APIs. An API for this or that… and if you’re starting in the world of programming, it will sound a bit “Chinese.” Do not worry. In plain and easily understandable words, I will explain what an API is, what they are for, what types exist, and how they are created.
What is an API?
An API ( Application Programming Interface ) is how an application exposes data and functionality to other applications. In other words, it is a way of communicating with each other to two or more applications, obtaining data, sending orders, etc…
There are APIs for local use and APIs for remote use, which is generally for the Web.
A local use API is intended to expose functionality to other applications installed on the same machine. For example, Microsoft Office (you know, Word, Excel, PowerPoint…) offers several APIs that allow you to use its capabilities from your applications, for example, to generate an Excel from the data you have in your app, and things like that. Windows also offers many APIs so that your application can do everything in the system. This is the traditional concept of APIs. There have been many standards to create over the last 30 or 40 years, although the two most relevant were COM/ActiveX from Microsoft and CORBA from many other manufacturers.
However, today if they talk to you about APIs, they probably refer more to APIs for remote use or Web APIs.
A Web API communicates over the Internet to two or more applications to exchange information and send and receive orders.
Depending on the use you make of them, you have two types of Web APIs: those aimed at providing a service and those that expose the functionality of an application.
Web APIs aimed at providing a service
For example, if you have to make an online store, logically, you will have to have a way to charge users. You could consider creating your collection system that receives, processes, and saves credit cards, communicates with banks, etc… But it would be crazy because it is very complex and rigorous security. It would not be feasible for you to do so.
Luckily, many payment service providers have already done all that, which allows you to use their development through an API. Thus, when you want to implement payments in your online store or your application, you have to use one of these APIs, for example, Paypal or Stripe, which already give you everything done. In exchange, they will charge you something to provide you with the service, but they save you all the work, which in many cases you would never be able to tackle on your own.
Well, the same goes for a thousand other things: do you need maps and measurements? Well, making maps of the whole world and keeping them up to date would be impossible, but Google or Open Street Map, among others, give it to you through an API. You have APIs for almost everything you can think of: weather anywhere in the world, stock prices in real-time, speech synthesis, face recognition… In short, anything you can imagine.
APIs that expose the functionality of other apps
The other excellent classification could be applications that expose all or part of their functionality to others. For example, Twitter has an API that allows your application to do the same thing a user would do on this social network. Many apps use this API to make Twitter interfaces prettier or more functional, automate your social media presence, and do a thousand other things.
Almost all web applications you know have APIs to use from other applications. And without a doubt, if you make a Web application sooner or later, you will want to have an API and let your client’s applications communicate and automate your application. For example, our e-learning platform has an API that allows our significant clients to automatically enrol students when they want to take a course or pull information about a specific student in training to see how they are doing. In this way, they do not have to enter several applications (at least their management and platform) to do the same thing or repeat the data, saving time and errors.
How to create an API
Almost all development platforms (.NET, Java, Node.js, PHP…) offer a simple way to use Web APIs and a form, more or less complex depending on the case, to create APIs to allow others to communicate with them.
There are several standards to create this type of Web APIs: from the old SOAP based on XML to APIs of the REST or GraphQL kind, to name the best known.