What Are API'S and How do They work?

 When you hang around programmers, you might have heard about APIs and how they can be used to perform certain tasks or retrieve some data. But what are these exactly, and why were they created? Let me explain the matter with an easy , non-IT related example.


When you attend a restaurant and order some food, you interact with the waiter. You can order food and drinks, ask questions about the menu, request and pay the bill, and much more.  this example, the waiter is protected you from all the complicated stuff that happens behind the scenes. You don’t need to worry about stoves, ovens, dishes, managing stock, or pouring drinks. He is the interface between you and every one of the services that a restaurant offers. Giving you how to interact with the restaurant while still shielding you from all the complexity behind the scenes. In a way, the waiter are often seen because the API of the restaurant, and thru this instance , you intuitively understand why they're useful.

The term API stands for Application Programmable Interface, and it’s a way for different programs to work together in various ways. There are many types of API’s and reasons why they are used. I’ll highlight 4 of them here: For starters, API’s can be used to get access to data from third parties. In the restaurant example, the waiter can provide you information on the status of your order, without you having to go to the kitchen yourself. Another example would be the weather app on your phone. Google or Apple have not gone out and put temperature sensors all over the world. No, instead these apps use the API of a third-party to retrieve weather predictions. Apple for instance is using the API of The Weather Channel. The API’s allow others apps and services to exchange information. These days, it’s hard to find a service that doesn’t have an API.

There are API’s to lookup recipes, lyrics, information on barcodes, zip codes, available parking spaces, public holidays, and so on and so on. Aside from just accessing data, API's can also be used to hide complexity and perform tasks. In the restaurant example, you don’t need to know how to prepare a perfect roll of Sushi, you just order one. Other example would be the operating systems on our phones and computers . App developers don’t have to worry about setting up a WiFi connection, drawing shapes onto the screen to make a beautiful user interface or how to talk to the various sensors like the accelerometer or GPS. No, instead the operating system gives developers a bunch of API’s that simplify all of this. If an app wants to show a button on the screen, it just asks the system to render one. The app doesn’t need to worry about what device it's running on, what hardware it's , screen resolution, or anything like that.

It makes developers more efficient because they will specialise in what matters to them. But aside from accessing data and abstracting complexity, API's can also be used to extend functionality. For instance, on iOS, applications can show a widget in Notification Center. And to do that, the app notifies the system through an API that it has a widget available. And if the user adds it to their Notification Center, the system will contact the app to ask how it should display the widget. Another example is Siri, Google Assistant or Alexa. These personal assistants are quite clever but external developers can use the assistant’s API to extend the functionalities even further. My Google Home for instance didn’t know how to turn my smart plugs on and off. But that changed, when the seller integrated with the Google Assistant through its API. Suddenly, Google became aware of the new hardware, its capabilities and how to interact with them. Nice! You might not realize it, but API’s are all around us. You’ve probably seen messages like these, your phone posing for permission to use your location or microphone. That brings us to the final use case: API’s can be used as gatekeepers.

For instance, on mobile platforms, the system only features a few API’s which will be wont to get your location. and since it’s centralized within the system, it’s very easy for iOS or Android to notify you when an app is using your location. So it’s not the app that's being nice, and asks permission first. No, it’s the system that does it for them. There’s no way around it. What’s more, the system also gives the power to revoke this permission at a later time, do you have to change your mind. So whenever your phone asks you for permission, you recognize that an app is using an API of the system. And one that's privacy sensitive. And while that's great, there's a problem with this: usually permission is merely asked once. you would possibly have used your Google or Facebook account to login to a different website or app. It’s easy, fast and convenient. But by doing that, we also give the web site or app the permission to access a number of our data. Like our name or email address. this is often great, because it puts us on top of things of our personal data. If you don’t want to share it, you only deny it. However, the matter here is that sometimes these permissions are long lasting and after a short time we forget what apps or websites we gave permission to access our data. this is often what allowed Cambridge Analytical to gather massive amounts of knowledge through the Facebook API.

They created a “personality quiz” that asked for permission to urge a number of your personal data. However, if you gave it permission, the app could silently access your data for months, albeit you didn’t use it anymore.  So, in short: API’s can act as gatekeepers, protecting our personal data and only giving it bent the apps we elect . But we should always remember about how long those permissions last, and revoke them once we not use an app. So time for a conclusion. API’s are all around us. they're wont to get access to data in order that multiple apps or services can work together. they will also hide complexity for developers, allowing them to not waste time on deciding how GPS works as an example . API’s also can be wont to extend functionality of existing systems and eventually , they will act as gatekeepers to guard our personal data.

I hope this this article brought some clarity to a topic that is mostly discussed among developers. Let me know your thoughts or questions in the comments below




Post a Comment

Previous Post Next Post