The Ultimate Guide on API Testing with Complete Automation

API Automation with Rest Assured library

What is an API ?

API is an interface that allows communication between client to server to simplify the building of client-server software.

API is an software that allows two applications to talk to each other. Each time you use an app like Facebook, send an instant message, or check the weather on your phone, you’re using an API.

When you use an application on your mobile phone, the application 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 all possible with an API.

Difference between Types of API’s [ SOAP v/s REST ]

REST: Representational State Transfer. It is an lightweight and scalable service built on REST architecture. It uses HTTP protocol. It is based on architectural pattern

Elements of REST API:

  • Method: GET, PUT, DELETE
    • POST – This would be used to send the data to the server such as customer information or uploading any file using the RESTful web service. To send the data use Form parameter and body payload.
    • GET – This would be used to retrieve data from the server using the RESTful web service. It only extracts the data there is no change in the data. No Payload or body required. To get the data use query parameter.
    • PUT – This would be used to update the resources using the RESTful web service
    • DELETE – This would be used to delete * using the RESTful services
  • Request Headers: These are additional instructions that are sent along with the request
  • Request Body: Data is sent along with the POST request that is it wants to add a resource to the server.
  • Response status code: Returned along with the request such as 500, 200 etc.

Characteristics of REST

  • REST is an Architectural style in which a web service can only be treated as a RESTful service if it follows the constraints of being 1. Client Server 2. Stateless 3. Cacheable 4. Layered System 5. Uniform Interface
  • Stateless means that the state of the application is not maintained in REST .For example, if you delete a resource from a server using the DELETE command, you cannot expect that delete information to be passed to the next request. This is required so that server can process the response appropriately
  • The Cache concept is to help with the problem of stateless which was described in the last point. Since each server client request is independent in nature, sometimes the client might ask the server for the same request again
  • REST use Uniform Service locators to access to the components on the hardware device. For example, if there is an object which represents the data of an employee hosted on a URL as , the below are some of URI that can exist to access them

SOAP: Simple Object Access Protocol.

  • Follows strict rules for communicate between [client-server] as it doesn’t follows what is being followed by REST follows Uniform Interface, Client-Server, Stateless, Cacheable, Layered System, Code.
  • SOAP was designed with a specification. It includes a WSDL file which has the required information on what the web service does in addition to the location of the web service.
  • The other key challenge is the size of the SOAP messages which get transferred from the client to the server. Because of the large messages, using SOAP in places where bandwidth is a constraint can be a big issue.
  • SOAP uses service interfaces to expose its functionality to client applications. In SOAP, the WSDL file provides the client with the necessary information which can be used to understand what services the web service can offer.
  • SOAP uses only XML to transfer the information or exchanging the information where as REST uses plain text, HTML , JSON and XML and more.

Application Programming Interface theory (API-theory)

  • When Website is owned by single owner such as Google: In that case when frontend site needs to connect to backend site then it may vary with different languages and can cause lot of compatibility issues such as frontend uses Angular and backend uses Java , so you would need API to deal with it.
  • When Your client needs to access data from your website then you would need to expose the API rather than exploring your entire code and packages.
  • When client connects to another client or server using API the transmission of data takes places using either XML or JSON which are language independent.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s