0% found this document useful (0 votes)
82 views

API Questions & Answers

API testing involves directly testing application programming interfaces (APIs) and testing them as part of integration testing to check their functionality, reliability, performance, and security. The main focus is on testing the business logic layer. Common API testing types include unit testing, functional testing, load testing, runtime/error detection testing, security testing, and UI testing. Key aspects that need verification in API testing include data accuracy, HTTP status codes, response time, error codes, authorization checks, and non-functional aspects like performance and security. Common documentation tools for APIs include Swagger, FlatDoc, RestDoc, API Blueprint, Slate, Miredot, and Web Service API Specification.

Uploaded by

Prashant Gupta
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views

API Questions & Answers

API testing involves directly testing application programming interfaces (APIs) and testing them as part of integration testing to check their functionality, reliability, performance, and security. The main focus is on testing the business logic layer. Common API testing types include unit testing, functional testing, load testing, runtime/error detection testing, security testing, and UI testing. Key aspects that need verification in API testing include data accuracy, HTTP status codes, response time, error codes, authorization checks, and non-functional aspects like performance and security. Common documentation tools for APIs include Swagger, FlatDoc, RestDoc, API Blueprint, Slate, Miredot, and Web Service API Specification.

Uploaded by

Prashant Gupta
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

What is an API?

In simple words, API stands for Application Programming Interface. API acts as an
interface between two software applications and allows the two software
applications to communicate with each other. API is a collection of software
functions that can be executed by another software program.

What is API Testing?


API testing is a type of software testing that involves testing APIs directly and also
as a part of integration testing to check whether the API meets expectations in
terms of functionality, reliability, performance, and security of an application. In
API Testing our main focus will be on the Business logic layer of the software
architecture.

API testing can be performed on any software system which contains multiple
APIs.

What are the common API Testing Types?


API testing typically involves the following practices:

 Unit testing
 Functional testing
 Load testing
 Runtime/ Error Detection
 Security testing
 UI testing
What is API test environment?
In API testing environment, no GUI (Graphical User Interface) is available.

For API, the test environment is a rather sophisticated approach that configures
the server and database to match the requirement of the software application.
After the installation process is done, API will be verified for correct functioning.

Throughout the process, various parameters for the original environment are
established via API calls to examine the test result

What exactly needs to be verified in API Testing?


Basically, on API Testing, we send a request to the API with the known data and
we analyze the response.
1. Data accuracy
2. HTTP status codes
3. Response time
3. Error codes in case API return any errors
4. Authorization checks
5. Non-functional testing such as performance testing, security testing

List out the different status codes ?


- Please check into API Test cases Document…..

List some most used templates for API documentation?


Some of the API documentation templates are as follows.

 Swagger
 FlatDoc
 RestDoc
 API blueprint
 Slate
 Miredot
 Web service API Specification.
What are the main challenges faced in API testing?
Some of the challenges we face while doing API testing are as follows

 Selecting proper parameters and its combinations


 Categorizing the parameters properly
 Proper call sequencing is required as this may lead to inadequate coverage
in testing
 Verifying and validating the output
 Due to the absence of GUI, it is quite difficult to provide input values

Difference between API and Web services?


Web services:

1. All web services are APIs


2. All web services need to be exposed over web(HTTP)
3. A Web service uses only three styles of use: SOAP, REST and XML-RPC for
communication
4. A Web service always needs a network to operate

APIs:

1. All APIs are not web services


2. All APIs need not be exposed over web(i.e. HTTP)
3. API uses multiple ways for communication e.g. DLL files in C/C++, Jar files/ RMI
in java, Interrupts in Linux kernel API etc.
4. APIs don’t need a network for operation

What is Soap?
SOAP stands for Simple Object Access Protocol. It is an XML based messaging
protocol. It helps in exchanging information among computers.
What is Rest API?
REST stands for Representational State Transfer. It is a set of functions helping
developers in performing requests and receive responses. Interaction is made
through HTTP Protocol in REST API.

Difference between SOAP and REST?


SOAP:
1. SOAP is a protocol through which two computers communicate by sharing
XML document
2. SOAP supports only XML format
3. SOAP does not support caching
4. SOAP is slower than REST
5. SOAP is like a custom desktop application, closely connected to the server
6. SOAP runs on HTTP but envelopes the message

