API Testing
An API is Application programming Interface that enables two Application to communicate Each
other i.e. Client and server.
API is one type of security which provide security to data which is interacting between Client and
server.
API means sending request and getting response from server in different format.
Client:-
A client is computer hardware device that access a service which available by the server.
Server:-
A server is a physical computer dedicated to run a service to serve need of other.
Different Format of data:-
Text
XML
JSON (java script object notation)
HTML
Example of API:-
Calculator API
Selenium API
Web services:-
Web service is nothing but sending request and getting response from server Over a network (http
or https).
Example of Web service: -
FB , what Up, Gmail, Goggle
Difference Between API and WEB services: -
All web services are API but All API are not web services.
Web services is an API Wrapped in http or https.
A web service need a network to send request and getting response and API doesn’t need network
to send request and getting response.
Types Web services: -
Tool used:-
1. Postman
2. SOAP UI
3. Swagger.
What is REST:-
REST (Representational state Transfer) it is an Architecture Style for developing web services that
uses http Protocol for transferring request and getting response.
SOAP :-
SOAP (simple object access protocol) .
It a protocol.
Difference Between SOAP and REST:-
SOAP REST
1.SOAP is Protocol 1. Rest is architecture.
2. SOAP support only XML format. 2. Rest support all formats
XML, JSON,HTML,TEXT.
3.SOAP needs WSDL file 3. REST need API only.
4.Response time is more 4 . response time less.
5.heavy in weight’s API’s. 5.light in weight API’s.
6. tool used – SOAP UI 6. Tool Used – Postman
Download site:- https://www.postman.com/downloads/
Practice site :-
https://reqres.in/
https://gorest.co.in/
http://dummy.restapiexample.com/#
Hoe to create collection:
Click on NEW
API Method / API call
CRUD operation:-
Create - create the data---POST.
Retrieve – fetch the data--- GET.
Update – update the data – PUT.
Delete – Delete the data – DELETE.
URL and URI:-
URL – Uniform resource locator
URI- Uniform resource Identifier.
URI = base /Domain + END point
https://gorest.co.in/public/v2/users
https://www.facebook.com/login - End point
https://gorest.co.in/ - Base URL
public/v2/users - End point
type of END point:-
Path Parameter:-
It is defined by “/” and used to searching the value.
Ex :- https://gorest.co.in/public/v2/users
Query Parameter:-
It is defined by “?” and it is used for fetching specific data.
Ex - https://gorest.co.in/public/v2/users?page=1
Headers:-
Content type : Application JSON/XML/HTML
Key value
Accept: Application JSON/XML
Authentication :- key
Value :-
Username/Password
Auth key
Token – Bearer+ space+ token value
No Auth
While doing API testing we have to check Status code , Response time , data .
Status Code / HTTP code:-
2XX – Success
200 – Ok
We found 200 when response is correct or ok.
201- Created successfully
We found this status code when we are using post method and creating some new entity successfully in
DB/server.
4XX – clint Error:-
401 – Unauthorized
We found this status code when we are passing wrong token key .
404 – Not Found
Occur when we are trying to fetch data which is not available in DB /server.
5XX- Internal / server Error:-
500 – server Error
We get 500 when server is not responding.
503 – service unavailable.
API Advantages:-
API provide security.
Test for Core functionality.
Time Effective or less time consuming.
Language Independent. (XML, JSON,HTML,TEXT).
Rest Assured: -
If we want to automate any API then we Required Rest Assured Libraires.
RESFUL: -
When we automate Any API then it is RESTFUL.
WSDL
WSDL stand for web service description language.
WSDL it is XML based document which define the functionality of API.
UDDI:
- universal description discovery integration
-UDDI is an XML based standard for describing, publishing and finding the webservices
WSDL elements:
a. Type- Define the data types used by the webservices
b. Message – Define the data element for each operation
c. Port Type- Describe the operation that can be performed and message involve
d. Binding- Defines the protocol and data format for each port type
What must be checked while doing API testing:
Ans: Error or status code , response time and data which is coming from server.
What are the tool used ?
Ans: SOAPUI POSTMAN Swagger.
Website for trial:
https://gorest.co.in/
http://dummy.restapiexample.com/#