What are API’s, and how do they work between software or applications?

959 views
0

What are API’s, and how do they work between software or applications?

In: Technology

Kind of like a socket and plug.

One program exposes (some of) its functions and procedures to anyone or anything that knows how to connect to it. Then, another program connects, and uses the functions that have been exposed.

An example would be a site like Facebook. You can post comments, or share, but those are functions within the app/site. By exposing those functions to the world with an API, other apps can now use Facebook’s own code to post content to Facebook.

Another way to think of it, is like a contract where an app states what its capabilities are and how to access it. Then other apps use those rules, and get those services.

An API (application programming interface) is how a program (or other system such as a website) accepts commands or instructions from other programs. It means that, instead of having to spend months writing specific functionality for your own software, you can just make a call to someone else’s API.

For example, someone might write a web-based database system that works out which country a particular IP address belongs to. And to use it, you can go to their web site and type an IP address into the search box, and it’ll return a country name. But the system might also offer an API that you can use, so that you can perform lookups from within your own software or website. So when my web site needs to know where a visitor is located, I just retrieve the visitor’s IP address, make a call to the lookup system’s API, and it sends me the country name. I don’t have to maintain a database of millions of IP addresses.

It works the same with operating systems such as Windows. If I write a program on my PC and I want to play a sound, or display a picture, or save a file, I just call the relevant API from my program.

An API is like a menu at a restaurant. You don’t need to know how the chef works and how the kitchen runs; you just need to know what to ask for.

Likewise, an API for a program tells you what you can ask for, without needing to know how the program works. A game, for example, won’t let people see its code because that could lead to exploits, but there may be an API that lets people request character information from the game so that they can use it on a fan site.

Thank you everyone for your time and effort to explain everything to me. Very helpful.