Endtoendapitestinginterviewquestionsnotes Sample
Endtoendapitestinginterviewquestionsnotes Sample
INTERVIEW QUESTIONS
NOTES
End to End API Testing, Automation API Test With Cucumber, Mock Interview Question for API Testing for
Backend Engineer, SDET, Software Quality Engineer, Software Quality Assurance, Software Test Engineer, and
Test Engineer
PART 1:
Version 1.0
Contact Information:
Email: lamhot.id@gmail.com
Site: https://lamhotjm.github.io
Linkedin: https://www.linkedin.com/in/lamhotsiagian
TABLE OF CONTENTS
Preface 1
Introduction to APIs and API Testing 3
Understanding APIs 3
Importance of API Testing 5
Types of APIs 7
Overview of API Testing Techniques 9
Common Interview Questions and Answers Related to Basic APIs 11
Setting Up Your API Testing Environment 14
Choose Your API Testing Tool 14
1. Postman 14
2. Insomnia 14
3. Swagger UI 15
4. SoapUI 15
5. HTTPie 15
6. Paw 16
7. JMeter 16
Install and Set Up the Tool 17
1. Installing Postman 17
2. Configuring Postman 18
3. Organize Your Requests 18
Using Collections 18
4. Configure and Send Requests 19
5. Validate Responses 19
6. Documentation and Collaboration 20
7. Advanced Features 20
Common Interview Questions & Answers Related to API Test Tools 21
Basic Questions 21
Intermediate Questions 21
Advanced Questions 22
Practical Questions 22
Troubleshooting Questions 23
Integration Questions 24
Understanding API Requests and Responses 25
HTTP Methods 25
2
End to End APIs and API Testing, Curated by Lamhot Siagian
1. GET 25
2. POST 26
3. PUT 26
4. DELETE 26
5. PATCH 27
6. HEAD 27
7. OPTIONS 27
8. CONNECT 27
9. TRACE 28
Comparison of HTTP methods 28
Request Headers and Parameters 29
Request Headers 29
Request Parameters 29
Query Parameter 30
Fragment Parameters 31
Character Encoding 31
Size Limits 32
3.3. Response Codes and Their Meanings 33
1xx Informational Responses 33
2xx Success 33
3xx Redirection 34
4xx Client Errors 34
5xx Server Errors 35
How to Test HTTP Method 37
Analyzing Response Body 40
Common Interview Questions & Answers Related to API Request and Response 41
Security Testing of APIs 43
Types API security testing 43
Dynamic Application Security Testing (DAST) 43
Software Composition Analysis (SCA) 43
Authentication 43
Authorization 44
Common API Security Risks 45
4.3.Preparing for API Security Testing 46
Steps to Follow for API Security Testing 48
Step 1: Understanding API Endpoints 48
Step 2: Authentication and Authorization Testing 48
Step 3: Input Validation 49
Step 4: Error Handling and Exception Management 51
Step 5: Rate-limiting and Throttling 52
3
End to End API Testing, Curated by Lamhot Siagian
4
End to End APIs and API Testing, Curated by Lamhot Siagian
5
End to End API Testing, Curated by Lamhot Siagian
Dependencies 107
Configuration 108
Exception Handling 108
Models 108
Utility Classes 109
API client Util 110
Authentication Util 110
Logger Util 110
Test Util 111
Response Processor 111
Feature File 112
Step Definitions 113
Test Runner 113
Test Driver 114
Common Interview Questions and Answers Related to Organizing a Test Framework 115
General Framework Design 115
Request and Response Handling 115
Exception Handling 115
Configurations 116
User Authentication 116
Processor and Models 116
Test Assertions 117
Logger 117
Utilities 117
Test Execution 117
Continuous Integration and Continuous Deployment (CI/CD) with API Testing 119
Introduction to CI/CD 119
Importance of CI/CD for API Testing 119
CD Tools 120
Jenkins 120
GitLab CI/CD 120
AWS CodePipeline 121
Travis CI 121
CircleCI 122
Bamboo 123
GitHub Actions 123
Step-by-Step Guide to Setting Up a Basic CI Pipeline with Maven and BDD 124
1. Connecting to a VCS 124
2. Setting Up Your Maven Project for BDD 124
3. Creating Feature Files and Step Definitions 126
6
End to End APIs and API Testing, Curated by Lamhot Siagian
7
End to End API Testing, Curated by Lamhot Siagian
Preface
Welcome to End to End API Testing & Interview Questions Notes, a comprehensive guide designed to assist
you in mastering API testing and preparing for technical interviews in API testing roles. With the
increasing reliance on APIs in modern software architectures, understanding how to test APIs is becoming
more crucial than ever for QA professionals and software testers.
This book is structured to provide both practical knowledge and insights into real-world API testing
scenarios. The chapters are meticulously organized to take you from the basics of API testing to advanced
topics such as security, performance testing, and automation. Here's a brief overview of the chapters:
1
End to End API Testing, Curated by Lamhot Siagian
Interview Preparation
Each chapter contains a set of interview questions and sample answers, helping you prepare for API testing
roles in Backend Engineering, SDET (Software Development Engineer in Test), Software Quality
Assurance, and Test Engineering positions. These questions are inspired by my own experiences from
years of technical interviews in the United States and other resources.
Over the past seven years, I've meticulously gathered notes and questions from each interview,
summarizing them into this guide. Whether you are a fresh graduate or an experienced tester, these notes
will help you solidify your understanding of key concepts while giving you the confidence to face any API
testing interview.
API testing has been increasingly recognized for its efficiency, flexibility, and integration capabilities,
making it a vital part of any software testing strategy. I hope this book helps you gain a strong foundation
in API testing, and I trust that the included interview questions and answers will be a valuable resource for
your career progression.
Happy learning, and good luck with your API testing journey!
Lamhot Siagian
2
End to End APIs and API Testing, Curated by Lamhot Siagian
Chapter 1
Understanding APIs
APIs (Application Programming Interfaces) is fundamental for modern software development, as they
enable different software systems to communicate with each other. Here’s a detailed overview to help you
understand what APIs are, how they work, and why they are important.
What is an API?
An API, or application programming interface, is a set of rules or protocols that enables software
applications to communicate with each other to exchange data, features and functionality..
A simple way to understand how APIs work is to look at a common example—third-party payment
processing. When a user purchases a product on an e-commerce site, the site might prompt the user to “Pay
with PayPal” or another type of third-party system. This function relies on APIs to make the connection.
- When the buyer clicks the payment button, an API call is sent to retrieve information. This is the
request. This request is processed from an application to the web server through the API’s Uniform
Resource Identifier (URI) and includes a request verb, headers, and sometimes, a request body.
- After receiving a valid request from the product webpage, the API calls to the external program or
web server, in this case, the third-party payment system.
- The server sends a response to the API with the requested information.
- The API transfers the data to the initial requesting application, in this case, the product website 1
Components of an API
1
https://www.ibm.com/topics/api
3
End to End API Testing, Curated by Lamhot Siagian
6. Payload/Body: Data being sent with the request (typically in JSON or XML format).
1. Integration: Connecting different applications and services, such as integrating payment gateways
into e-commerce platforms.
2. Automation: Automating repetitive tasks, such as deploying code, managing resources, or data
synchronization.
3. Data Access: Providing access to data from different sources, such as retrieving weather data or
financial information.
4. Third-Party Services: Enabling third-party developers to build applications that interact with your
services, such as social media apps using Facebook or Twitter APIs.
5. Microservices Architecture: Facilitating communication between microservices in a distributed
system.
API Documentation
Good API documentation is essential for developers to understand how to use the API effectively. It
typically includes:
1. Endpoint Descriptions: Detailed information about available endpoints and their purposes.
2. HTTP Methods: The methods supported by each endpoint (e.g., GET, POST).
3. Parameters: Required and optional parameters for each endpoint.
4. Request and Response Formats: Examples of request payloads and expected responses.
5. Authentication: Information about authentication and authorization mechanisms.
6. Error Handling: Common error codes and messages, along with troubleshooting information.
2
https://www.postman.com/what-is-an-api/#benefits-of-apis
4
End to End APIs and API Testing, Curated by Lamhot Siagian
API testing is a crucial aspect of software development, offering numerous benefits and addressing key
challenges that can significantly impact the quality, reliability, and performance of software applications.
Here are the primary reasons why API testing is important:
1. Ensures Functionality
● Verification of Requirements: API testing ensures that the API functions according to the specified
requirements. This involves checking that the endpoints are working correctly, the data is being
processed as expected, and the correct responses are returned.
● Detection of Errors Early: By testing APIs early in the development cycle, errors can be detected
and fixed before they become more difficult and costly to resolve.
2. Improves Reliability
● Consistent Performance: Regular API testing helps ensure that the API performs consistently
under various conditions, reducing the likelihood of unexpected failures in production
environments.
● Regression Testing: API tests can be automated and included in regression testing to ensure that
new changes do not break existing functionality.
3. Enhances Security
● Identification of Vulnerabilities: API testing can reveal security vulnerabilities such as SQL
injection, cross-site scripting (XSS), and other common exploits.
● Validation of Authentication and Authorization: Ensures that security mechanisms like
authentication and authorization are working correctly, protecting sensitive data and functionality
from unauthorized access.
4. Boosts Performance
● Load and Stress Testing: API testing includes performance tests such as load and stress testing,
which help determine how well the API performs under heavy traffic and identify potential
bottlenecks.
● Scalability Assessment: Helps in assessing whether the API can scale effectively to handle
increased load as the user base grows.
● Ensures Smooth Integration: For APIs that are consumed by external developers or third-party
applications, thorough testing ensures that these integrations work smoothly, providing a better
user experience.
● Reduces Downtime: By identifying and resolving issues early, API testing helps reduce the chances
of downtime, ensuring that end-users experience fewer disruptions.
5
End to End API Testing, Curated by Lamhot Siagian
● Automated Testing: API tests can be automated and integrated into CI/CD pipelines, providing
quick feedback to developers and ensuring that changes do not introduce new issues.
● Continuous Monitoring: Ongoing API testing helps monitor the API's health and performance
continuously, allowing for rapid response to issues.
● Improved Debugging: API tests provide detailed information about failures, making it easier for
developers to debug and resolve issues.
● Documentation and Clarity: Writing API tests often helps clarify the API's functionality and
expected behavior, which can improve the quality of documentation and assist other developers in
understanding how to use the API.
8. Reduces Costs
● Lower Maintenance Costs: Identifying and fixing issues early in the development process reduces
the costs associated with post-release maintenance and support.
● Fewer Production Issues: Well-tested APIs are less likely to cause issues in production, leading to
reduced costs related to bug fixes and customer support.
● Adherence to Standards: API testing ensures that the API complies with industry standards and
protocols, which is particularly important for APIs in regulated industries.
● Contract Testing: Validates that the API contracts (the agreed-upon schema and behavior between
API consumers and providers) are maintained, ensuring compatibility and reliability.
6
End to End APIs and API Testing, Curated by Lamhot Siagian
Types of APIs
APIs come in various forms, each with its own strengths and purposes. Understanding these differences is
essential for picking the right API for your project and ensuring your application is effective, scalable, and
reliable. Let’s look at the different types of APIs, exploring what makes each unique and how they fit into
modern software development.
This table provides a high-level overview of various API types, their descriptions, and examples.3
Library-based Part of software libraries, Java API for Android app development, .NET
APIs language-specific, range from basic libraries used in Windows applications
utilities to complex GUI components
Operating Provide interfaces for OS interaction, Windows API for Windows OS interaction,
system APIs manage hardware resources and POSIX API for UNIX-like systems
processes
Database APIs Enable interaction with database SQL API for relational databases, Oracle’s
management systems, facilitate data OCI for Oracle databases
querying and manipulation
Hardware Allow communication with hardware IoT device APIs for smart home systems,
APIs devices, direct control over hardware Printer APIs for document processing
functions
Cloud APIs Provided by cloud service platforms, Amazon Web Services (AWS) API, Microsoft
enable interaction with cloud-based Azure API for cloud-based solutions
resources and services
HTTP APIs Facilitate client-server communication Web services, mobile apps, IoT devices, social
(web API) over the web, use standard HTTP media platforms, content management
methods, lightweight and flexible systems
REST APIs Use HTTP requests for data Web services accessible via the web, social
(web API) operations, stateless and separate media APIs, cloud services
client-server concerns
SOAP APIs Use service interfaces to expose Enterprise-level services like banking,
(web API) business logic, high security, suitable healthcare, where security and transactions
for enterprise-level organizations are critical
GraphQL Clients request only needed data, Complex data-driven web and mobile
APIs (web reduce data transfer over the network, applications, ad-hoc queries by the client
API) support multiple responses in one
request
3
https://www.nylas.com/api-guide/types-of-apis/
7
End to End API Testing, Curated by Lamhot Siagian
Open APIs Accessible by third-party developers, Twitter API for tweets, Stripe API for
(public APIs) typically for external users, require payments, providing data or services to
API keys external developers
Internal APIs Designed for internal use within an Linking HR systems to internal employee
(private APIs) organization, enhance integration directories, improving internal efficiency and
between systems data security
Partner APIs Available to strategic business Integration of supply chain systems, service
partners, require specific entitlements expansion to partners, creating revenue
channels, controlled data sharing with trusted
partners
Composite Combine different data and service Aggregating various services in a single call
APIs APIs, access multiple endpoints in one for smoother user experience, commonly used
call in microservices architectures
JSON-RPC Encode data as JSON or XML for Remote procedure calls with simple
and XML-RPC remote procedure calls, send lists of request/response model, suitable for basic
APIs commands request/response scenarios
Library-based Part of software libraries, Java API for Android app development, .NET
APIs language-specific, range from basic libraries used in Windows applications
utilities to complex GUI components
8
End to End APIs and API Testing, Curated by Lamhot Siagian
1. Unit Testing
2. Functional Testing
● Objective: Verify that the API performs its intended functions correctly.
● Tools: Postman, SoapUI, REST Assured.
● Description: Functional tests validate the API against the functional requirements and
specifications. This includes testing endpoints, methods (GET, POST, PUT, DELETE), and responses.
3. Integration Testing
● Objective: Ensure that the API interacts correctly with other components and systems.
● Tools: Postman, SoapUI, JUnit (with integration test configurations).
● Description: Integration tests evaluate the interactions between different parts of the API and other
services or databases to ensure that integrated parts work together as expected.
4. Performance Testing
5. Security Testing
6. Usability Testing
9
End to End API Testing, Curated by Lamhot Siagian
7. Validation Testing
8. Compliance Testing
● Objective: Ensure the API complies with industry standards and regulations.
● Tools: Postman, SoapUI, custom scripts.
● Description: Compliance testing checks if the API adheres to legal and regulatory requirements,
such as GDPR, HIPAA, and other industry-specific standards.
10
End to End APIs and API Testing, Curated by Lamhot Siagian
1. What is an API?
Answer: An API (Application Programming Interface) is a set of rules and protocols that allows different
software applications to communicate with each other. APIs define the methods and data formats that
applications can use to request and exchange information.
2. Can you explain the difference between REST and SOAP APIs?
Answer:
3. What are the main HTTP methods used in RESTful APIs and what are their purposes?
Answer:
Answer: An API endpoint is a specific URL that provides access to a particular resource or functionality of
the API. It represents one of the discrete units of interaction in an API and is typically a combination of the
base URL and a resource path.
Answer: Statelessness in RESTful APIs means that each request from a client to a server must contain all
the information needed to understand and process the request. The server does not store any context or
11
End to End API Testing, Curated by Lamhot Siagian
session information about the client between requests, making each request independent and
self-contained.
Answer: An API key is a unique identifier used to authenticate a client accessing an API. It helps track and
control how the API is used, ensuring that only authorized users can make requests. API keys are
commonly used for security purposes to prevent misuse and limit the number of requests from a client.
Answer: CORS (Cross-Origin Resource Sharing) is a security feature implemented by web browsers to
prevent web pages from making requests to a different domain than the one that served the web page. It is
important in web APIs because it enables servers to specify who can access their resources, ensuring that
only trusted domains can make cross-origin requests.
8. What are some common status codes returned by APIs, and what do they mean?
Answer:
Answer: API versioning ensures that changes in the API do not break existing client applications. It allows
developers to introduce new features and improvements without disrupting the current functionality for
existing users. Versioning can be implemented in several ways:
● URL Path: Including the version number in the URL (e.g., /v1/users).
● Query Parameters: Adding a version parameter in the query string (e.g., ?version=1).
● Headers: Using a custom header to specify the version (e.g., Accept:
application/vnd.myapi.v1+json).
10. What are the differences between synchronous and asynchronous API calls?
Answer:
12
End to End APIs and API Testing, Curated by Lamhot Siagian
○ The client sends a request and waits for the server to respond.
○ The client is blocked until the response is received.
○ Simple and straightforward but can lead to inefficiencies if the server takes a long time to
respond.
● Asynchronous API Calls:
○ The client sends a request and continues processing other tasks.
○ The client is notified (usually via a callback or promise) when the response is ready.
○ More efficient for long-running operations, as it doesn't block the client.
Answer: Rate limiting is a mechanism to control the number of requests a client can make to an API within
a certain time period. It is important for:
● Preventing Abuse: Protects the API from being overwhelmed by too many requests from a single
client.
● Ensuring Fair Usage: Ensures that all clients have fair access to the API.
● Maintaining Performance: Helps maintain the API's performance and availability by avoiding
excessive load.
Answer: API throttling is a technique used to control the usage of an API by limiting the number of
requests that can be made in a specific time frame. It helps in managing the load on the server, ensuring
service availability, and preventing abuse. Throttling can be implemented by setting a limit on the number
of requests per minute, hour, or day.
13