API Automation
API Automation
API Automation
Complete Interview Guide
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
Kalpesh Jain
SDET @ Algebrik AI | Mentor | 42K+ Community ■
Bengaluru, Karnataka, India
[Link]/in/kalpeshnjain09
JSPM University Pune
Page 1
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Table of Contents
API FUNDAMENTALS
1. What is API
2. Types of APIs
3. API Architecture
4. Client-Server Communication
5. REST API Basics ★
6. JSON Basics
7. Real-Time API Flow ★
8. Best Practices
HTTP METHODS
1. GET Method
2. POST Method ★
3. PUT Method ★
4. DELETE Method
5. PATCH Method
6. Idempotency ★
7. Real-Time Scenarios
8. Best Practices
STATUS CODES
1. What are Status Codes
2. 2xx Success Codes ★
3. 4xx Client Error Codes ★
4. 5xx Server Error Codes ★
5. Most Important Status Codes
6. Real-Time Scenarios
7. Negative Testing
8. Best Practices
Page 2
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
2. What is Response
3. Request Components ★
4. Response Components ★
5. Request Body
6. Response Body
7. Query Parameters
8. Path Parameters ★
9. Real-Time Flow
10. Best Practices
API VALIDATION
1. What is API Validation
2. Status Code Validation ★
3. Response Body Validation ★
4. Header Validation
5. Schema Validation ★
6. Response Time Validation
7. Data Validation
8. Negative Validation ★
9. Real-Time Scenarios
10. Best Practices
Page 3
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
API CHAINING
1. What is API Chaining
2. Why API Chaining is Used ★
3. Dynamic Data Handling
4. Token Chaining ★
5. ID Chaining ★
6. Multi-Step API Flow
7. Real-Time Scenarios ★
8. Common Challenges
9. Best Practices
10. Common Interview Questions
POSTMAN
1. What is Postman
2. Postman Features ★
3. Collections
4. Environment Variables ★
5. Request Creation
6. Response Validation
7. Authorization Handling
8. Pre-request Scripts
9. Tests Tab ★
10. Collection Runner
11. Newman CLI ★
12. Real-Time Scenarios
13. Best Practices
REST ASSURED
1. What is Rest Assured
2. Rest Assured Architecture
3. HTTP Methods in Rest Assured ★
4. Request Specification ★
5. Response Validation ★
6. Authentication Handling
Page 4
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Page 5
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
SCHEMA VALIDATION
1. What is Schema Validation
2. Why Schema Validation is Important ★
3. JSON Schema Basics
4. Response Structure Validation
5. Required Fields Validation ★
6. Data Type Validation
7. Nested JSON Validation ★
8. Schema Validation in Rest Assured ★
9. Schema Validation in Postman
10. Real-Time Scenarios
11. Best Practices
12. Common Interview Questions
API MOCKING
1. What is API Mocking
2. Why API Mocking is Important ★
3. Mock Server Basics
4. Types of Mocking
5. Mocking in Postman ★
6. Mocking Using WireMock ★
7. Mocking Third-Party APIs
8. Simulating Error Responses ★
9. Real-Time Scenarios ★
10. Best Practices
11. Common Mistakes
12. Common Interview Questions
REAL-TIME SCENARIOS
1. What are Real-Time Scenarios
2. Login API Automation ★
3. User Management APIs
4. E-Commerce API Flow ★
5. Banking API Flow
Page 6
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
BEST PRACTICES
1. What are API Automation Best Practices
2. Reusable Framework Design ★
3. Strong Assertions ★
4. Dynamic Test Data Handling
5. Proper API Validation
6. Negative Testing ★
7. Environment Management
8. Logging & Reporting
9. CI/CD Integration
10. Error Handling & Retry Logic ★
11. Test Data Cleanup
12. Common Interview Questions
Page 7
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
API FUNDAMENTALS
1. What is API
What is it
API (Application Programming Interface) is a medium that allows two applications or systems to
communicate with each other.
Key Components
• Request
• Response
• Endpoint
• Client
• Server
Practical Example
Example
Common Mistakes
✕ Saying API is only for testing
✕ Confusing API with database
✕ Ignoring request-response flow
2. Types of APIs
Page 8
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
What is it
Different API categories based on accessibility and architecture.
Key Components
• REST API
• SOAP API
• GraphQL API
• Internal API
• Public API
Practical Example
Example
Common Mistakes
✕ Not knowing REST vs SOAP
✕ Saying SOAP is modern standard
✕ Ignoring GraphQL basics
3. API Architecture
What is it
API architecture defines how APIs are designed and communicate.
Key Components
• Client
• Server
• Endpoint
Page 9
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
• HTTP Protocol
• Request/Response
Practical Example
Example
Common Mistakes
✕ Confusing frontend and backend roles
✕ Not understanding stateless communication
4. Client-Server Communication
What is it
Communication model where client sends requests and server returns responses.
Key Components
• Request
• Response
• HTTP
• Status Code
• Data Exchange
Practical Example
Page 10
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Example
Common Mistakes
✕ Ignoring status codes
✕ Confusing request and response
What is it
REST (Representational State Transfer) is a lightweight architecture used for API communication over
HTTP.
Key Components
• HTTP methods
• Stateless
• JSON
• Resource-based URLs
Practical Example
Example
GET /users
POST /users
PUT /users/1
DELETE /users/1
Common Mistakes
✕ Not understanding statelessness
Page 11
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
6. JSON Basics
What is it
JSON (JavaScript Object Notation) is a lightweight data format used in APIs.
Key Components
• Key-value pairs
• Objects
• Arrays
• Nested JSON
Practical Example
Example
"name": "Kalpesh",
"role": "SDET"
Common Mistakes
✕ Invalid JSON syntax
✕ Confusing object and array
Page 12
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
What is it
Understanding how APIs work in real applications.
Key Components
• Frontend
• Backend
• Database
• API layer
Practical Example
Example
Mobile App
API Layer
Database
Common Mistakes
✕ Thinking frontend directly accesses database
✕ Ignoring backend processing
8. Best Practices
What is it
Guidelines for understanding and testing APIs effectively.
Page 13
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Key Components
• Proper validations
• Understanding architecture
• Response verification
• Error handling
Practical Example
Validate
- Status Code
- Response Body
- Headers
- Response Time
Common Mistakes
✕ Only validating status codes
✕ Ignoring negative testing
✕ Weak validations
1. REST API
2. Request-Response Flow
3. JSON Basics
4. Real-Time Architecture
Page 14
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
HTTP METHODS
1. GET Method
What is it
GET method is used to retrieve/fetch data from the server.
Key Components
• Read operation
• No request body
• Query parameters
• Safe operation
Practical Example
Example
GET /users
GET /users/101
GET /products?category=mobile
Common Mistakes
✕ Sending body in GET request
✕ Using GET for update operations
✕ Ignoring query parameters
2. POST Method ★
What is it
Page 15
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Key Components
• Create operation
• Request body
• JSON payload
• Data submission
Practical Example
Example
POST /users
Content-Type: application/json
Common Mistakes
✕ Missing request body
✕ Invalid JSON format
✕ Not validating response
3. PUT Method ★
What is it
PUT method is used to update existing resources completely.
Key Components
• Update operation
• Full resource update
• Idempotent operation
Page 16
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Practical Example
Example
PUT /users/1
Common Mistakes
✕ Using PUT for partial updates
✕ Confusing PUT and PATCH
4. DELETE Method
What is it
DELETE method removes resources/data from the server.
Key Components
• Delete operation
• Resource removal
• Permanent deletion
Practical Example
Example
DELETE /users/1
Common Mistakes
Page 17
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
5. PATCH Method
What is it
PATCH method is used for partial updates of resources.
Key Components
• Partial update
• Lightweight update
• Specific field modification
Practical Example
Example
PATCH /users/1
Common Mistakes
✕ Confusing PATCH with PUT
✕ Sending full payload unnecessarily
6. Idempotency ★
Page 18
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
What is it
Idempotency means performing the same operation multiple times gives the same result.
Key Components
• Repeatable operation
• Same result
• Resource consistency
Practical Example
Example
Common Mistakes
✕ Saying POST is idempotent
✕ Confusing response and state
7. Real-Time Scenarios ★
1. User Registration
POST /users
3. Update Profile
PUT /users/1
4. Delete Account
DELETE /users/1
Page 19
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
8. Best Practices
What is it
Guidelines for using HTTP methods properly in APIs.
Key Components
• Correct method usage
• Proper validations
• Resource-based APIs
• Secure operations
Common Mistakes
✕ Wrong HTTP method usage
✕ Ignoring status code validations
✕ Weak API design understanding
1. POST vs PUT
2. Idempotency
3. PUT vs PATCH
Page 20
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
STATUS CODES
What is it
HTTP status codes are server responses that indicate whether an API request was successful or failed.
Key Components
• Response status
• Success codes
• Error codes
• Client/server communication
Practical Example
Example
200 → Success
Common Mistakes
✕ Ignoring status code validation
✕ Validating only response body
✕ Confusing client and server errors
What is it
Page 21
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Key Components
• 200 OK
• 201 Created
• 204 No Content
Practical Example
Example
Common Mistakes
✕ Expecting 200 for every API
✕ Ignoring 201 for create operations
What is it
4xx codes indicate client-side/request-related issues.
Key Components
• 400 Bad Request
• 401 Unauthorized
• 403 Forbidden
• 404 Not Found
Page 22
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
4xx status codes occur when the request sent by client is invalid, unauthorized, or requests unavailable
resources.
Practical Example
Example
Common Mistakes
✕ Confusing 401 and 403
✕ Ignoring negative testing
What is it
5xx codes indicate server-side failures.
Key Components
• 500 Internal Server Error
• 502 Bad Gateway
• 503 Service Unavailable
Practical Example
Example
Page 23
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Common Mistakes
✕ Assuming all failures are frontend issues
✕ Not reporting server logs properly
Code Meaning
200 OK
201 Created
204 No Content
401 Unauthorized
403 Forbidden
6. Real-Time Scenarios ★
1. Login Failure
401 Unauthorized
Page 24
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
4. Backend Crash
500 Internal Server Error
7. Negative Testing ★
What is it
Testing APIs with invalid or unexpected data.
Key Components
• Invalid payload
• Missing headers
• Unauthorized access
• Boundary testing
Practical Example
Example
Common Mistakes
✕ Testing only positive scenarios
✕ Ignoring invalid data testing
Page 25
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
8. Best Practices
What is it
Guidelines for validating and handling API status codes effectively.
Key Components
• Validate all responses
• Include negative testing
• Log failures properly
• Verify error messages
Common Mistakes
✕ Validating only success cases
✕ Ignoring error response body
✕ Weak assertions
1. 401 vs 403
2. 4xx vs 5xx
3. Negative Testing
4. 200 vs 201
Page 26
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
1. What is Request
What is it
A request is data sent from client to server asking for some operation or information.
Key Components
• Endpoint
• Method
• Headers
• Body
• Parameters
Practical Example
Example
POST /users
Common Mistakes
✕ Missing mandatory headers
✕ Invalid payload structure
✕ Wrong endpoint usage
2. What is Response
What is it
A response is data returned by server after processing the client request.
Page 27
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Key Components
• Status code
• Response body
• Headers
• Response time
Practical Example
Example
"id": 1,
"name": "Kalpesh"
Common Mistakes
✕ Validating only status code
✕ Ignoring response body validation
3. Request Components ★
What is it
Important elements included in API requests.
Key Components
• URL
• HTTP Method
• Headers
• Body
• Authentication
Page 28
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
• Parameters
Practical Example
Example
POST /users
Content-Type: application/json
Common Mistakes
✕ Missing authentication
✕ Wrong content type
✕ Invalid parameters
4. Response Components ★
What is it
Important data returned in API responses.
Key Components
• Status code
• Response body
• Headers
• Cookies
• Response time
Page 29
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Practical Example
Example
200 OK
Content-Type: application/json
Common Mistakes
✕ Ignoring headers validation
✕ Not validating response time
5. Request Body ★
What is it
Request body contains data sent to server during API operations.
Key Components
• JSON payload
• Input data
• Objects
• Arrays
Practical Example
Example
"name": "Kalpesh",
"role": "SDET"
Common Mistakes
✕ Invalid JSON format
Page 30
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
6. Response Body ★
What is it
Response body contains data returned from server.
Key Components
• JSON response
• API output
• Business data
• Error message
Practical Example
Example
"status": "success",
"userId": 101
Common Mistakes
✕ Weak field validations
✕ Ignoring error messages
Page 31
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
7. Query Parameters
What is it
Query parameters are optional key-value pairs passed in URL for filtering or searching data.
Key Components
• Filtering
• Searching
• Pagination
Practical Example
Example
GET /users?page=1
GET /products?category=mobile
Common Mistakes
✕ Invalid query format
✕ Hardcoded query values
8. Path Parameters ★
What is it
Path parameters identify specific resources directly in URL path.
Key Components
• Resource identification
• Dynamic values
• URL path
Page 32
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Practical Example
Example
GET /users/101
Common Mistakes
✕ Confusing path and query params
✕ Hardcoding resource IDs
2. Product Search
GET /products?category=mobile
What is it
Guidelines for validating requests and responses effectively.
Key Components
• Proper validations
• Secure headers
• Validate body and status
• Negative testing
Page 33
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Common Mistakes
✕ Validating only response code
✕ Ignoring headers and body
✕ No negative testing
1. Request vs Response
Page 34
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
What is it
Headers are key-value pairs sent between client and server containing metadata about the request or
response.
Key Components
• Authorization
• Content-Type
• Accept
• Cookies
• Custom headers
Practical Example
Example
Content-Type: application/json
Common Mistakes
✕ Missing mandatory headers
✕ Wrong content type
✕ Exposing sensitive data
2. Types of Headers
Page 35
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
What is it
Different categories of headers used during API communication.
Key Components
• Request headers
• Response headers
• General headers
• Security headers
Practical Example
Example
Request Header:
Response Header:
Content-Type: application/json
Common Mistakes
✕ Confusing request and response headers
✕ Ignoring response header validations
3. Authentication Basics ★
What is it
Authentication verifies user or system identity before granting API access.
Key Components
• Username/password
• Tokens
Page 36
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
• API keys
• OAuth
Practical Example
Example
Common Mistakes
✕ Exposing credentials in code
✕ Ignoring token expiration
✕ Weak security practices
What is it
Bearer token authentication uses tokens passed in Authorization header to access protected APIs.
Key Components
• JWT token
• Authorization header
• Token expiration
• Secure access
Practical Example
Example
Page 37
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Common Mistakes
✕ Hardcoding tokens
✕ Using expired tokens
✕ Incorrect token format
5. Basic Authentication
What is it
Basic authentication uses username and password encoded in request headers.
Key Components
• Username
• Password
• Base64 encoding
Practical Example
Example
Common Mistakes
✕ Sending credentials without HTTPS
✕ Confusing encoding with encryption
Page 38
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
6. API Keys
What is it
API keys are unique identifiers used to authenticate API consumers.
Key Components
• API key
• Access control
• Usage tracking
Practical Example
Example
x-api-key: abc123xyz
Common Mistakes
✕ Exposing API keys publicly
✕ Hardcoding keys in repository
7. OAuth Basics ★
What is it
OAuth is an authorization framework that allows secure third-party access without exposing passwords.
Key Components
• Access token
• Authorization server
• Client application
• Resource owner
Page 39
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Practical Example
Example
Common Mistakes
✕ Confusing OAuth with authentication only
✕ Not understanding token flow
8. Real-Time Scenarios ★
1. Login Flow
Login API → Generate JWT Token
3. Third-Party Login
OAuth → Login with Google
What is it
Guidelines for secure API communication and authentication handling.
Key Components
• Avoid hardcoding credentials
• Use HTTPS
• Secure token handling
• Token expiration management
Page 40
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Practical Example
Example
Common Mistakes
✕ Hardcoded passwords
✕ Exposed tokens in logs
✕ Weak security validation
1. Bearer Token
2. Authentication vs Authorization
Page 41
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
API VALIDATION
What is it
API validation ensures API responses are correct, complete, secure, and meet business requirements.
Key Components
• Functional validation
• Data validation
• Performance validation
• Security validation
Practical Example
Example
Validate:
- Status Code
- Response Body
- Headers
- Response Time
Common Mistakes
✕ Validating only status code
✕ Ignoring response data
✕ No negative testing
Page 42
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
What is it
Checking whether API returns expected HTTP status codes.
Key Components
• 200 OK
• 201 Created
• 400 Bad Request
• 401 Unauthorized
• 500 Server Error
Practical Example
Example
expect([Link]()).toBe(200);
Common Mistakes
✕ Hardcoded incorrect expectations
✕ Ignoring failure scenarios
What is it
Validating API response content and business data.
Key Components
• JSON validation
• Field validation
• Data correctness
Page 43
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
• Response structure
Practical Example
Example
expect([Link]).toBe('Kalpesh');
Common Mistakes
✕ Weak assertions
✕ Validating only one field
✕ Ignoring nested JSON
4. Header Validation
What is it
Validating response headers returned by APIs.
Key Components
• Content-Type
• Authorization
• Cache-Control
• Security headers
Practical Example
Example
expect([Link]()['content-type'])
Page 44
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
.toContain('application/json');
Common Mistakes
✕ Ignoring headers validation
✕ Incorrect content type expectations
5. Schema Validation ★
What is it
Schema validation verifies API response structure and data types.
Key Components
• JSON schema
• Data types
• Required fields
• Structure validation
Practical Example
Example
"id": "number",
"name": "string"
Common Mistakes
✕ Validating only field values
✕ Ignoring missing fields
✕ No structure validation
Page 45
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
What is it
Validating API performance and response speed.
Key Components
• Response time
• Performance check
• SLA validation
Practical Example
Example
expect(responseTime).toBeLessThan(2000);
Common Mistakes
✕ Ignoring performance validation
✕ Unrealistic thresholds
7. Data Validation
What is it
Validating actual business data returned by APIs.
Key Components
Page 46
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
• Field values
• Database consistency
• Dynamic data
• Business logic
Practical Example
Example
Common Mistakes
✕ Static validations only
✕ Ignoring dynamic values
8. Negative Validation ★
What is it
Testing API behavior with invalid or unexpected inputs.
Key Components
• Invalid payload
• Missing token
• Invalid endpoint
• Boundary testing
Practical Example
Example
Page 47
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Common Mistakes
✕ Testing only positive scenarios
✕ Ignoring invalid data tests
9. Real-Time Scenarios ★
1. Login Validation
Validate: Token generated, Status code 200, Response time
2. User Creation
Validate: User ID generated, 201 Created, Correct response body
3. Invalid Login
Validate: 401 Unauthorized, Error message
What is it
Guidelines for writing reliable API validations.
Key Components
• Strong assertions
• Negative testing
• Schema validation
• Reusable validations
Page 48
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Common Mistakes
✕ Weak validations
✕ No schema checks
✕ Ignoring error responses
2. Schema Validation
3. Negative Validation
Page 49
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
API CHAINING
What is it
API chaining means using data from one API response in another API request.
Key Components
• Dynamic response data
• Sequential requests
• Dependency flow
• Request-response linking
Practical Example
Example
Common Mistakes
✕ Hardcoding IDs
✕ Ignoring dependency failures
✕ Poor response handling
What is it
API chaining is used to automate real business workflows where APIs depend on previous responses.
Page 50
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Key Components
• Dynamic workflows
• Data dependency
• End-to-end flow
• Real-time testing
Practical Example
Example
Common Mistakes
✕ Using static data
✕ Ignoring response validations
What is it
Using runtime-generated values during API execution.
Key Components
• Dynamic IDs
• Tokens
• Session values
• Runtime variables
Page 51
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Practical Example
Example
Common Mistakes
✕ Hardcoded test data
✕ Reusing expired tokens
4. Token Chaining ★
What is it
Using authentication token generated from one API in subsequent APIs.
Key Components
• Login API
• JWT token
• Authorization header
• Secured APIs
Practical Example
Example
headers: {
Common Mistakes
✕ Token expiration handling issues
Page 52
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
5. ID Chaining ★
What is it
Using resource IDs generated from one API in another API request.
Key Components
• Dynamic resource IDs
• CRUD operations
• Resource linking
Practical Example
Example
GET /users/{userId}
Common Mistakes
✕ Hardcoded IDs
✕ Invalid resource handling
Page 53
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
What is it
Executing multiple dependent APIs sequentially to simulate complete workflows.
Key Components
• Sequential execution
• Dependency management
• Workflow automation
Practical Example
Example
Common Mistakes
✕ Ignoring intermediate validations
✕ No cleanup handling
7. Real-Time Scenarios ★
1. E-Commerce Flow
Login → Add Product → Place Order → Payment
2. Banking Flow
Login → Fetch Balance → Transfer Money
8. Common Challenges
Page 54
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
What is it
Problems commonly faced during chained API automation.
Key Components
• Token expiration
• Dynamic data issues
• Dependency failures
• Cleanup management
Practical Example
Example
Common Mistakes
✕ No retry handling
✕ Weak cleanup logic
9. Best Practices ★
What is it
Guidelines for reliable chained API automation.
Key Components
• Dynamic data usage
• Proper validations
• Cleanup handling
• Reusable methods
Page 55
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
I use dynamic response handling, reusable API utilities, proper validations, and cleanup mechanisms for
stable API chaining automation.
Practical Example
Example
Common Mistakes
✕ Hardcoded dependencies
✕ No response validation
1. Token Chaining
Page 56
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
POSTMAN
1. What is Postman
What is it
Postman is an API testing and development tool used to send requests, validate responses, and automate
API workflows.
Key Components
• API requests
• Collections
• Environment variables
• Automation scripts
• API debugging
Practical Example
Example
Common Mistakes
✕ Hardcoding environment values
✕ Ignoring automation capabilities
✕ No response validations
2. Postman Features ★
What is it
Page 57
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Key Components
• API testing
• Automation
• Collections
• Environment handling
• Collection runner
Practical Example
Example
Common Mistakes
✕ Using Postman only for manual testing
✕ Ignoring reusable collections
3. Collections
What is it
Collections are groups of saved API requests.
Key Components
• Organized requests
• Folder structure
• Reusability
• Shared workflows
Page 58
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Collections help organize APIs into reusable workflows and simplify execution of multiple API requests
together.
Practical Example
Example
User APIs
Common Mistakes
✕ Unorganized collections
✕ Duplicate APIs
4. Environment Variables ★
What is it
Variables used to store reusable dynamic values.
Key Components
• Base URL
• Tokens
• Environment configs
• Dynamic data
Practical Example
Example
{{baseUrl}}
Page 59
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
{{token}}
Common Mistakes
✕ Hardcoding URLs
✕ Storing sensitive credentials insecurely
5. Request Creation
What is it
Creating and configuring API requests in Postman.
Key Components
• URL
• HTTP methods
• Headers
• Body
• Authorization
Practical Example
Example
POST /users
Content-Type: application/json
Common Mistakes
✕ Wrong HTTP method
✕ Invalid JSON payload
✕ Missing authentication
Page 60
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
6. Response Validation
What is it
Validating API responses after request execution.
Key Components
• Status code
• Response body
• Headers
• Response time
Practical Example
Example
[Link](200);
Common Mistakes
✕ Weak validations
✕ Validating only status code
7. Authorization Handling ★
What is it
Managing API authentication in Postman.
Key Components
Page 61
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
• Bearer token
• Basic auth
• OAuth
• API keys
Practical Example
Example
Common Mistakes
✕ Expired tokens
✕ Hardcoded credentials
8. Pre-request Scripts
What is it
Scripts executed before API requests.
Key Components
• Dynamic token generation
• Variable setup
• Data preparation
Practical Example
Example
[Link]("token", "abc123");
Page 62
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Common Mistakes
✕ Complex unnecessary scripting
✕ Hardcoded values
9. Tests Tab ★
What is it
Section used to write validations and assertions after API execution.
Key Components
• Assertions
• Status validation
• JSON validation
• Dynamic variables
Practical Example
Example
[Link](200);
});
Common Mistakes
✕ Weak assertions
✕ No negative validations
Page 63
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
What is it
Tool used to execute multiple API requests together.
Key Components
• Sequential execution
• Data-driven testing
• Batch execution
Practical Example
Example
Common Mistakes
✕ Ignoring execution order
✕ No data cleanup
What is it
Newman is Postman's command-line tool used for automation and CI/CD execution.
Key Components
• CLI execution
• Jenkins integration
• Reporting
Page 64
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
• Automation pipelines
Practical Example
Example
Common Mistakes
✕ Ignoring reporting
✕ Incorrect environment setup
1. Login Automation
Generate token → Store variable → Access secured APIs
3. Multi-Environment Testing
QA → UAT → Production
What is it
Guidelines for efficient Postman usage.
Key Components
• Reusable collections
• Environment variables
Page 65
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
• Proper assertions
• Secure credential handling
Common Mistakes
✕ Hardcoded data
✕ Weak assertions
✕ No collection organization
1. Environment Variables
2. Tests Tab
3. Newman CLI
4. Collection Runner
Page 66
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
REST ASSURED
What is it
Rest Assured is a Java library used for automating REST API testing.
Key Components
• Java-based
• API automation
• Request handling
• Response validation
Practical Example
Example
given()
.when()
.get("/users")
.then()
.statusCode(200);
Common Mistakes
✕ Weak assertions
✕ Hardcoded data
✕ Poor reusable design
Page 67
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
What is it
Structure and flow of Rest Assured API automation.
Key Components
• Request
• Response
• Validation
• Assertions
Practical Example
Example
given()
.when()
.then()
Common Mistakes
✕ Mixing validations and request setup
✕ No reusable utilities
What is it
Executing API methods using Rest Assured.
Key Components
• GET
Page 68
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
• POST
• PUT
• DELETE
• PATCH
Practical Example
Example
given()
.when()
.post("/users");
Common Mistakes
✕ Wrong HTTP method usage
✕ Missing validations
4. Request Specification ★
What is it
Reusable request configuration in Rest Assured.
Key Components
• Base URI
• Headers
• Authentication
• Reusable setup
Page 69
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Practical Example
Example
RequestSpecification req =
given()
.baseUri("[Link]
Common Mistakes
✕ Duplicate request setup
✕ Hardcoded configurations
5. Response Validation ★
What is it
Validating API responses using assertions.
Key Components
• Status code
• Response body
• Headers
• Schema validation
Practical Example
Example
then()
.statusCode(200)
.body("name", equalTo("Kalpesh"));
Common Mistakes
✕ Weak assertions
Page 70
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
6. Authentication Handling
What is it
Managing secured API authentication in Rest Assured.
Key Components
• Bearer token
• Basic auth
• OAuth
• API keys
Practical Example
Example
given()
.auth()
.oauth2(token);
Common Mistakes
✕ Hardcoded credentials
✕ Expired token handling issues
Page 71
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
What is it
Extracting response data dynamically from JSON.
Key Components
• Dynamic extraction
• JSON path
• Runtime values
Practical Example
Example
String token =
[Link]().getString("token");
Common Mistakes
✕ Incorrect JSON path
✕ Hardcoded response values
What is it
Converting Java objects to JSON and vice versa.
Key Components
• POJO classes
• JSON conversion
• Object mapping
Page 72
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Practical Example
Example
Common Mistakes
✕ Incorrect POJO mapping
✕ Field mismatch issues
9. API Chaining ★
What is it
Using response data from one API into another API.
Key Components
• Dynamic IDs
• Tokens
• Sequential APIs
Practical Example
Example
String userId =
[Link]().getString("id");
Common Mistakes
✕ Hardcoded IDs
Page 73
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
What is it
Integrating Rest Assured into automation frameworks.
Key Components
• TestNG/JUnit
• Maven
• Reporting
• CI/CD
Practical Example
Example
Common Mistakes
✕ Poor framework structure
✕ No reusable utilities
Page 74
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
1. Login Automation
Generate token → Access secured APIs
2. CRUD Operations
Create → Fetch → Update → Delete
What is it
Guidelines for scalable API automation using Rest Assured.
Key Components
• Reusable utilities
• Strong validations
• Dynamic data handling
• Centralized configurations
Common Mistakes
✕ Hardcoded test data
✕ Weak assertions
✕ Duplicate API methods
1. Request Specification
2. Response Validation
Page 75
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Page 76
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
What is it
Data-driven testing is a testing approach where test data is separated from test scripts and executed using
multiple datasets.
Key Components
• External test data
• Reusable scripts
• Multiple datasets
• Parameterization
Practical Example
Example
→ Multiple usernames/passwords
Common Mistakes
✕ Hardcoded test data
✕ Duplicate test scripts
✕ Poor data management
What is it
Page 77
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Key Components
• Scalability
• Reusability
• Reduced duplication
• Faster execution
Practical Example
Example
- Valid users
- Invalid users
- Empty credentials
Common Mistakes
✕ Creating separate tests for every dataset
✕ Static test execution
What is it
Different formats used to store automation data.
Key Components
• JSON
• Excel
• CSV
• Database
Page 78
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
• Environment variables
Practical Example
Example
[Link]
[Link]
[Link]
Common Mistakes
✕ Poor data organization
✕ Duplicate datasets
What is it
Using JSON files to store and manage API test data.
Key Components
• Structured data
• Nested objects
• Dynamic payloads
Practical Example
Example
Page 79
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
"username": "Kalpesh",
"password": "12345"
Common Mistakes
✕ Invalid JSON syntax
✕ Hardcoded dynamic values
What is it
Using Excel sheets for storing automation datasets.
Key Components
• Rows and columns
• Bulk test data
• External data source
Practical Example
Example
Username | Password
user1 | pass1
user2 | pass2
Common Mistakes
✕ Complex Excel dependencies
✕ Poor file maintenance
Page 80
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
What is it
Using CSV files for lightweight data-driven execution.
Key Components
• Comma-separated values
• Lightweight structure
• Bulk datasets
Practical Example
Example
username,password
user1,pass1
Common Mistakes
✕ Invalid formatting
✕ Encoding issues
What is it
Generating unique runtime test data during execution.
Key Components
• Dynamic emails
Page 81
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
• Random values
• Unique IDs
• Runtime variables
Practical Example
Example
const email =
`test${[Link]()}@[Link]`;
Common Mistakes
✕ Duplicate test data
✕ Reusing static users
8. Parameterization ★
What is it
Passing multiple input values into reusable test scripts.
Key Components
• Reusable tests
• Dynamic inputs
• Multiple datasets
Practical Example
Example
Page 82
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Login(username, password)
Common Mistakes
✕ Hardcoded parameters
✕ Poor reusable design
9. Real-Time Scenarios ★
1. Login Testing
Test: Valid users, Invalid users, Locked users
3. Dynamic Registration
Generate unique email IDs
What is it
Integrating data-driven approach into automation frameworks.
Key Components
• Utility classes
• External files
• Reusable methods
• Centralized data
Practical Example
Page 83
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Example
Framework
■■■ [Link]
■■■ [Link]
Common Mistakes
✕ Duplicate data logic
✕ No centralized data handling
What is it
Guidelines for scalable data-driven automation.
Key Components
• Reusable data
• Dynamic generation
• Centralized management
• Clean datasets
Practical Example
Example
Use:
- JSON data
- Utility methods
- Dynamic values
Common Mistakes
Page 84
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
✕ Hardcoded datasets
✕ Duplicate test cases
✕ Poor data cleanup
2. Parameterization
4. Framework Integration
Page 85
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
1. What is CI/CD
What is it
CI/CD stands for Continuous Integration and Continuous Deployment/Delivery.
Key Components
• Automated builds
• Automated testing
• Continuous deployment
• Faster feedback
Practical Example
Example
Common Mistakes
✕ Manual execution dependency
✕ No automated validations
2. What is Jenkins ★
What is it
Jenkins is an open-source automation server used for CI/CD pipeline execution.
Key Components
Page 86
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
• Pipelines
• Build jobs
• Scheduling
• Plugins
• Reporting
Practical Example
Example
Common Mistakes
✕ Poor job organization
✕ No reporting integration
What is it
Using Jenkins for automated execution and continuous testing.
Key Components
• Automated execution
• Scheduled jobs
• Faster feedback
• Team collaboration
Practical Example
Page 87
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Example
Common Mistakes
✕ Manual test execution dependency
✕ No pipeline monitoring
What is it
A Jenkins pipeline defines stages for automated execution workflows.
Key Components
• Stages
• Build
• Test
• Deploy
• Reporting
Practical Example
Example
pipeline {
stages {
stage('Build') {}
stage('Test') {}
Common Mistakes
Page 88
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
What is it
Executing API automation frameworks through Jenkins pipelines.
Key Components
• Maven commands
• Newman execution
• Build triggers
• Reports
Practical Example
Example
Common Mistakes
✕ No environment configuration
✕ Poor report handling
6. Maven Integration
Page 89
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
What is it
Using Maven commands to execute automation suites in Jenkins.
Key Components
• [Link]
• Build lifecycle
• Dependency management
Practical Example
Example
Common Mistakes
✕ Dependency conflicts
✕ Incorrect build configuration
7. Newman Integration
What is it
Executing Postman collections through Jenkins using Newman.
Key Components
• Newman CLI
• Collection execution
• Environment configs
• Reports
Page 90
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Practical Example
Example
Common Mistakes
✕ Incorrect environment files
✕ No report generation
8. Scheduled Execution
What is it
Running automation suites automatically at scheduled times.
Key Components
• Cron jobs
• Nightly execution
• Regression suites
Practical Example
Example
Common Mistakes
✕ No monitoring for failures
✕ Resource conflicts during execution
Page 91
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
9. Reporting in Jenkins ★
What is it
Generating and publishing automation reports in Jenkins.
Key Components
• HTML reports
• Allure reports
• Execution logs
• Failure screenshots
Practical Example
Example
Common Mistakes
✕ No report archiving
✕ Poor failure logging
1. Nightly Regression
Execute full API regression every night
2. PR Validation
Trigger automation after code commit
3. Multi-Environment Execution
QA → UAT → Staging pipelines
Page 92
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
What is it
Guidelines for stable CI/CD automation execution.
Key Components
• Stable pipelines
• Proper reporting
• Environment handling
• Failure notifications
Common Mistakes
✕ Weak failure analysis
✕ Hardcoded environment values
✕ No notifications setup
■ What is Jenkins?
■ Explain CI/CD pipeline.
■ Difference between freestyle and pipeline jobs?
■ How do you integrate API automation with Jenkins?
■ What reports have you used?
■ Have you scheduled automation runs?
1. Jenkins Pipeline
2. Automation Integration
Page 93
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
3. Reporting in Jenkins
4. Scheduled Execution
Page 94
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
SCHEMA VALIDATION
What is it
Schema validation verifies whether an API response matches the expected JSON structure and data
format.
Key Components
• Response structure
• Field validation
• Data types
• Mandatory fields
Practical Example
Example
"id": 101,
"name": "Kalpesh"
Common Mistakes
✕ Validating only status code
✕ Ignoring response structure
✕ Weak field validations
Page 95
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
What is it
Schema validation prevents API contract failures and response structure issues.
Key Components
• API contract validation
• Stability checks
• Response consistency
• Regression safety
Practical Example
Example
Common Mistakes
✕ Ignoring contract changes
✕ Validating only response values
What is it
JSON Schema defines expected response structure and rules.
Key Components
• Properties
• Required fields
Page 96
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
• Data types
• Arrays
• Objects
Practical Example
Example
"type": "object",
"properties": {
Common Mistakes
✕ Incorrect schema format
✕ Missing required validations
What is it
Validating API response hierarchy and structure.
Key Components
• Parent-child structure
• Nested objects
• Arrays
• Field hierarchy
Page 97
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Practical Example
Example
"user": {
"name": "Kalpesh"
Common Mistakes
✕ Ignoring nested structures
✕ Partial validation only
What is it
Checking whether mandatory fields exist in response.
Key Components
• Mandatory keys
• Required properties
• Null validations
Practical Example
Example
Required:
- id
- token
- status
Page 98
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Common Mistakes
✕ Ignoring missing fields
✕ No null checks
What is it
Validating response field data types.
Key Components
• String
• Integer
• Boolean
• Array
• Object
Practical Example
Example
"id": 101,
"active": true
Common Mistakes
✕ Type mismatch issues
✕ Ignoring boolean validations
Page 99
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
What is it
Validating deeply nested response structures.
Key Components
• Nested objects
• Arrays
• Child fields
• JSON hierarchy
Practical Example
Example
"user": {
"address": {
"city": "Bangalore"
Common Mistakes
✕ Weak nested validations
✕ Ignoring child objects
Page 100
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
What is it
Using Rest Assured libraries to validate JSON schema.
Key Components
• JSON schema validator
• Schema files
• Assertion libraries
Practical Example
Example
then().assertThat()
.body(matchesJsonSchemaInClasspath("[Link]"));
Common Mistakes
✕ Incorrect schema file path
✕ Weak schema definitions
What is it
Validating response structure using Postman test scripts.
Key Components
• [Link]
• JSON validation
• Response assertions
Page 101
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Practical Example
Example
[Link]([Link]).[Link].a('number');
Common Mistakes
✕ Weak assertions
✕ Missing datatype validations
1. Login API
Validate: token, userId, response structure
2. User API
Validate: nested address object, phone number array
3. E-Commerce APIs
Validate: order structure, product arrays, payment details
What is it
Guidelines for strong schema validation implementation.
Key Components
• Reusable schemas
• Strong assertions
• Nested validations
• Contract consistency
Page 102
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Common Mistakes
✕ Weak schema definitions
✕ Ignoring nested objects
✕ No required field validations
Page 103
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
API MOCKING
What is it
API mocking simulates API responses without using the actual backend service.
Key Components
• Fake responses
• Mock server
• Request simulation
• Response simulation
Practical Example
Example
Common Mistakes
✕ Using outdated mock responses
✕ Poor mock maintenance
What is it
Mocking removes dependency on real backend services.
Key Components
Page 104
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
• Independent testing
• Faster execution
• Early testing
• Failure simulation
Practical Example
Example
Common Mistakes
✕ Overusing mocks
✕ Not validating against real APIs later
What is it
A mock server simulates API endpoints and responses.
Key Components
• Fake endpoints
• Response configuration
• Request handling
• Response delay simulation
Practical Example
Page 105
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Example
GET /users
Common Mistakes
✕ Poor endpoint mapping
✕ Invalid response structures
4. Types of Mocking
What is it
Different ways to simulate APIs.
Key Components
• Static mocking
• Dynamic mocking
• Service virtualization
• Contract mocking
Practical Example
Example
Static:
Dynamic:
Common Mistakes
✕ Unrealistic mock behavior
✕ No dynamic validations
Page 106
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
5. Mocking in Postman ★
What is it
Using Postman mock servers to simulate APIs.
Key Components
• Mock collections
• Example responses
• Mock URLs
Practical Example
Example
Postman Collection
Common Mistakes
✕ Incorrect example mapping
✕ No response maintenance
What is it
WireMock is a Java-based tool used for API mocking and service virtualization.
Page 107
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Key Components
• Stub responses
• Dynamic responses
• Request matching
• Response simulation
Practical Example
Example
stubFor(get(urlEqualTo("/users"))
.willReturn(aResponse()
.withStatus(200)));
Common Mistakes
✕ Weak request matching
✕ Incorrect stub configuration
What is it
Simulating external APIs that are unstable, paid, or rate-limited.
Key Components
• Payment APIs
• External integrations
• Dependency isolation
Page 108
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Practical Example
Example
Common Mistakes
✕ Ignoring real integration testing
✕ Mock mismatch with actual APIs
What is it
Testing failure scenarios using mocked error responses.
Key Components
• 500 errors
• Timeout simulation
• Invalid responses
• Failure handling
Practical Example
Example
Simulate:
- Timeout
- Unauthorized response
Common Mistakes
✕ Only testing success responses
Page 109
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
9. Real-Time Scenarios ★
3. Performance Testing
Simulate delayed API responses
What is it
Guidelines for reliable API mocking.
Key Components
• Realistic responses
• Response maintenance
• Negative scenarios
• Reusable mocks
Practical Example
Example
Use:
- Mock servers
- Dynamic responses
Page 110
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
- Failure simulations
Common Mistakes
✕ Outdated mocks
✕ No synchronization with real APIs
✕ Ignoring negative cases
1. Mocking in Postman
2. WireMock
Page 111
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
REAL-TIME SCENARIOS
What is it
Real-time scenarios are practical business workflows automated using APIs.
Key Components
• End-to-end workflows
• Business validations
• API chaining
• Dynamic data handling
Practical Example
Example
Common Mistakes
✕ Testing isolated APIs only
✕ Ignoring business workflows
What is it
Automating user authentication APIs.
Key Components
Page 112
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
• Token generation
• Authentication
• Session handling
• Authorization validation
Practical Example
Example
Login API
Common Mistakes
✕ Hardcoded tokens
✕ Ignoring token expiration
What is it
Automating CRUD operations for user-related APIs.
Key Components
• Create user
• Fetch user
• Update user
• Delete user
Page 113
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Practical Example
Example
Create User
→ Fetch User
→ Update User
→ Delete User
Common Mistakes
✕ No cleanup handling
✕ Duplicate user creation
What is it
Automating shopping and order management workflows.
Key Components
• Product APIs
• Cart APIs
• Order APIs
• Payment APIs
Practical Example
Example
Login
→ Add Product
→ Add to Cart
→ Place Order
Page 114
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
→ Payment
Common Mistakes
✕ Weak order validations
✕ Ignoring inventory checks
What is it
Automating banking transaction APIs.
Key Components
• Account APIs
• Balance APIs
• Fund transfer APIs
• Transaction validation
Practical Example
Example
Login
→ Fetch Balance
→ Transfer Funds
→ Validate Transaction
Common Mistakes
✕ Weak security validations
✕ Ignoring transaction consistency
Page 115
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
What is it
Testing payment processing APIs and transaction handling.
Key Components
• Payment requests
• Success/failure flows
• Refund APIs
• Gateway integrations
Practical Example
Example
Initiate Payment
→ Payment Success
→ Generate Receipt
Common Mistakes
✕ No negative testing
✕ Ignoring failed transaction handling
What is it
Page 116
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Key Components
• Multipart requests
• File validation
• Upload status
• File type checks
Practical Example
Example
Upload PDF
Common Mistakes
✕ Invalid file handling
✕ No size validations
What is it
Automating OTP generation and verification APIs.
Key Components
• OTP generation
• Expiration validation
• Verification APIs
• Retry handling
Page 117
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
OTP APIs are automated to validate OTP generation, expiration handling, verification flows, and security
behavior.
Practical Example
Example
Generate OTP
→ Verify OTP
→ Login Success
Common Mistakes
✕ Ignoring OTP expiration
✕ Weak security testing
What is it
Testing APIs across distributed microservices architecture.
Key Components
• Service communication
• API dependencies
• Contract validation
• Distributed workflows
Practical Example
Example
Order Service
→ Payment Service
Page 118
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
→ Notification Service
Common Mistakes
✕ Ignoring service dependencies
✕ Weak integration validations
What is it
Testing APIs under failure and invalid conditions.
Key Components
• 400 errors
• 401 errors
• 500 errors
• Timeout handling
Practical Example
Example
Invalid Token
→ 401 Unauthorized
Common Mistakes
✕ Testing only success flows
✕ Weak negative validations
Page 119
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
What is it
Guidelines for scalable real-time API automation.
Key Components
• Dynamic data
• End-to-end validation
• Reusable workflows
• Strong assertions
Common Mistakes
✕ Hardcoded workflows
✕ Weak business validations
✕ No cleanup handling
Page 120
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Page 121
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
BEST PRACTICES
What is it
Best practices are standard guidelines used to build stable, scalable, and maintainable API automation
frameworks.
Key Components
• Reusability
• Stability
• Scalability
• Maintainability
Practical Example
Example
Reusable utilities
+ Dynamic data
+ Strong validations
Common Mistakes
✕ Hardcoded data
✕ Duplicate methods
✕ Weak validations
Page 122
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
What is it
Designing automation frameworks using reusable components.
Key Components
• Utility methods
• Base classes
• Reusable requests
• Centralized configs
Practical Example
Example
Framework
■■■ [Link]
■■■ [Link]
■■■ [Link]
Common Mistakes
✕ Duplicate code
✕ Poor folder structure
3. Strong Assertions ★
What is it
Using proper validations for APIs instead of weak checks.
Key Components
• Status validation
• Schema validation
• Response body validation
Page 123
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
• Header validation
Practical Example
Example
then()
.statusCode(200)
.body("status", equalTo("success"));
Common Mistakes
✕ Validating only status code
✕ Weak assertions
What is it
Using runtime-generated or externalized data during execution.
Key Components
• JSON files
• Dynamic emails
• Random IDs
• External datasets
Practical Example
Example
Page 124
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
const email =
`test${[Link]()}@[Link]`;
Common Mistakes
✕ Hardcoded users
✕ Duplicate test data
What is it
Performing complete response validation.
Key Components
• Status codes
• Response body
• Headers
• Response time
• Schema validation
Practical Example
Example
Validate:
- Status
- Schema
- Response time
Common Mistakes
✕ Partial validation only
✕ Ignoring headers
Page 125
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
6. Negative Testing ★
What is it
Testing APIs using invalid or failure scenarios.
Key Components
• Invalid payloads
• Unauthorized access
• Missing fields
• Failure responses
Practical Example
Example
Invalid Token
→ 401 Unauthorized
Common Mistakes
✕ Testing only happy paths
✕ Weak failure validations
7. Environment Management
What is it
Managing different execution environments.
Page 126
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Key Components
• QA
• UAT
• Staging
• Production configs
Practical Example
Example
[Link]
[Link]
Common Mistakes
✕ Hardcoded URLs
✕ Poor config management
What is it
Capturing execution logs and automation reports.
Key Components
• Logs
• Allure reports
• Execution details
• Failure analysis
Page 127
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
Practical Example
Example
Generate:
- Execution logs
- Allure reports
Common Mistakes
✕ Weak logs
✕ No failure screenshots/reports
9. CI/CD Integration
What is it
Integrating automation execution into deployment pipelines.
Key Components
• Jenkins
• Maven
• Scheduled execution
• Automated reports
Practical Example
Example
Jenkins
→ Generate Report
Common Mistakes
Page 128
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
What is it
Managing unstable APIs and retrying temporary failures.
Key Components
• Retry mechanisms
• Timeout handling
• Failure recovery
• Exception handling
Practical Example
Example
if response = 503
Common Mistakes
✕ Infinite retries
✕ Weak exception handling
Page 129
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
What is it
Removing or resetting created test data after execution.
Key Components
• Delete APIs
• Database cleanup
• Data reset
• Environment stability
Practical Example
Example
Create User
→ Execute Test
→ Delete User
Common Mistakes
✕ Leaving stale test data
✕ No cleanup automation
Page 130
API Automation Complete Guide — Interview Preparation Kalpesh Jain | @kalpeshnjain09
2. Strong Assertions
3. Negative Testing
Page 131