API Testing Interview Questions
API Testing Interview Questions
EBRAHIM HOSSAIN
SQA Engineer at
What are the main differences between API and Web service?
All Web services are APIs but not all APIs are Web services. Web services might not contain
all the specifications and cannot perform all the tasks that APIs would perform.
A Web service uses only three styles of use: SOAP, REST, and XML-RPC for communication
whereas API may be exposed to in multiple ways.
A Web service always needs a network to operate while APIs don’t need a network for operation.
API testing is a kind of software testing that determines if the developed APIs meet expectations
regarding the functionality, reliability, performance, and security of the application.
SQA Engineer at
Web API can be consumed by any clients that support HTTP verbs such as GET, PUT,
DELETE, and POST. Since Web API services do not require configuration, they can be easily
used by any client. In fact, even portable devices such as mobile devices can easily use Web
API, which is undoubtedly the biggest advantage of this technology.
SQA Engineer at
SQA Engineer at
What are the testing methods that come under API testing?
One of the most common Web API testing interview questions is about the testing methods.
They are:
1. Unit testing and Functional testing
2. Load testing to test the performance under load
3. Discovery testing to list, create, and delete the number of calls documented in the API
4. Usability and Reliability testing to get consistent results
5. Security and Penetration testing to validate all types of authentication
6. Automation testing to create and run scripts that require regular API calls
7. End to end Integration and Web UI testing to determine its efficiency and effectiveness
Why is API testing considered the most suitable form for Automation testing?
API testing is now preferred over GUI testing and is considered as most suitable because: It
verifies all the functional paths of the system under test very effectively. It provides the most
stable interface. It is easier to maintain and provides fast feedback.
SQA Engineer at
Not only API fundamental questions, the interviewer also determines your knowledge and
experience by asking about the API errors in a Web API testing interview. So the most common
ones are: Missing module errors Documentation errors Parameter validation errors And some
standard error expectations if the result is not so predicted then the occurrence of errors can be
seen and for the same warnings are specified in the form of a message. There can be one or
more warnings within an individual module.
How often are the APIs changed and, more importantly, deprecated?
APIs, especially modern RESTful APIs, are a nice creation that can certainly simplify and
accelerate integration efforts, which makes it more likely you will benefit from them. But APIs
can and do change for various reasons, sometimes abruptly, and hence REST APIs do not
differ from traditional integration methods in this respect. If an API call is obsolete and
disappears, your procedure will be interrupted and it is important to understand how often the
APIs you depend on change or are deprecated.
What is REST?
REST (Representational State Transfer) is an architectural style for developing web services
that exploit the ubiquity of HTTP protocol and use the HTTP method to define actions. It
revolves around a resource where every component is a resource that can be accessed through
a shared interface using standard HTTP methods. In REST architecture, a REST Server
provides access to resources and REST client accesses and makes these resources available.
Here, each resource is identified by URIs or global IDs, and REST uses multiple ways to
MD. EBRAHIM HOSSAIN
SQA Engineer at
represent a resource, such as text, JSON, and XML. XML and JSON are the most popular
representations of resources nowadays.
SQA Engineer at
2. Uniform Resource Identifier (URI), which is the identifier for the resource on the server.
3. HTTP Version, which indicates the HTTP version, for example HTTP v1.1.
4. Request Header, which carries metadata (as key-value pairs) for the HTTP Request
message. Metadata could be a client (or browser) type, format supported by the client, format of
a message body format, cache settings, and so on.
5. Request Body, which indicates the message content or resource representation.
What are the most commonly used HTTP methods supported by REST?
GET is only used to request data from a specified resource. Get requests can be cached and
bookmarked. It remains in the browser history and has length restrictions. GET requests should
never be used when dealing with sensitive data.
POST is used to send data to a server to create/update a resource. POST requests are never
cached and bookmarked and do not remain in the browser history.
PUT replaces all current representations of the target resource with the request payload.
DELETE removes the specified resource.
OPTIONS is used to describe the communication options for the target resource.
HEAD asks for a response identical to that of a GET request but without the response body.
Which purpose does the OPTIONS method serve for the RESTful Web services?
The OPTIONS Method lists down all the operations a web service supports. It creates read-only
requests to the server.
What is URI?
MD. EBRAHIM HOSSAIN
SQA Engineer at
What is the main purpose of REST-based web services and what is its format? URI stands for
Uniform Resource Identifier. It is a string of characters designed for unambiguous identification
of resources and extensibility via the URI scheme. The purpose of a URI is to locate a
resource(s) on the server hosting of the web service.
SQA Engineer at
1. Postman is an API platform for developers to design, build, test, and iterate their
APIs.
2. We can say Postman is an API platform for building and using APIs.
3. Postman is an API (application programming interface) development tool that helps to
build, test and modify APIs. Almost any functionality that could be needed by any
developer is encapsulated in this tool.
4. It is used by over 5 million developers every month to make their API development
easy and simple.
A collection in Postman helps to group similar requests. It helps in systematically arranging the requests
into folders. Consider the Below example -
1. It is free: Postman is free software that we can use for API testing. It is free to
download and use for teams of any size.
2. It is easy to use: Postman is an easy-to-use software tool. We can send HTTP
requests of various types (such as GET, POST, PUT, PATCH, etc.). We have to
download it, and we can send our first request in minutes. It also gives us the ability to
save environments for future use.
3. Community & Support: It has a huge community forum for customer support and
extensive documentation.
4. It is extensible: Postman facilitates us customizing it according to our needs with the
Postman API.
5. APIs Support: It facilitates us to make any API call (REST, SOAP, or plain HTTP)
and easily inspect even the largest responses. It also helps manage the end-to-end
MD. EBRAHIM HOSSAIN
SQA Engineer at
lifecycle of the API - starting from design to mocking to testing and finally
maintaining the APIs.
6. Runtime Services: Postman provides Runtime Services that help us manage API
collections, environments, workspaces, and different examples.
7. Integration: Postman facilitates us to easily integrate test suites into our
preferred CI/CD tools and services, such as Jenkins with Newman(command-
line collection runner).
console.log(pm.variables.get("variable_name"));
● GET
● POST
● PUT
● PATCH
● DELETE
How are Query Params different from Path Variables?
Path Variables are used for identifying specific resources and Query Parameters are used for sorting or
filtering the resources.
MD. EBRAHIM HOSSAIN
SQA Engineer at
The scope of global variables is limited to the workspace and is global. Due to this, variables
having global scope cannot have the same names. We can have the same names for local
variables but they need to be part of different variables.
Monitoring is a method of staying in sync with the health and performance of the APIs. Postman
provides inbuilt monitoring services that help us be in sync with the API development and
performance. The monitors provided by Postman are mainly based on the working of collection
MD. EBRAHIM HOSSAIN
SQA Engineer at
runners.
The binary form is designed to help send data in a format that is not possible to be entered
manually. These options are used while sending large files like images, CSV files, etc in the
POST request. Binary representation is the easiest representation for sending complex data
with the request.
● Tests script
● Pre-request script
MD. EBRAHIM HOSSAIN
SQA Engineer at
The 301 status code represents permanent redirects from one website page to another. It tells the search
engine that the old page is outdated and the engine has to index the new page URL.
All the requests you send in Postman appear under the History tab of the sidebar. It is very
much similar to browser history, which you can clear whenever you want.
SQA Engineer at
The Payload of an API Module is the body of your request and response message. When making an API
request, it contains the data you send to the server. You can send and receive Payload in various
formats, for example, JSON or XML.
Pre-request scripts help you to execute JavaScript before a request runs. It allows you to accomplish pre-
processing tasks like setting variable values, parameters, headers, and body data.
The environment in Postman is a set of key-value pairs. Postman allows you to build multiple
environments and switch among them with a click of a button.
MD. EBRAHIM HOSSAIN
SQA Engineer at
Postman monitors allow you to import local variables but not global variables.
Can you have two global scope variables with the same name in Postman?
No, the global scope never has duplicate/same names, while variables having local scope can have the
same name in various environments.
Postman contains a collection runner that is useful for automating API testing. It helps
visualize the details of each iteration and test results. A postman collection runner is also
used for Data-driven testing.
You should not save your work in Postman as your business details do not remain confidential.
Moreover, saving your on-Postman cloud may cause a security breach as it requires sign-in.
Therefore, saving your work in the Postman cloud is not advisable.
1. Lodash
2. Moment
3. GUID
What is GUID?
GUID is short for Global Unique Identifier. It is hexadecimal digits that are separated by hyphens. This
Postman identifier GUID solves the purpose of uniqueness.
MD. EBRAHIM HOSSAIN
SQA Engineer at
setNextRequest helps you to define the workflow. It is needed to change the order of the
requests being executed.
What test code allows you to check whether the response status is 200 or not?
Following is a test code to check whether the response status is 200 or not: tests
pm.response.to.have.status(200);
});
Describe any four response things you receive from a response (Correct or Incorrect)
Status Code
1. Response Status
2. Response time
3. Response Size
4. Response Headers
5. Response Cookies
6. Response Date and Time
7. Response Session limit
8. Response Cookies
9. Response Server
10. Response type
SQA Engineer at
Can you read the Postman Chrome application to read and write cookies?
The Postman API testing tool is currently available for Mac, Windows (32-bit / 64-bit), and Linux
(32-bit / 64-bit).
Status code 201 is created only when a resource is successfully created using a PUT or POST
request. It returns a link to a newly created one with the help of the location header.
What are the different types by which we can see the response body in Postman?
Explain.
MD. EBRAHIM HOSSAIN
SQA Engineer at
1. Pretty
2. Raw
3. Preview
Although all three have their own importance and value in Postman, the most commonly used is Pretty as
it shows the response code in different formats and colors which makes it easy to read and analyze the
response. It is just like any good text editor used for coding
Why do we group requests under collections when collection is already a grouping of requests?
A collection may have hundreds of requests under it. We need to subcategorize the requests according to
a more specific category so that it is easier for us to find them, edit them, or modify them. For this, we use
folders in collections. A collection may have many folders inside it and a folder may have many requests.
This way we can generalize the types of requests to a deeper level than the collections which are already
generalized. For ease, a collection can be considered a folder "Movies" in your system which has all the
movies. A folder can be considered as different folders inside "Movies" like Hollywood, Bollywood, etc
which have respective types of movies.
Which method should you prefer? Javascript or Functional to write the tests?
It is advised and recommended to use the functional method while writing tests in Postman. Although
there has been no notice of ending the support for the JS method.
It is very important that your API’s responses and performance remain up to the mark
throughout the day. Monitors can help you schedule a collection of test runs to monitor the
performance and response of your APIs even if you are not available or not handling them.
No, monitors cannot be run without signing in because monitors run your collection even if
your system is shut down. So, you need a place to store the collection and let it run
automatically. You also need a place to store the reports so that you can look at them when
MD. EBRAHIM HOSSAIN
SQA Engineer at
you are free. This all needs to be saved into your Postman account and hence you need to
sign in
Chai assertion library is an assertion library that is installed beforehand to use in Postman. This is used to
write assertions in Postman which is very beneficial. Chai assertion helps us write many lines of test code
in a few lines which is both understandable and readable. Chai uses the BDD approach which means that
the Chai library has codes that are more user-friendly.
A simple code is written in the chai library which tests if number 3 is already in the array or not.
What command line interface is used with Postman normally to serve continuous integration.
Newman is used with Postman normally as a command line interface to serve continuous
integration.
Postman has a command-line integration tool called Newman with which you can run any existing
Postman collection.
Newman is a node js-based package, which requires just a node environment to execute the collection
and has full parity with the Postman collection runner i.e. the Newman collection runner supports the
Postman capabilities like Running assertions, Pre-request scripts or any other scripts that are associated
with the requests that are a part of the collection.
To use Newman:
MD. EBRAHIM HOSSAIN
SQA Engineer at
How can you generate HTML based reports running tests through the Postman?
Newman uses the concept of reporters and templates to generate HTML reports for the executed
collection. Hence, to generate HTML reports, you first need to install a reporter. You can install any of the
available HTML reporters like Newman-reporter-html as a node package through the below command.
Once the HTML reporter is installed, we can use the Newman command to run the collection with -r flag
i.e. the reporter flag, and specify the reporter name as HTML.
newman run {{path to collection json}} -e {{path to environment json if any}} -r html
Base64 encoding is primarily used because it does the task of data transmission in a textual
format that is easier to send in the requests in HTML form statistics format.
Another reason why we use this is that using identical 64 characters for encoding is heavily
reliable in any language we use.
Why does Postman never accept any other encoding apart from Base64?
You can use base64 as it helps us transmit the data into the textual form and send it as HTML form data.
Moreover, we must rely upon the same 64 characters in any encoding language.
1. Global Variables
MD. EBRAHIM HOSSAIN
SQA Engineer at
2. Local Variables
3. Environment Variables
4. Collection Variables
5. Data Variables
Scratch Pad is a space provided by Postman that helps us to work without being connected to
Postman servers. It provides the flexibility of utilizing some of the features of Postman offline.
The features include- collection creation, creating requests, and the ability to send requests.
These are stored locally and once logged in, the work is saved into the workspace.
For all the requests in a collection, the scripts will execute in the following order:
Step 1) A pre-request script associated with a collection will run before every
request.
Step 2) A pre-request script associated with a folder will run before every request in a specific
folder.
Step 3) A test script associated with a collection will run after every request.
Step 4) A test script associated with a folder will run after the request in the specific folder.
How will you stop the execution of upcoming requests or Stop the execution of the
collections?
A:- We can use the below code to stop the execution of the next request:
pm.setNextRequest(null);
Pre-request scripts are those scripts that are used for executing Javascript code before a
request is run. It is used for performing pre-processing tasks like setting variables, parameters,
headers, body data, etc., are performed using it.
How can we use Custom Javascript libraries in our scripts with an example?
MD. EBRAHIM HOSSAIN
SQA Engineer at
Postman provides a lot of built-in tools and libraries that we can use to add in our pre-request
or post-request scripts or test cases. Let us take the example of using the moment.js library. It
provides a lot of useful functions to format data around time. Consider that we have a POST
request that needs to specify the created date to the user which expects the format
“DD/MM/YYYY”. We can use the moment library to perform this using a single line of code. In
our pre-request script, we need to add the below lines of code to get the correctly formatted
data and then store that in an environment variable:
If we have a global and a local variable of the same name, which one will be given the
most preference in Postman?
In such cases, the higher precedence is given to the local variable by overwriting the value of
the global variable.