API Interview Questions And Answers
Q1. What is Api?
Ans: An API (Application Programming Interface) is a collection of software functions and strategies, called API calls, that may be performed through different software program programs. Application builders code that hyperlinks to current APIs to utilize their functionality. This link is seamless and end-users of the software are commonly ignorant of using a one after the other developed API.
During trying out, a test harness-an software that hyperlinks the API and methodically exercises its capability-is built to simulate the usage of the API with the aid of end-user programs. The interesting issues for testers are:
1. Ensuring that the check harness varies parameters of the API calls in approaches that affirm capability and divulge failures. This consists of assigning common parameter values as well as exploring boundary conditions.
2. Generating interesting parameter cost mixtures for calls with or more parameters.
3. Determining the content material underneath which an API call is made. This would possibly consist of setting external surroundings situations (files, peripheral gadgets, and so forth) and additionally internal stored information that have an effect on the API.
4. Sequencing API calls to differ the order wherein the functionality is exercised and to make the API produce beneficial results from successive calls.
Q2. Explain what is REST and RESTFUL?
Ans: REST represents REpresentational State Transfer; it's miles distinctly new element of writing net api.
RESTFUL is referred for net offerings written through making use of REST architectural idea are called RESTful offerings, it makes a speciality of gadget resources and how state of resource must be transported over HTTP protocol to a unique clients written in one-of-a-kind language. In RESTFUL net carrier http methods like GET, POST, PUT and DELETE may be used to perform CRUD operations.
Q3. Explain the architectural fashion for developing web api?
Ans: The architectural style for creating net api are
HTTP for customer server communication
XML/JSON as formatting language
Simple URI as the address for the offerings
Stateless verbal exchange
Q4. Mention what gear are required to check your web api?
Ans: SOAPUI tool for SOAP WS and Firefox “poster” plugin for RESTFUL offerings.
Q5. Mention what are the HTTP methods supported by way of REST?
Ans: HTTP techniques supported by REST are:
GET: It requests a resource on the request URL. It must now not incorporate a request body as it could be discarded. May be it can be cached regionally or at the server.
POST: It submits records to the provider for processing; it should commonly return the modified or new aid
PUT: At the request URL it replace the resource
DELETE: At the request URL it removes the useful resource
OPTIONS: It suggests which strategies are supported
HEAD: About the request URL it returns meta statistics
Q6. Mention whether or not you could use GET request in preference to PUT to create a aid?
Ans: No, you are not intended to apply POST or GET. GET operations ought to only have view rights.
Q7. Mention what are resources in a REST structure?
Ans: Resources are recognized by means of logical URLs; it is the important thing element of a RESTful layout. Unlike, SOAP internet offerings in REST, you view the product facts as a useful resource and this useful resource must contain all the required facts.
Q8. Mention what is the distinction between AJAX and REST?
· Ajax is a fixed of era; it is a method of dynamically updating elements of UI without having to reload the web page
· Ajax gets rid of the interplay between the customer and server asynchronously
· REST calls for the interaction between the purchaser and server
· REST have a URL shape and a request/response sample the revolve around the use of resources
· REST is a form of software program structure and a way for customers to request records or statistics from servers
· REST calls for the interaction among the purchaser and server
Q9. Mention some key characteristics of REST?
Ans: Some key traits of REST consists of
REST is stateless, consequently the SERVER has no country (or consultation data)
With a properly applied REST API, the server may be restarted among calls as each records is exceeded to the server
Web carrier mainly makes use of POST method to make operations, whereas REST uses GET to get admission to resources
Q10. Mention what are the special utility integration styles?
Ans: The exceptional integration styles includes
Batch file switch
Invoking far flung manner (RPC)
Swapping asynchronous messages over a message orientated middle-ware (MOM)
Q11. Explain how JAXB related to RESTful internet api?
Ans: JAXB stands for java arch for xml binding.
Q12. Mention what is the difference among PUT and POST?
Ans: “PUT”puts a report or aid at a specific URI and precisely at that URI. If there is already a document or resource at that URI, PUT adjustments that record or useful resource. If there is no aid or report there, PUT makes one
POST sends records to a selected URI and expects the aid at that URI to address the request. The net server at this point can determine what to do with the records within the context of certain aid
Q13. Mention which markup language can be used in restful net api?
Ans: JSON and XML are the two markup language that can be used in restful net api
Q14. Mention what is the difference between RPC or record style internet services? How you decide to which one to choose?
Ans: In document fashion web offerings, we will shipping an XML message as part of SOAP request which is not possible in RPC style internet provider. Document fashion net provider is most suitable in a few utility wherein XML message behaves as document and content of that file can adjust and aim of net carrier does not depend upon the content material of XML message.
Q15. Mention what is JAX-WS and JAX-RS?
Ans: Both JAX-WS and JAX-RS are libraries (APIs) for doing verbal exchange in diverse ways in Java. JAX-WS is a library that can be used to do SOAP communication in JAVA, and JAX-RS helps you to do the REST communication in JAVA.
Q16. List out the equipment or API for developing or trying out internet api?
Ans: Testing tools for internet services for REST APIs consists of
Spring REST web carrier the usage of MVC
Q17. Mention what is the difference among SOAP and REST?
· SOAP is a protocol thru which two computer communicates by way of sharing XML report
· SOAP allows best XML
· SOAP based totally reads cannot be cached
· SOAP is like custom desktop software, carefully linked to the server
· SOAP is slower than REST
· It runs on HTTP however envelopes the message
· Rest is a service architecture and layout for network-based totally software architectures
· REST helps many special facts formats
· REST reads can be cached
· A REST customer is greater like a browser; it knows a way to standardized techniques and an software has to match internal it
· REST is quicker than SOAP
· It makes use of the HTTP headers to keep meta records
API Testing and API Rest Interview Questions and solutions:
Q1. What is API trying out?
Ans: API (Application Programming Interface) specifies how some software components need to have interaction with different, in different phrases it’s a set of capabilities and tactics that allows the introduction of packages which access the features or statistics of an software or operating machine. Testing of those functions is called API testing.
Q2. What are the tools used for API trying out?
Ans: The gear used for various API testing are
Alertsite API tracking
Q3. What are the common exams carried out on API’s?
Ans: The not unusual tests accomplished on API’s
Verification of the API whether it is updating any records shape
Verify if the API does not go back whatever
Based on enter conditions, returned values from the API’s are checked
Verification of the API whether or not it triggers some different occasion or calls any other API
Q4. Mention the important thing distinction among UI stage testing and API trying out?
Ans: UI ( User Interface) refers to testing graphical interface along with how person interacts with the packages, checking out application factors like fonts, pics, layouts and many others. UI trying out essentially specializes in look and feel of an application.
While, API allows communique between two separate software systems. A software device enforcing an API incorporates functions or sub-workouts that can be carried out via every other software system
Q5. Explain what is SOAP?
Ans: SOAP-stands for Simple Object Access Control, and it is an XML based totally protocol for replacing data between computer systems.
Q6. Explain what is REST API?
Ans: It is a fixed of capabilities to which the builders performs requests and acquire responses. In REST API interaction is made thru HTTP protocol
REST – stands for Representational State Transfer, it's far fast becoming defacto standard for API introduction.
REST stands for Representational State Transfer. REST is an architectural fashion of growing net offerings which take advantage of the ubiquity of HTTP protocol and leverages HTTP approach to define moves. It revolves around aid where each thing is a resource which may be accessed via a not unusual interface the usage of HTTP fashionable strategies.
In REST architecture, a REST Server presents get admission to to resources and REST purchaser accesses and presents those resources. Here every aid is identified by means of URIs or worldwide IDs. REST makes use of one-of-a-kind approaches to symbolize a resource like text, JSON, and XML.XML and JSON are the maximum famous representations of sources in recent times.
Q7. Difference API and Unit Testing?
API testing UNIT testing
· API is owned via QA group · Unit testing is owned by means of development team
· API is normally black box checking out · Unit checking out is white field checking out
· Full capability of the gadget is taken into consideration in API checking out because it can be used by the quit-consumer (outside builders who will use your API ) · Unit checking out is performed to verify whether every unit in isolation performs as predicted or not
· API take a look at are regularly run after the build is ready and authors do no longer have access to the source code · For each in their module the builders are expected to build unit assessments for each of their code modules and need to make sure that every module bypass unit take a look at earlier than the code is included in a construct
Q8. How to test API’s ?
Ans: To take a look at the API’s you need to observe the subsequent steps
Select the suite in that you want to feature the API take a look at case
Choose check development mode
Develop take a look at instances for the preferred API methods
Configure software control parameters
Configure test conditions
Configure technique validation
Execute API check
View check reviews
Filter API take a look at cases
Sequence API take a look at cases
Q9. Mention what the main regions to be taken in attention whilst writing API file ?
Ans: The key location to be considered when writing API files are
Source of the content
Document plan or comic strip
Information required for every function inside the file
Automatic file advent programs
Q10. In API report explain the way to document every feature ?What are the gear used for documentation?
Description:Small description approximately what a feature does
Syntax:Syntax about the parameter of the code, the collection in which they arise, required and elective elements and so on.
Error Messages:Syntax of error messages
Example Code:Small snippet of code
Related Links:Related capabilities
Popular equipment used for API documentations are JavaDoc (for Java code ) Doxygen (for .Net code)
Q11. Explain API framework?
Ans: API framework is self-explanatory. Values for test run and for containing the configurable parts, config report is used. Automated test instances have to represent in “ parse-desk” format within config document. When testing API, it is not necessary to test each API so the config document have some phase whose all API are activated for that precise run.
Q12. How does the API Builder paintings?
Ans: API Builder is a PLSQL application includes four SQL files
For setting API parameters and starting the procedure one report is accountable
Two documents are created for transient tables and Master bundle to create the outputted code
Fourth document creates “spooled” output of the code into a report known as “output_script_.Square”
Q13. Explain what is TestApi ?
Ans: TestApi is a library of software and test APIs that enables testers and developers to create testing equipment and automated tests for .NET and Win32 utility. It presents a set of not unusual take a look at constructing blocks, sorts, statistics-structure and algorithms.
Q14. What is Input injection and what are specific methods of doing it ?
Ans: Input Injection: It is the act of simulating person enter, in numerous methods you can simulate person input.
Direct Method Invocation
Invocation using an accessibility interface
Simulation the usage of low-stage enter
Simulation the use of a tool driver
Simulation using a robotic
Q15. What are the main challenges of API testing?
Ans: The fundamental challenges in API testing is
Q16. What is API testing with runscope ?
Ans: Runscope is a web utility that offers backend offerings and smooth to use interface for checking out APIs.
Q17. Explain what are the concepts of API test layout?
Ans: The precept for API check design are
Setup :Create gadgets, start offerings, initialize data and many others
Execution:Steps to exercise API or scenario, also logging
Verification:Oracles to evaluate execution final results
Reporting:Pass, failed or blocked
Clean up:Pre-check nation
Q18. What are the varieties of Bugs will API trying out finds?
Ans: The styles of Bugs, API will discover
Missing or reproduction capability
Fails to handle error conditions gracefully
Not carried out errors
Inconsistent blunders managing
Q19. What are the tools used for API take a look at automation?
Ans: While checking out Unit and API trying out, both target supply code, if an API technique is the use of code based on .NET then the tool that's supporting ought to have .NET
Automation equipment for API checking out can be used are
NUnit for .NET
JUnit for Java
Q20. Mention the steps for trying out API ?
Ans: API checking out steps
Select the test case that has to be fulfilled
For API call increase a take a look at case
To meet the check case configure the API parameters
Determine how will you validate a successful take a look at
Using programming language like PHP or .NET execute the API name
Allow the API call to go back the facts to validate
Q21. What are the commonplace protocols that are testing in API tesing ?
Q22. Explain The RESTFul Web Service?
Mostly, there are forms of Web Services which can be pretty famous.
SOAP (Simple Object Access Protocol) that's an XML-primarily based way to show web offerings.
Web offerings evolved the usage of REST fashion are known as RESTful web services. These net services use HTTP techniques to implement the idea of REST architecture. A RESTful internet service usually defines a URI, Uniform Resource Identifier a carrier, provides resource representation such as JSON and set of HTTP Methods.
Q23. Explain What Is A “Resource” In REST?
REST architecture treats each content material as a aid. These assets may be either textual content documents, HTML pages, photos, movies or dynamic business data.
REST Server gives get admission to to resources and REST customer accesses and modifies those sources. Here every resource is identified by way of URIs/ global IDs.
Q24. What Is The Most Popular Way To Represent A Resource In REST?
Ans: REST makes use of exceptional representations to outline a useful resource like text, JSON, and XML.
XML and JSON are the most famous representations of sources.
Q25. Which Protocol Is Used By RESTful Web Services?
Ans: RESTful net services employ HTTP protocol as a medium of verbal exchange among patron and server.
Q26. What Is Messaging In RESTful Web Services?
Ans: RESTful web offerings employ HTTP protocol as a medium of communication between patron and server. The customer sends a message inside the shape of an HTTP Request.
In response, the server transmits the HTTP Response. This technique is called Messaging. These messages comprise message facts and metadata i.E. Records about the message itself.
Q27. State The Core Components Of An HTTP Request?
Ans: Each HTTP request includes 5 key factors.
The Verb which shows HTTP techniques including GET, PUT, POST, DELETE.
URI stands for Uniform Resource Identifier (URI).It is the identifier for the aid on the server.
HTTP Version which indicates HTTP model, for example-HTTP v1.1.
Request Header consists of metadata (as key-cost pairs) for the HTTP Request message. Metadata may be a customer (or browser) kind, the layout that client supports, message body layout, and cache settings.
Request Body shows the message content material or aid illustration.
Q28. State The Core Components Of An HTTP Response?
Ans: Every HTTP response includes 4 key elements.
Status/Response Code – Indicates Server reputation for the useful resource gift inside the HTTP request.For instance, 404 method aid not observed and 2 hundred approach response is good enough.
HTTP Version – Indicates HTTP version, as an example-HTTP v1.1.
Response Header – Contains metadata for the HTTP response message stored in the shape of key-cost pairs. For example, content length, content type, response date, and server kind.
Response Body – Indicates response message content material or useful resource illustration.
Q29. Name The Most Commonly Used HTTP Methods Supported By REST?
Ans: There are a few HTTP techniques in REST which can be greater popular.
GET -It requests a useful resource on the request-URL. It have to not comprise a request body because it will get discarded. Maybe it may be cached domestically or at the server. 2.POST – It submits information to the service for processing; it need to generally return the modified or new useful resource. 3. PUT – At the request URL it updates the useful resource. 4. DELETE – It removes the useful resource at the request-URL. Five. OPTIONS -It indicates the supported techniques. 6. HEAD – It returns meta facts about the request URL.
Q30. Mention, Whether You Can Use GET Request Instead Of PUT, To Create A Resource?
Ans: No, you shouldn’t use a PUT or POST technique. Instead, practice the GET operation which has view-handiest rights.
Q31. Is There Any Difference Between PUT And POST Operations? Explain It.
Ans: PUT and POST operation are almost same. The most effective distinction between the two is inside the terms of the result generated by them.
PUT operation is idempotent while POST operation can deliver a specific result.
Let’s take an instance.
PUT puts a file or useful resource at a selected URI and precisely at that URI. If the aid already exists, then PUT updates it. If it’s a primary-time request, then PUT creates one.
POST sends facts to a selected URI and expects the useful resource at that URI to address the request. The internet server at this factor can determine what to do with the facts within the context of specified aid.
Q32. What Purpose Does The OPTIONS Method Serve For The RESTful Web Services?
Ans: This technique lists down all of the operations a web service supports. It makes read-simplest requests to the server.
Q33. What Is URI? Explain Its Purpose In REST Based Web Services. What Is Its Format?
Ans: URI stands for Uniform Resource Identifier. URI is the identifier for the resource in REST structure.
The purpose of a URI is to discover a aid(s) on the server website hosting the internet provider. A URI is of the following layout
Q34. What Do You Understand By Payload In RESTFul Web Service?
Ans: Request body of each HTTP message includes request facts referred to as as Payload. This a part of the message is of interest to the recipient.
We can say that we ship the payload in POST method but no longer in <GET> and <DELTE> methods.
Q35. What Is The Upper Limit For A Payload To Pass In The POST Method?
Ans: <GET> appends facts to the provider URL. But, its size shouldn’t exceed the maximum URL duration. However, <POST> doesn’t have this sort of restriction.
So, theoretically, a consumer can pass unlimited information as the payload to POST approach. But, if we remember a actual use case, then sending POST with large payload will consume more bandwidth. It’ll take extra time and present overall performance challenges for your server. Hence, a consumer must take movement accordingly.
Q36. Explain The Caching Mechanism?
Ans: Caching is a system of storing server response on the consumer cease. It makes the server keep good sized time from serving the same aid again and again.
The server response holds facts which leads a customer to carry out the caching. It facilitates the patron to determine how long to archive the reaction or now not to shop it at all.
Q37. What Are The Tools Available For Testing Web Services?
Ans: Following gear can assist in trying out the SOAP and RESTful net services.
SOAP UI device.
Poster for Firefox browser.
The Postman extension for Chrome.
Q38. Explain The Factors That Help To Decide About The Style Of Web Service To Use? SOAP Or REST?
Ans: In popular, using REST based internet carrier is favored because of its simplicity, overall performance, scalability, and guide for a couple of data formats.
However, SOAP is favorable to use in which service calls for a complicated stage of protection and transactional reliability.
But you could study the subsequent facts before opting for any of the patterns.
Does the service disclose data or business common sense? To reveal statistics REST can be a higher desire and SOAP for good judgment.
If the patron or the provider carriers require a formal contract, then SOAP can offer this sort of settlement thru WSDL.
Need to help more than one statistics formats. REST supports this.
Support for AJAX calls. REST can use the XMLHttpRequest.
Synchronous and asynchronous calls – SOAP allows both synchronous/asynchronous operations while REST has built-in support for synchronous.
Stateless or Stateful calls -REST is ideal for stateless operations.
Here are some of the advanced-stage information that you could recall as well.
Security requirement – SOAP offers a high stage of security.
Transaction assist – SOAP has accurate support for transaction management.
Limited bandwidth – SOAP has a lot of overhead when sending/receiving packets since it’s XML primarily based, requires a SOAP header. However, REST calls for less bandwidth to ship requests to the server. Its messages are commonly built the use of JSON.
Ease of use – It is easy to put in force, take a look at, and keep REST based application.
Q39. Can You Tell Us Which Java API Helps In Developing A RESTFul Web Service?
Ans: There are many frameworks and libraries available that a developer can use to create RESTful net services in Java. For example, the JAX-RS library is a popular way to broaden a REST web service.
Also, Jersey is some other most popular implementations of JAX-RS which gives more than what the specs recommend. There are others like RESTEasy, RESTlet, and Apache CFX.
If you want Scala, then you definately have to be the usage of Play framework to broaden RESTful net services.
Q40. Name The Most Commonly Used HTTP Methods Supported By REST?
Ans: There are a few HTTP techniques in REST which might be greater popular.
GET -It requests a useful resource at the request-URL. It have to not comprise a request frame because it will get discarded. Maybe it is able to be cached regionally or on the server.
POST – It submits information to the service for processing; it must commonly return the modified or new useful resource.
PUT – At the request URL it updates the resource.
DELETE – It gets rid of the useful resource at the request-URL.
OPTIONS -It indicates the supported strategies.
HEAD – It returns meta records approximately the request URL.