Interview Questions

What is API Testing?

This question is mostly asked question among the API interview questions to check if you can efficiently frame your answer.

Ans: API testing is the testing of the developed so APIs to check their functionality, efficiency, reliability, and security.

You can mention types of API testing such as

  • Validation testing

  • Functional testing

  • load testing

  • UI testing

  • Run time/error detection

  • penetration testing

  • Fuzz testing

  • Interoperability and WS Compliance testing.

Q3. What are the advantages of API Testing?

Give this answer in a way to show the interviewer the importance and relevance of API testing and where and how you are going to use it or have already used it.

Ans:-

  • API testing helps in core functionality by giving direct access to the application, without needing a user interface. It is helpful in detecting minor errors before they turn into major issues during GUI testing.

  • API testing uses less code than GUI testing so it gives better coverage. That’s hat it is time-effective too.

  • API testing is language-independent as data is exchanged using XML or JSON, which allows users to select any coding language when adopting an automation test service.

  • API can be easily integrated with GUI testing.

Q4. How does API work?

Ans:- Generally, API takes a request, processes it which is data validation, database interaction, data processing, and then the result is reverted to the source.

Q5. Do you know about the common tests performed on the APIs?

Ans:-Here is the list of common tests that are performed on APIs –

  • You should verify the API first and check whether it is updating any data structure or not.

  • You need to check whether the API returns anything.

  • As per the given parameters or values, the values returned by APIs need to be checked.

  • Verify the API whether it triggers any other event or calls another API.

  1. How do you maintain API tests? By updating test cases and data when APIs change. Re-running regression tests with each code change.

  2. How do you monitor API test execution? Using test automation tools that provide reports, dashboards and metrics on test runs.

  3. What are the challenges in API testing? Complexity of data-driven testing, difficulty in mocking dependencies, difficulty testing all permutations.

  4. How do you handle asynchronous APIs? By implementing waits/delays in test scripts. Or using callback urls/webhooks.

  5. What is a API test case sample? A test case defines a test scenario with inputs, execution steps and expected outputs. A sample case tests a successful user sign up:

  • Input: User object with valid credentials

  • Steps: Call POST /users endpoint with data

  • Output: Response code 201 and new user details

This tests a single use case of the sign up API functionality.

  1. What is an API test plan? An API test plan defines all the test cases, test data, environments, tools, schedules for testing an API. It ensures all aspects of the API are covered systematically and thoroughly.

  2. What is API contract testing? Contract tests ensure APIs conform to contracts or agreements about expected input/output formats and behavior. Any changes to APIs that break contracts fail the tests.

  3. What is a mock API? A mock API mimics the behavior of a real API but with fake or simulated responses. It is used to simulate API dependencies during development and testing.

  4. What are API assertions? Assertions are checks made in test scripts to validate API responses match expectations. Common assertions include:

  • Status code

  • Response time

  • Response body schema and contents

  • Response headers

  1. How do you identify API bottlenecks? By monitoring metrics like:

  • High average response time

  • High error rate

  • High number of time-outs

  • Spikes in response time graphs

  1. How do you correlate API and UI tests? By using the same test data and including identifiers in API responses that UI tests can match.

  2. What is an API endpoint? An API endpoint is a unique URL that represents a function or operation in an API. A request to an endpoint returns a response with data or triggers an action.

  3. What is an API key? An API key is a secret string used to authenticate API requests. It identifies the API caller and allows the API to track requests and impose limits.

  4. What are best practices for API testing? Thorough test planning, robust test data strategies, good test automation, extensive test coverage, constant monitoring, maintenance of outdated tests.

  5. What are the different ISO standards for API testing? ISO 29119 - general software testing standard, ISO 29148 - test documentation standard, ISO 21111 - API management standard.

  6. Explain API testing in Scrum methodology? API testing is performed at two levels:

  7. At Sprint level - Unit, integration and functionality tests. Automated tests are added as new features are developed.

  8. At Release level - System level regression, performance, security and user acceptance testing of the integrated system including all APIs.

  9. Give some API testing interview tips? Focus on hands-on experience with tools, different types of API tests performed, how you approach API testing and maintain tests, challenges faced and solutions.

  10. What are webhooks? Webhooks are HTTP callbacks - a way for an API to notify a URL when something happens. When an event occurs in the API, a HTTP request is made to the registered URL.

  11. What are API gateways? API gateways sit between APIs and external consumers. They enforce policies, security and provide a single entry point for API access.

Last updated