In recent years, the use of APIs has been instrumental in the architecture of systems. APIs use their own protocols to determine the instantaneous response to any request that you may have. Think of APIs as a way for different computer programs to talk to each other and share information. It’s like when you and your friend have a secret handshake that you use to communicate and share something without anyone else understanding.
APIs are like that secret handshake between programs. They allow one program to request information or send a command to another program and get a response back. For example, let’s say you’re playing a game on your phone, and you want to share your high score on social media. The game app would use an API to send your high score to the social media app, and the social media app would use an API to receive the score and post it on your profile.
APIs come in many forms and allow different types of communication between programs. Some APIs are public and can be used by anyone, while others are private and only available to certain programs or developers. But no matter what type of API it is, they all serve the same purpose of enabling different programs to work together and share information in a secure and controlled way.
Let’s dive deeper into APIs and use a different example. Imagine you’re Sam, and you’re helping Frodo figure out when his order of Lembas bread will arrive from the elves. Instead of sending a message with a bird, you’re using a special magic called an API to talk to the elves’ computer.
First, you need to know the elves’ computer address, which is called the universal resource identifier or URI. This is like a map that shows you where to find the elves’ computer. Once you have the URI, you use a special magic spell to summon a portal called the API gateway to talk to the elves’ computer. This gateway ensures that only authorized people can talk to the elves’ computer, just as only you and Frodo can communicate with each other using your secret hobbit code.
This is an example of a private API that restricts access based on various factors, including whether users should have access, whether they have been here too often, and what kind of “key” they possess. Although the gateway may be open to the public, making it a public API, allowing anyone to access to the elves’ computer could be hazardous for most business use cases. Thus, the use of private APIs is more widespread.
Next, you tell the gateway which part of the elves’ computer you want to communicate with, known as the API endpoint. This is akin to informing the elves’ computer which elf you wish to speak with about your order of Lembas bread.
Then, you use special words called HTTP commands to ask the elves’ computer for information about your order. These commands are like the secret words you use to get into the elf kingdom. There are different magic words for things you want to do, like asking for or sending information.
There are nine HTTP commands, and each one does something different. Here are the most common ones:
- GET: This magic word is used to ask another computer for information. It’s like saying “Can I have that, please?” For example, when you search for something on Google, your computer uses the GET command to ask Google’s computer for information.
- POST: This magic word is used to send information to another computer. It’s like saying “Here’s something for you.” For example, when you fill out a form on a website, your computer uses the POST command to send the information you entered to the website’s computer.
- PUT: This magic word is used to update information on another computer. It’s like saying “Here’s some new information to replace the old information.” For example, if you edit your profile information on a website, your computer uses the PUT command to send the updated information to the website’s computer.
- DELETE: This magic word is used to delete information on another computer. It’s like saying, “Get rid of this, please.” For example, if you delete a post on social media, your computer uses the DELETE command to tell the social media website’s computer to delete the post.
For example, you might use the “GET” command to ask the elves’ computer to give you information about your order. Then, the elves’ computer sends a message back to the API gateway with the information you asked for, like the day your Lembas bread will arrive.
Finally, the API gateway sends that message back to you and Frodo, just like how you and Frodo share secrets with each other. And just like that, you know when your Lembas bread will arrive!
APIs use special magic to talk to other computers and obtain information, such as the delivery date of your order of Lembas bread. To use an API, you need to know the URI to locate the other computer, use the API gateway to communicate with it, specify which part of the computer you want to interact with using the API endpoint, and use HTTP commands to request information.
IT integration can help organizations streamline their operations, reduce manual tasks, and improve data accuracy by ensuring that data is consistent across different systems. Additionally, it can enhance collaboration and communication between different departments or teams and enable organizations to create new and innovative services or products by leveraging data from multiple sources.