API Flashcards

1
Q

What is an API?

A

API is an acronym and it stands for Application Programming Interface. API is a set of routines, protocols, and tools for building Software Applications. APIs specify how one software program should interact with other software programs.

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Difference between API and Web services?

A

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:

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is Soap?

A

SOAP stands for Simple Object Access Protocol. It is an XML based messaging protocol. It helps in exchanging information among computers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is Rest API?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Difference between SOAP and REST?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the common tests that are performed on APIs?

A
  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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the advantages of API Testing?

A
  1. 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.
  2. 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.
  3. API Testing is language independent.
  4. 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.
  5. API Testing helps us to reduce the risks.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What exactly needs to be verified in API Testing?

A

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
4. Error codes in case API return any errors
5. Authorization checks
6. Non-functional testing such as performance testing, security testing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the main challenges faced in API testing?

A
  1. Selecting proper parameters and its combinations
  2. Categorizing the parameters properly
  3. Proper call sequencing is required as this may lead to inadequate coverage in testing
  4. Verifying and validating the output
  5. Due to the absence of GUI, it is quite difficult to provide input values
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Name some most commonly used HTTP methods?

A

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
OPTIONS: It is used to describe the communication options for the target resource
HEAD: It asks for a response identical to that of a GET request, but without the response body

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Can you use GET request instead of PUT to create a resource?

A

No, GET request only allows read only rights. It enables you to retrieve data from a server but not create a resource. PUT or POST methods should be used to create a resource.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the difference between PUT and POST methods?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

API Testing Best Practices:

A
  1. Test for the expected results
  2. Add stress to the system by sending a series of API load tests
  3. Group API test cases by test category
  4. Create test cases with all possible inputs combinations for complete test coverage
  5. Prioritize API function calls to make it easy to test
  6. Create tests to handle unforeseen problems
  7. Automate API testing wherever it is possible
How well did you know this?
1
Not at all
2
3
4
5
Perfectly