JavaScript Tutorial

Web APIs - Introduction

A Web API has below features:

  • It allows for extending the functionality of the browser.
  • It aids in simplifying complex functions.
  • It provides a user-friendly syntax for complex code.

What is Web API?

A Web API, which stands for Application Programming Interface, is an interface provided by a web application or service that allows other software applications to interact with it. It defines a set of rules and protocols for how different software components should communicate with each other.

A Web API specifically refers to an API that is designed for web-based applications and services. It enables developers to access and utilize the functionalities provided by the web application or service, such as retrieving data, performing actions, or interacting with specific features.

There are two main types of Web APIs:

  • Browser APIs
  • Server APIs

Browser APIs

These are APIs provided by web browsers themselves, allowing developers to extend the functionality of the browser. Browser APIs provide capabilities such as manipulating the DOM (Document Object Model), making HTTP requests, accessing device features (like geolocation or camera), and more.

For example, the Geolocation API is used to return the coordinates of where the user’s browser is located.

Example :-

Server APIs

These are APIs provided by web servers or web services, allowing developers to extend the functionality of the server-side application or service. Server APIs enable functionalities like data retrieval, data modification, authentication, and various operations specific to the server or service.

Server APIs are APIs provided by the web server or web service itself. These APIs are built and maintained by the organization or team behind the web application or service. Server APIs enable functionalities such as data retrieval, data modification, authentication, and various operations specific to the server or service.

  1. RESTful APIs: Representational State Transfer (REST) APIs are a popular type of server API that follows a set of architectural principles. They use HTTP methods (such as GET, POST, PUT, and DELETE) to perform operations on resources. RESTful APIs are widely used for building web services and allow clients to interact with the server by sending requests and receiving responses in a standardized format, such as JSON or XML.

  2. GraphQL APIs: GraphQL is an alternative to RESTful APIs that provides a flexible query language for clients to request specific data from the server. With GraphQL APIs, clients can specify the exact data they need, reducing over-fetching and under-fetching of data. GraphQL APIs allow clients to retrieve related data in a single request and are known for their efficiency and flexibility.

Third-Party APIs

Third-party APIs, in the context of web APIs, refer to APIs that are provided by external parties or companies, separate from the web application or service being developed. These APIs are created and maintained by third-party providers and offer specific functionalities or services that developers can integrate into their own applications.

They allow developers to access and use services such as social media integration (e.g., Facebook, Twitter), payment gateways (e.g., PayPal, Stripe), mapping and geolocation services (e.g., Google Maps), weather data, image recognition, and many others.

Here's an example:

  • Payment Gateway APIs: Payment gateway APIs are server APIs provided by payment service providers (such as PayPal, Stripe, or Braintree) to facilitate online payment transactions. These APIs allow developers to integrate payment functionality into their applications, enabling users to make payments securely and efficiently.
Go back to Previous Course