API is the acronym for Application Programming Interface, which is a software intermediary that allows two applications to talk to each other.
Understanding the API
When you use an application on your mobile phone, the app connects to the internet and sends data to a server. The server then retrieves that data, interprets it, performs the necessary actions and sends it back to your phone. The application then interprets that data and presents you with the information you wanted in a readable way. This is what an API is - all of this happens via API.
To explain this a litte better...
Imagine you are sitting at a table in a restaurant with a menu of choices to order from. The kitchen is the part of the "system" that will prepare your order. What is missing is the citical link to communicate your order to the kitchen and deliver your food back to your table. That is where the waiter or API comes in. The waiter is the messenger - or API - that takes your request or order and tells the kitchen - the system - what to do. Then the waiter delivers the response back to you; in this case, it is the food.
To understand this example in more detail, visit
Mulesoft.com
Process of Using an API
-
In general, APIs define the rules that programmers must follow in order to interact with a programming language, a software library, or any other software tool. Lately, the term API is most often used to describe a particular kind of web interface. These web APIs are a set of rules for interacting with a webserver, with the most common use case being data retrieval.
-
The user makes a “request” to a webserver, that webserver accesses a database (with the customers data), and returns it to the requester in a "response". This request/response cycle is used when you access webpages in your browser.
-
Web API Request vs Web Page Request. A website returns HTML, CSS and JavaScript which work together with your browser to render a webpage. Web APIs respond to data in raw format, not intended to be rendered by a browser into a user experience (JSON and XML are the most common formats used for raw data).
When to use an API
- Because the APIs simply provide data, there are no limits on how a company can then go on to use that data. Furthermore, these programs can be automated to run on a schedule, reducing the need for someone to navigate the complex steps of exporting data manually. For instance, let's say on a Wordpress site you need a weather section of some sort, and instead of building it from scratch, the developer can simply access an existing weather API and retrieve the needed data and style accordingly.
- Another benefit of Web APIs is that, because they are built around the HTTP protocol, nearly any programming language can be used to access them.
Downsides of an API
- Just because an API is available now, that does not mean it will always be. Companies can shut down services and APIs that your applications depend on - or they can go out of business entirely, leaving the portion of your website that relied on it without function.
- APIs can also be entirely complex. Sometimes it will be more cost and time efficient to NOT use an API. Figuring out and learning the API can take longer than anticipated. It is good to research the API entirely, even the most reliable source can change. A good live example of this is the Twitter API. Twitter notoriously limited third-party applications' use of its APIs just over a year ago - a move that had the practical effect of killing off alternative Twitter clients and driving users to Twitter's own site and apps, where Twitter can monetize them by displaying ads/promoted tweets.
- API Version Developers update their APIs from time to time. Sometimes, the API can change so much that the developer decides to upgrade their API to another version. Not keeping the API up-to-date breaks the application. Meaning, someone must always be checking whether there is a new version out and check whether certain syntax changed and apply those changes to your current app/site.