REST:
1. REST is a service architecture and design for network-based software
architecture
2. REST supports different data formats
3. REST supports caching
4. REST is faster than SOAP
5. REST client is just like a browser and uses standard methods An application has
to fit inside it
6. REST uses the HTTP headers to hold meta information

What are the common tests that are performed on


APIs?
Some of the common tests we perform on APIs are as follows.

1. Verify whether the return value is based on the input condition. The response
of the APIs should be verified based on the request.
2. Verify whether the system is authenticating the outcome when the API is
updating any data structure
3. Verify whether the API triggers some other event or request another API
4. Verify the behavior of the API when there is no return value
What are the advantages of API Testing?
 API Testing is time effective when compared to GUI Testing. API test
automation requires less code so it can provide faster and better test
coverage.
 API Testing helps us to reduce the testing cost. With API Testing we can
find minor bugs before the GUI Testing. These minor bugs will become
bigger during GUI Testing. So finding those bugs in the API Testing will be
cost-effective to the Company.
 API Testing is language independent.
 API Testing is quite helpful in testing Core Functionality. We can test the
APIs without a user interface. In GUI Testing, we need to wait until the
application is available to test the core functionalities.
 API Testing helps us to reduce the risks.

How is UI testing is not similar to API testing?


UI (User Interface) testing is to test the graphical interface part of the application.
Its main focus is to test the look and feel of an application. On the other hand,
API testing enables the communication between two different software systems.
Its main focus is in the business layer of the application.

Name some most commonly used HTTP methods?


Some of the HTTP methods are

GET: It enables you to retrieve data from a server


POST: It enables you to add data to an existing file or resource in a server
PUT: It lets you replace an existing file or resource in a server
DELETE: It lets you delete data from a server
PATCH: It is used to apply partial modifications to a resource
Can you use GET request instead of Post to create a
resource?
No, GET request only allows read only rights. It enables you to retrieve data from
a server but not create a resource. Post or Put methods should be used to create
a resource.

What is the difference between PUT and POST


methods?
PUT and POST methods are sometimes confused in regards to when each should
be used. Using POST request, our intent is to create a new object on the server
whereas with PUT request, our intent is to replace an object by another object.

POST should be used when the client sends the page to the server and then the
server lets the client know where it put it. PUT should be used when the client
specifies the location of the page

Building Blocks of Postman:

Before testing an API, first we will see some building blocks of Postman Tool that
are essential for every Postman operation.

1. Requests
2. Collections
3. Environment

1. Requests:
A request is a combination of the URL, HTTP headers, Body or Payload. In the
postman tool, you can save your requests and use them in the future based on
your needs.
2. Collections:
Collections are a group of saved requests you can organize into folders. We can
call it as a repository to save our requests.

3. Environment:
Environments in Postman allow us to run requests and collections against
different data sets. We could have different environments for Dev, QA, UAT &
Production.

Each of these environments will have different configurations such as URL,


token’s id and password, API keys etc., Environments are key-value pairs of
variables. Each variable name represents its key. So whenever we reference a
variable name then it allows us to access its corresponding value.

What are the components of an HTTP request?


An HTTP request have five components. These are:

1. Action showing HTTP method like GET, PUT, POST, DELETE.


2. Uniform Resource Identifier (URI): URI is the identifier for the resource on the
server.
3. HTTP version: Indicate the HTTP version like- HTTP V1.1.
4. Request Header: Request Header carries metadata for the HTTP request
message. Metadata could be a client type, format supported by the client, format
of a message body, cache setting etc.
5. Request Body: Resource body indicates message content or resource
representation.
What is URI? What is the purpose of web-based service and what
is it's format?
URI stands for Uniform Resource Identifier. It is a string of characters designed for
unambiguous identification of resources and extensibility by the URI scheme. The
purpose of URI is to locate the resource on the server hosting of the web service.

A URIs format is <protocol>://<service-name>/<Resource Type>/<ResourceID>

Example : https://reqres.n/users/id=2

In API document explain how to document each function? What are the
tools used for documentation?

 Description: Small description about what a function does


 Syntax: Syntax about the parameter of the code, the sequence in which
they occur, required and optional elements etc.
 Parameters: Functions parameters
 Error Messages: Syntax of error messages
 Example Code: Small snippet of code
 Related Links: Related functions
 What Are Variables In Postman?
 Variables, like any other programming language, are nothing but
placeholders to hold some value or result of some expressions.
 Postman offers 5 different types of variable scopes as stated below:
 Global
 Collection
 Environment
 Variable Types In Postman

You might also like