What is an API?
API stands for Application Programming Interface, which is a software intermediary that allows two applications to talk to each other. Each time you use an app like Facebook, send an instant message, or check the weather on your phone, you’re using an API.
An API is a set of definitions and protocols for building and integrating application software.
APIs let your product or service communicate with other products and services without having to know how they’re implemented. This can simplify app development, saving time and money. When you’re designing new tools and products—or managing existing ones—APIs give you flexibility; simplify design, administration, and use; and provide opportunities for innovation.
Login API: Most of the APIs are same for a single application. For Example: Login API. No matter you are logging in with which device API is same. User from mobile or Desktop submit credentials then Server calls API and API then validate the information and return session token. With a single Login API same user can login on multiple devices. Similarly if you add an item to a cart using desktop browser, you can observe in your mobile application that same item is added automatically. This is because mobile and desktop browser calling same API.
Example 1: Movie Ticket
A real-world example is buying movie tickets online. You go to the movie site, you enter your movie, name and credit card information, name payment, you print out your tickets. But what’s going on between entering your information to receiving your ticket? APIs, that’s what!
They are collaborating behind the scenes with other applications. This type of integration is called "seamless" because you never have a clue when a software role is passed from one application to another.
Example 2: Restaurant
Think of an API like a menu in a restaurant. The menu provides a list of dishes you can order, along with a description of each dish. When you specify what menu items you want, the restaurant’s kitchen does the work and provides you with some finished dishes. You don’t know exactly how the restaurant prepares that food, and you don’t really need to.
Similarly, an API lists a bunch of operations that developers can use, along with a description of what they do. The developer doesn’t necessarily need to know how, for example, an operating system builds and presents a "Save As" dialog box. They just need to know that it's available for use in their app.
List of Real world example APIs
Google Maps: Google maps API allows your custom app to have access to googles mapping services.
Google Analytics: Google Analytics API allows custom dashboards to be built of google analytics data.
Twitter API: Twitter API allows 3rd party apps to allow social login using twitter username/password. Or can enable application to have access to twitter tweets data.
Facebook API: Facebook API allows connectivity and interaction with Facebook and ability to work with ads, games, payment, login or user data.