An application programming interface (API) is a set of rules (code), subroutine, protocols, and specifications that software programs can follow to communicate with each other. It serves as an interface between different software programs and facilitates their interaction, similar to the way the user interface facilitates interaction between humans and computers.

In other words, an API is the interface through which you access someone else's code or through which someone else's code accesses yours.

An API may be for a web-based system, operating system, database system, computer hardware or software library. Technically speaking,  An API specification can take many forms, but often includes specifications for routines, data structures, object classes, variables or remote calls. Microsoft Windows API, Google APIs,  the C++ Standard Template Library, REST API, and Java APIs are examples of different forms of APIs.

Some practical examples where APIs are used frequently:

Policy Bazaar, Yatra.com, Goibibo, Foodpanda, Zomato like websites are very good example where APIs are used a lot. These websites interact with various provider websites using APIs to fetch you the results for comparison based on which you select the best deal.

Another example can be taken from Online shopping using Internet Banking where you buy a product from a shopping site (say Amazon, Flipkart etc.) and while you pay for it using your credit card through shopping site, it takes you to the bank gateway/website for authentication, credentials verification, and payment. There is a lot of  interaction going on in the background b/w the applications that happens with help of APIs.