Web Application Programming Interfaces (API)

Have you ever wondered how you see dynamic(constantly changing over time) data on a website or a mobile application? Are you heard about a term called API before? Don’t worry let's find out about it.

🔎 Web APIs

In computer programming, Application Programming Interface (API) is a system that allows two systems to communicate and interact with each other. Web APIs is the APIs that uses the internet as a transferring medium between these two parties. It uses a request-response messaging system and standards like JSON, XML as a message body. These APIs have one or more endpoints that exposed via an HTTP web server.

Web APIs

📡 Web APIs Use Cases

Abstracting the communication between the database and the systems that are using those data is the main use case of a Web API. Imagine there is a social media website that users can access via a web browser. After some time to improve mobile users experience you may need to provide a mobile application. So the requirement is to have access from multiple different systems to a common database. Web APIs comes to help in this situation. The client-side web applications that run on browsers can access a Web API via HTTP requests. The mobile application also has the capability to communicate over the internet and get the data from an API. So, by using a web API we can provide a common data access endpoint that can be used to get the data via the internet without worrying about the system type.

💠 Example Web APIs

There are multiple types of web APIs. Most popular web API type is REST APIs that still uses by many companies. However, GraphQL APIs are rising over the REST approach due to their techniques for minimizing resource usage and smooth user experience. For example, Facebook is now using GraphQL in their all web and mobile applications. Let’s find out more about these two approaches.

REST API

Representational State Transfer(REST) is a set of rules that defines a standard Web API. When there is a well-known standard anyone can easily develop the applications that use those data and integrate.

Usually REST API support CRUD(Create, Read, Update, Delete) operation as in the database via HTTP requests. Following is a scenario that the client requests user data related operations via REST API endpoints such as users/<id> and users/<id>/posts.

How REST API works

GraphQL API (Developed by Facebook)

Overcome the over-fetching problems in the REST APIs, GraphQL became a revolution in the API industry. It allows the client-side application to send a query in a request that describes what data they need from the server rather than traditional endpoints that have pre-defined schemas in REST APIs. Using GraphQL we can request data at once that may need multiple requests in rest. Also, we get only the data that we request. No additional resources are wasted for non-using data transferring.

How GraphQL works

⛔ Limitations

Like all other technologies, Web APIs also has its own set of limitations.

  • Latency in request processing and also depend on network speed.
  • Some approaches are over-fetching data.
  • Changes in the database may require a change in the API as well.

Most of these limitations also have some kind of solutions by now. For example, caching in the client-side used to make a smooth experience and hide any latency from the user.

That's all about Web APIs for now. Stay Safe! 🏡

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store