1-What Is An API?: //asked in Interview
1-What Is An API?: //asked in Interview
1-What Is An API?: //asked in Interview
WebService : A WebService is any piece of software that makes itself available over the internet.
It is an API which is wrapped over HTTP protocol. Webservice is a way for two machines to
communicate with each other over a network. Unlike web applications, web services are designed to
interact with another program rather than interacting directly to the user.
Web Services uses only three styles REST , SOAP , XML-RPC(Remote Procedure Call).
//Asked in interview
1- What is an API?
Api is a software interface that enables two applications to communicate with each other without
any network.
And we can also say API is a code written by someone else and we are using that code in our
application to use that functionality.
Here are some Realistic API examples which we are using in our daily life:
Google API, Amazon advertising API,Twitter Api,YouTube API etc.
//Asked in interview
2-What are the main differences between API and Web-service?
An API is an interface that enables two applications to communicate with each other., while a
web service is a network-based resource that fulfills a specific task. Yes, there’s overlap
between the two: all web services are APIs, but not all APIs are web services.
All Web Services are API but not all API are Web Services . Web Services might not contain all
the specifications and can not perform all the tasks that API would perform .
Web Services only use three styles of use : REST , SOAP , XML RPC for communication
whereas API may be exposed in multiple ways like dll file, JAR file , XML over HTTP , JSON
over HTTP.
Web Services always need a network to operate whereas API does not need any network for
operation.
//Asked in interview
REST stands for Representational State Transfer. It is an architectural pattern used for
creating Web services.REST works with plain text, XML, HTML and JSON.
SOAP cannot make use of REST whereas REST can make use of SOAP.The interaction
is made through HTTP protocol in REST API.
The HTTP methods used in REST are :
GET , PUT , POST , DELETE , Patch (Difference b/w them) //Asked in interview
//Asked in interview
What is REST API?
REST API is a set of functions used by developers to perform requests and receive responses.
The interaction is made through HTTP protocol in REST API.
//Asked in interview
4-What is API Testing?
API Testing is a kind of software testing which determines if the developed API meets the
expectations regarding functionality,reliability,performance and security of the application.
//Asked in interview
5-What are the advantages of API Testing?
a-Test the core functionality
b-Time Effective
c-Fast Response
d-Language Independent
//Asked in interview
7-What are the principles of API test design?
a-Setup
b-Execution
c-Verifying
d-Reporting
e-Clean-Up
//Asked in interview
8- What must be checked When performing API Testing?
a-Accuracy of data
b-HTTP Status Codes
c-Error code in case of API returns
d-Schema Validations
e-Data Type, validations ,completeness
f-Autoriation checks
g-Implementation of response timeout
//Asked in interview
HTTP VERBS/Methods
There are 4 basic HTTP verbs we use in requests to interact with resources in a REST system:
For each HTTP verb, there are expected status codes a server should return upon success:
200 (OK) This is the standard response for successful HTTP requests.
201 (CREATED) This is the standard response for an HTTP request that resulted in
an item being successfully created.
202 (ACCEPTED) The request has been accepted for processing but the processing
has not been completed.
204 (NO CONTENT) This is the standard response for successful HTTP requests, where
nothing is being returned in the response body
400 (BAD REQUEST) The request cannot be processed because of bad request syntax,
excessive size, or another client error.
401 (UNAUTHORIZED) The request did not include an authentication token or the
authentication token expired.
.403 (FORBIDDEN) The client does not have permission to access this resource.
405 (METHOD NOT The HTTP method in the request was not supported by the
ALLOWED) resource.
406 (NOT The server can not produce a response matching in the list of
ACCEPTABLE CLIENT accepted values.
ERROR)
407 (PROXY
AUTHENTICATION
REQUIRED CLIENT
ERROR)
408 (REQUEST
TIMEOUT RESPONSE)
501 (NOT The server did not recognise the requested method and is
IMPLEMENTED incapable of supporting it.
SERVER ERROR)
502 (BAD GATEWAY The server , while acting as a gateway or proxy , received an
SERVER ERROR) invalid response.
503 (SERVICE The server is currently unable to handle the request due to
UNAVAILABLE) temporary overloading or maintenance of the server.
● Uniform Interface
● Stateless
● Cacheable
● Client-Server
● Layered System
● Code on Demand (optional)
REST stands for Representational State Transfer. It is an architectural pattern used for
creating Web services.REST works with plain text, XML, HTML and JSON.
SOAP cannot make use of REST whereas REST can make use of SOAP.The interaction
is made through HTTP protocol in REST API.
The HTTP methods used in REST are :
GET , PUT , POST , DELETE
//Asked in interview
11- What is SOAP ?
The abbreviation of SOAP is Simple Object Access Protocol . It is a message protocol
that allows two applications to communicate. SOAP only works with XML formats .
There are three components of web service:
//Asked in interview
12- Difference between REST and SOAP :
SOAP stands for Simple Object Access Protocol whereas REST stands for
Representational State Transfer. SOAP is a protocol whereas REST is an architectural
pattern. SOAP only works with XML formats whereas REST works with plain text, XML,
HTML and JSON. SOAP cannot make use of REST whereas REST can make use of
SOAP.
//Asked in interview
13- What is Postman ?
Postman is an API client and it is used to develop , test , share and document API’s.
//Asked in interview
14- What are Postman Collections?
Postman Collections are a group of saved requests you can organize into folders.
● No Auth : If your request does not require authorization, select No Auth from the
Authorization tab Type dropdown list so that Postman will not attempt to send
authorization details with a request
● API Key : With API key auth, you send a key-value pair to the API either in the
request headers or query parameters.
● Bearer Token : Bearer tokens allow requests to authenticate using an access key,
such as a JSON Web Token (JWT). The token is a text string, included in the
request header.
If a variable with the same name is declared in two different scopes, the value stored in
the variable with the narrowest scope will be used—for example if there is a global and a
local variable both named “Username”, the local value will be used when the request
runs.
● Collection Variables are available throughout the requests in a collection and are
independent of Environments so do not change based on the selected
environments.
Collection Variables are suitable if you are using only one Environment.
● Data Variables come from external CSV and JSON files to define data sets you
can use when running collections via Newman or the Collection Runner.
pm.environment.unset(“AccessToken” , AccessToken);
Use pm.variables to define a Local variable
pm.variables.set(“AccessToken” , “usgd56”);
console.log(pm.variables.get("variable_key"));
var template = `
<table bgcolor="#FFFFFF">
<tr>
<th>Name</th>
<th>Email</th>
</tr>
{{#each response}}
<tr>
<td>{{name}}</td>
<td>{{email}}</td>
</tr>
{{/each}}
</table>
`;
// Set visualizer
pm.visualizer.set(template, {
// Pass the response body parsed as JSON as `data`
response: pm.response.json()
});