API's In Web Development

API's In Web Development

Hello Everyone!

There I was. Sitting in front of the monitor. Wondering what to write for my first ever blog. You know I always had this habit of writing things down whenever I tend to learn something. Deep down there is a part of me which is totally into Computer Science background. I've always been that kind of person to whom computer and programming is more fascinating than humans. So here I am sharing my knowledge through blogs which I learnt during quarantine times. I guess blogging will help me feel more solicitous and pertinacious .

Ok so lets get into the topic :

To begin with basics , API stands for Application Programming Interface. A Web API is an application programming interface for the Web. APIs provide a set of protocols, routines, and developer tools enabling software developers to extract and share information and let applications interact in an accessible manner. They abstract more complex code away from you, providing some easier syntax to use in its place.

what-is-an-api.jpg

As a real-world example, think about the electricity supply in your house, apartment, or other dwellings. If you want to use an appliance in your house, you plug it into a plug socket and it works. You don't try to wire it directly into the power supply — to do so would be really inefficient and, if you are not an electrician, difficult and dangerous to attempt.

In the same way, if you want to say, program some 3D graphics, it is a lot easier to do it using an API written in a higher-level language such as JavaScript or Python, rather than try to directly write low level code (say C or C++).

What can APIs do?

There are a huge number of APIs available in modern browsers that allow you to do a wide variety of things in your code.

APIs are used for manipulating documents loaded into the browser. The most obvious example is the DOM (Document Object Model) API, which allows you to manipulate HTML and CSS — creating, removing and changing HTML, dynamically applying new styles to your page, etc.

apis.jpg

APIs that fetch data from the server to update small sections of a webpage on their own are very commonly used. This seemingly small detail has had a huge impact on the performance and behavior of sites — if you just need to update a stock listing or list of available new stories, doing it instantly without having to reload the whole entire page from the server can make the site or app feel much more responsive and "snappy".

How do APIs work? (An abstraction)

Let’s use a metaphor to explain how an API works.

Imagine you’re a customer at a restaurant. The waiter (the API) functions as an intermediary between customers like you (the user) and the kitchen (web server). You tell the waiter your order (API call), and the waiter requests it from the kitchen. Finally, the waiter will provide you with what you ordered.

How_Do_APIs_Work_.png

The waiter is the intermediary between you and the kitchen. In this metaphor, the waiter is effectively an abstraction of the API. In software engineering, an abstraction is a fundamental concept that aims to simplify a complex mechanism by only focusing on the details of higher importance. In this example, as a customer, you don’t need to know how the kitchen or the restaurant operates in order to get what you want: the food. You just need to know how to order it.

An API is also an abstraction of the web server. The application (such as a website or a mobile app) will make an API call for a set of data to display for the end user to consume. The request is made via the API that accesses the web server to retrieve the requested data, which is populated in the user interface.

Web API Protocols

REST (Representational State Transfer) is widely considered the standard protocol for web APIs. Other protocols used for Web APIs include Soap and JavaScript.

There are four parts of a REST API request:

  • URI (uniform resource identifier, which is the URL address, also known as an “endpoint”)
  • HTTP method (most commonly either GET or POST)
  • Headers (which include authentication tokens, define the data format of the response)
  • Body (the actual part of the request)

What are the benefits of APIs?

APIs are all over the web, and are therefore common in modern business. Due to their ease of use, there’s been a huge increase in API usage among platform and infrastructure businesses.

api.jpg

Although the target audience for for a web API is usually the web development community, they can also be beneficial to end users as well as the API providers themselves.

  • Web Developers: Web APIs allow advanced functionality and features to be integrated into the websites that they create. There is also greater customization and flexibility with Web APIs than standard "copy and paste" widgets.
  • End Users: A good Web API can help increase the usefulness of a website and make the site interactive and more enjoyable.
  • API Providers: A well built API that is widely used by the web development community can be a powerful marketing tool because it can:

Takeaways

APIs have been a game-changer for modern software. The rise of the API economy not only enables software companies to rapidly build in key functionality that might previously have taken months or years of coding to implement, but it has also enabled end users to connect their best-of-breed apps and flow data freely among them via API calls .APIs have been around for a long time and will continue to be as long as businesses utilize them as part of their operations. They are very versatile and quick to implement.

img178.jpg