What is an API? #
API stands for Application Programming Interface and is a technique that allows developers to link two applications together. You may find it obvious that applications can work together, but it isn’t.
Every application works in a different way. This is because applications are often built by different developers. And so every developer uses a different programming language and programming style. Compare that to two people speaking a different language. A person who speaks French cannot communicate with someone who speaks Swedish. An interpreter is needed to translate the French question into Swedish. The interpreter then translates the Swedish answer into French. In this way, the two people can communicate with each other.
You can compare the interpreter in this example with the API. It is a means that stands between two entities and ensures the communication between these entities.
How are APIs used? #
APIs are extremely useful. Without APIs, many different software applications would not exist. We could argue that our lives are a lot more difficult without APIs. We use APIs on a daily basis, without our knowing it. You may understand this better with the examples below.
Buying plane tickets with an API #
When looking for a plane ticket, you probably use a comparison website such as Skyscanner or Kiwi.com. These websites have their own software system linked by means of an API to the websites of ticket providers.
The moment you enter a departure and arrival place, outward travel date, return travel date and the number of people, the comparison website sends this data to the airline ticket providers via an API. You will then have to wait a while until you see all the flight tickets. The website is collecting all the data. The providers send back the prices and times of the flights, which are then displayed on the comparator’s website. When you find a flight you want to buy, all you have to do is click on a link to go to the provider’s website.
Control smart home with an API #
More and more houses are becoming ‘smart’ thanks to smart home products. Consider, for example, Philips Hue. These are lamps that you can control via a smartphone. Just like your smartphone, the lamps are connected to the WiFi network.
These types of products often go much further than control via WiFi alone. For example, you can set the lights to turn on automatically as soon as the sun sets. And you can have your windows close automatically as soon as it starts to rain. Or all electrical appliances go off when you leave the house. APIs are used here.
Philips Hue uses the APIs of weather stations and navigation systems in these specific cases. It itself does not have any information about the weather. And why would they collect this information themselves when there are many different reliable weather stations that can provide this information?
Your Philips Hue app can read the local weather from the weather station. Does the app receive information about an upcoming rain shower? Then the windows will be closed automatically.
Why are APIs useful for developers? #
The examples above tell you more about why APIs are so useful. Let’s recap why APIs are so useful to developers and users.
Build apps faster #
If a developer wants to use certain data or certain functions within his application, he can of course develop these himself. But, of course, that takes a lot of time and effort. It’s a shame to spend time and effort on this when someone else has already developed this functionality. Why reinvent the wheel?
Developers can use the code of others to perform specific functions through another application. Or to retrieve data, as we already told you more about in the example about the Philips Hue. This allows them to build applications faster, because they do not have to rebuild the functions.
Fewer to no mistakes #
Developers can quickly and easily use data stored on other servers. They therefore do not need to transfer data to their own server or application. This also makes it impossible for something to go wrong due to human error.
When you can link applications through APIs, you can automate tasks. For example, it is possible to link a crypto exchange to your trading bot. The trading bot can automatically execute trades on the crypto exchange of your choice. And it all happens completely automatically, without you having to do anything further.
Provides interesting solutions #
APIs make consumers’ lives easier. Consider the example of airline ticket comparison websites. These kinds of websites wouldn’t exist if we didn’t know APIs. That is why we can say that APIs provide interesting new products and solutions.
How do APIs work? #
When someone develops software, APIs are often taken into account. That’s why you can usually find more information about how to use the API on the software’s website. This documentation explains how you can connect to the application.
Different types of APIs #
There are many different types of software applications, which is why there are different types of APIs. Every API works in a different way.
- Java APIs – These are program-oriented APIs and focus on real software applications that you need to install on a device.
- Simple Object Access Protocol (SOAP) APIs – The SOAP API is used for communication between applications or system components. A SOAP API sends XLM messages over protocols such as HTTP, HTTPS, JMS, FTP, and SMTP.
- Remote Procedure Call (RPC) APIs – An RPC API can be used to run code on another machine. This way the developer does not have to move this code to his own machine first.
- Representational State Transfer (REST) APIs – We see that REST APIs are the most popular and well-known. They are used by web applications to quickly and easily retrieve data via URLs. Think of the GET, POST, DELETE and PUT methods.
APIs within the blockchain world #
We also know APIs within the world of blockchain and crypto. And that’s a good thing, because without these APIs, decentralized applications and cryptocurrencies would look very different. API3 is a project that aims to set up decentralized APIs.
API3 is a protocol that allows for the creation of decentralized APIs (dAPIs) for web 3.0. It aims to develop powerful dApps that can make use of decentralized, secure and measurable data feeds. That’s less easy than you might think.
Within the blockchain, everything is decentralized. There is therefore no central party that can monitor whether everything is done in the right way. When someone supplies data to applications, applications must be able to assume that this data is correct. There is therefore no central party that can control the supply of this data.
Oracles must be used for these decentralized APIs. Blockchain oracles are techniques by which data from central systems is checked before it is moved to the blockchain.
This way nodes can take care of the control of this data. Suppose a dApp needs the data from a weather station. The dApp must be sure that the data that is supplied is correct, and that no one is deliberately supplying incorrect data.
One can then use an oracle where nodes supply the data. Other nodes can check whether the data is correct. When a node feels that something is wrong, it can raise the issue within the blockchain network. Then all nodes will vote on the event. If it turns out that the node in question has indeed supplied incorrect data, it could be removed from the network.
The difference between APIs and blockchain bridges #
Sometimes people make the mistake of comparing an API to a bridge. They are very similar, yet different from each other. Let’s take a look at the main differences and similarities between APIs and blockchain bridges.
A bridge is a technique that connects blockchains. Normally, blockchains cannot work with each other. Every blockchain is built in a different way, so they are not interoperable with each other.
Developers benefit greatly from blockchains that can work together. For example, they can use dApps that run on other blockchains and move tokens between blockchains. That is why there are blockchain bridges. These can be seen as a ‘bridge’ between different blockchains.
Often a protocol has to be built on both blockchains for such a bridge. When someone wants to send BTC from the Bitcoin blockchain to the Ethereum blockchain, a protocol on the Bitcoin blockchain holds the BTC. Then a wrapped BTC token on Ethereum that has the same value is issued. In this way, such blockchains can work together (although each bridge works in a different way, of course).
An API works completely differently. With an API you can directly use another application. The developer of the application must add this function to his application himself. Only then can other developers use the API. In this respect, the API differs from the blockchain bridge.
APIs are extremely important. Without APIs, it would take software developers much more time and effort to develop an application. They then have to use data from other servers and develop software functionalities themselves. This not only takes a lot of time, but also increases the risk of making human errors. That’s why developers are only too happy to use APIs.
There are different types of APIs, such as SOAP APIs, RPC APIs, and REST APIs. But nowadays we also see APIs within the blockchain and crypto world. We also call these dAPIs, which stands for decentralized APIs. A project that deals with decentralized APIs is API3.
However, the use of APIs within the blockchain is less easy than within central systems. There are no third central parties that can control incoming data. This is therefore done by the nodes within the blockchain network. They are rewarded for providing correct data and controlling other nodes.