RestAssured#1 - Introduction To API
Topics
What is an API?
API stands for application programming interface. It is a set of functions that allows applications to access data and interact with external software components, operating systems. An API is a software-to-software interface that defines the contract for applications to talk to each other over a network without user interaction.
As per Wikipedia - An application programming interface (API) is a connection between computers or between computer programs. It is a type of software interface, offering a service to other pieces of software. In contrast to a user interface, which connects a computer to a person, an application programming interface connects computers or pieces of software to each other.
Purpose - 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.
In building applications, an API (application programming interface) simplifies programming by abstracting the underlying implementation and only exposing objects or actions the developer needs. While a graphical interface for an email client might provide a user with a button that performs all the steps for fetching and highlighting new emails, an API for file input/output might give the developer a function that copies a file from one location to another without requiring that the developer understand the file system operations occurring behind the scenes.
Examples of API usage
1. Weather Snippets - One common API usage example we come across on a daily basis is weather data. This is one of common feature of smartphone and can also be found on other platform like Google's search, Apple's weather search. All of this applications use API to fetch weather details.
2. Travel/Hotel Booking - In travel websites we can find multiple flight details based on our search criteria. These travel sites uses API's to find relevant flight from multiple airlines.
As we can see that API's provides an interface to consume service from other application by abstracting underlying implementation of that application.
How do API work?
An API is a set of rules that define how computers, applications, or machines can talk to each other. Most web APIs sit between the application and the web server. The user initiates an API call that tells the application to do something, then the application will use an API to ask the web server to do something. The API is the middleman between the application and the web server, and the API call is the request. And every time you use software to communicate with other software or online web servers, you’re using APIs to request the information you need.
It’s important to note that while web APIs are the most common, APIs aren’t limited to the web. There are APIs for virtually every machine or system that expects to interact with other machines or systems.
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.
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.
领英推荐
Types of API
What is webservice and its type?
A Web service is a software application with a standardised way of providing interoperability between disparate applications. It does so over HTTP using technologies such as XML, SOAP, WSDL, and UDDI. Web services have the advantage of allowing programs developed in different languages to connect with one another by exchanging data over a web service between clients and servers.
A Web Service is can be defined by following ways:
- It is a client-server application or application component for communication.
- The method of communication between two devices over the network.
- It is a software system for the interoperable machine to machine communication.
- It is a collection of standards or protocols for exchanging information between two devices or application.
Types of Webservice
Difference between API and Web service?
- Web Services provide interaction between two machines over a network while APIs acts as an interface between two different applications for interoperability.
- Web Services requires a network connection while APIs may or may not require a network for their operability.
- While APIs can use any protocols or design patterns, web services mostly use REST, SOAP , XML-RPC, or UDDI.
- Many public APIs are transparent with open documentation and self-service portals for rapid developer onboarding. However, web services offer specific data or functionality to certain patterns only.
- Moreover, each web service is an API but all APIs are not web services because a web service might not perform all the operations that an API would do.
- APIs features efficiency, wide reach, personalization, data ownership, time-effectiveness, programming language independence, and easy integration with GUI; Web Services offer loose coupling, synchronous and asynchronous functionality, document exchange support while supporting remote procedure calls.
- Web Services provides support for HTTP only while APIs support HTTP/s, URL Requests/Response Headers and so on.
QA Manager || Alumni IIM Indore || Project Management -Indian Institute of Management, Indore, Mindtickler || Certified Scrum Master || Ex-Amdocs | QA Automation Engineering || Ex Fiserv
3 年Anushka Chaube
Software Test Analyst at Encora
3 年Nice Artical