✅ 1. What is API Testing?
It checks:
-
Functionality
-
Data accuracy
-
HTTP status codes
-
Response format (JSON, XML)
-
Security (authentication, authorization)
-
Error handling
✅ 2. What is an API?
✅ 3. Why is API Testing important?
-
APIs are the backbone of most apps.
-
It can find issues early in the development cycle.
-
It is faster and more stable than UI testing.
-
It validates core business logic without relying on the user interface.
-
Helps in testing multiple clients (mobile, web, desktop) with one backend.
✅ 4. What tools are commonly used for API Testing?
-
Postman – Easy GUI for sending API requests.
-
REST Assured – Java library for REST API automation.
-
SoapUI – Used for SOAP and REST services.
-
Karate – BDD testing tool for APIs.
-
JMeter – Used for API load/performance testing.
-
Swagger – API documentation and testing.
✅ 5. What is the difference between SOAP and REST APIs?
Answer:
| Feature | SOAP | REST |
|---|---|---|
| Protocol | Uses XML and WSDL | Uses HTTP/HTTPS |
| Format | XML only | JSON, XML, HTML, Plain Text |
| Flexibility | Rigid | Flexible and lightweight |
| Speed | Slower | Faster |
| Usage | Legacy systems | Modern web/mobile apps |
✅ 6. What are HTTP methods used in API Testing?
Answer:
-
GET – Read data
-
POST – Create data
-
PUT – Update entire record
-
PATCH – Update partial data
-
DELETE – Remove data
Example:
POST /loginGET /usersDELETE /users/5
✅ 7. What are common HTTP status codes in API responses?
Answer:
| Code | Meaning |
|---|---|
| 200 | OK – Request successful |
| 201 | Created – Resource created |
| 400 | Bad Request – Invalid input |
| 401 | Unauthorized – Login required |
| 403 | Forbidden – Access denied |
| 404 | Not Found – Resource missing |
| 500 | Internal Server Error – Server bug |
✅ 8. What is a Request and Response in API Testing?
Answer:
-
Request: Sent by the client to the server with method, headers, and body (data).
-
Response: Sent by the server with status code, headers, and body (output data).
Example Request (JSON):
{"username": "testuser","password": "123456"}
Example Response (JSON):
{"message": "Login successful","token": "abc123xyz"}
✅ 9. What is Postman?
-
Send API requests
-
View responses
-
Test with different data
-
Write scripts using JavaScript
-
Generate test reports
-
Automate tests using Postman Collection Runner
Postman is beginner-friendly and widely used in manual API testing.
✅ 10. What is REST Assured?
Example:
given().baseUri("https://api.example.com").when().get("/users").then().statusCode(200).body("name", hasItem("John"));
It can be integrated with TestNG, Maven, Jenkins, and supports JSON/XML parsing, headers, and authentication testing.
✅ 11. What is JSON and how is it used in API Testing?
Example:
{"name": "John","age": 30}
In API testing, JSON is commonly used in:
-
Request bodies (for sending data)
-
Response bodies (for receiving data)
Testers validate keys, values, and structure in JSON during testing.
✅ 12. What is XML in API Testing?
Example:
<user><name>John</name><age>30</age></user>
Though JSON is more common today, some legacy systems still use XML. Testers verify tag structure, values, and hierarchy in XML responses.
✅ 13. What is a RESTful API?
REST APIs:
-
Use URIs to access resources
-
Return JSON or XML
-
Are scalable and easy to use
-
Don’t store any session state on the server
✅ 14. What is a base URI and endpoint in API?
Answer:
-
Base URI is the root address of the API, e.g.,
https://api.example.com -
Endpoint is the path to a specific resource, e.g.,
/users/123
✅ 15. What is authentication in API Testing?
-
Basic Auth (username & password)
-
Bearer Token (JWT tokens)
-
OAuth 2.0 (used in secure applications like Google login)
Testers check if:
-
Only valid users can access endpoints
-
Unauthorized users get 401 or 403 errors
✅ 16. What is authorization in API Testing?
For example:
-
An admin may access
/users -
A regular user may only access
/profile
Testers validate role-based access control (RBAC) by using different users to test restricted resources.
✅ 17. What is a header in an API request?
-
Content-Type: application/json -
Authorization: Bearer token -
Accept: application/xml
Headers are crucial for specifying data format and authentication.
✅ 18. What is a payload or request body?
POST, PUT, or PATCH request.Example (JSON payload):
{"username": "john","password": "pass123"}
Testers validate structure, mandatory fields, and format of the payload.
✅ 19. How do you validate response time in API Testing?
-
Check it manually from the test result panel
-
Write assertions like:
.then().time(lessThan(2000L)); // less than 2 seconds
Performance SLAs usually define expected response times.
✅ 20. How do you validate a JSON response in Postman?
Example:
pm.test("Status code is 200", function () {pm.response.to.have.status(200);});pm.test("Name is John", function () {var jsonData = pm.response.json();pm.expect(jsonData.name).to.eql("John");});
These scripts validate status codes and specific values in the response.
✅ 21. What is a collection in Postman?
Benefits:
-
Run entire test suites using Collection Runner
-
Share collections with team members
-
Attach environment variables and scripts
✅ 22. What is an environment in Postman?
Example:
base_url = https://api.test.comtoken = abc123
This makes switching between development, staging, and production environments easier.
✅ 23. How do you use variables in Postman?
{{base_url}}/users
Variables can be used for:
-
URLs
-
Headers
-
Body data
They are defined in the environment settings or globally.
✅ 24. What is a test script in Postman?
Example:
pm.test("Token is present", function () {var json = pm.response.json();pm.expect(json.token).to.not.be.null;});
Used for assertions like checking status codes, headers, or body values.
✅ 25. What is a Pre-request Script in Postman?
-
Generating timestamps
-
Setting dynamic tokens
-
Updating variables
Example:
pm.environment.set("currentTime", new Date().toISOString());
✅ 26. What is chaining requests in Postman?
Example:
-
Send login request and capture token
-
Use that token in the next request's header
Postman allows storing token in environment variable like:
pm.environment.set("authToken", json.token);
✅ 27. What is status code 201 in API Testing?
Example:
-
POST /usersreturns 201 if a new user is added -
Useful for validating successful creation of data
✅ 28. What is status code 400 in API Testing?
Example:
-
Sending invalid JSON
-
Missing required fields
Testers check if APIs correctly return 400 when given bad inputs.
✅ 29. What is status code 401 in API Testing?
Example:
-
Missing or invalid token
-
Expired credentials
APIs must return 401 when a user tries to access without logging in.
✅ 30. What is status code 403 in API Testing?
Example:
-
A normal user accessing an admin-only endpoint
This validates proper role-based access control.
✅ 31. What is status code 404 in API Testing?
Example:
-
Accessing
/users/9999where user ID 9999 doesn't exist
It helps in validating resource availability and proper error handling.
✅ 32. What is status code 500 in API Testing?
Common causes:
-
Null pointer exception
-
Unhandled error in backend logic
Testers must report 500 errors immediately as they indicate poor error handling.
✅ 33. What is status code 204 in API Testing?
Example:
-
A successful DELETE request might return 204
It's useful when no further information is needed in response.
✅ 34. What is status code 202 in API Testing?
Used in asynchronous operations where the result may come later.
✅ 35. How do you handle authentication tokens in Postman?
var json = pm.response.json();pm.environment.set("token", json.token);
Then, use {{token}} in the Authorization header:
Bearer {{token}}
✅ 36. What is a mock server in API Testing?
Useful for:
-
Frontend testing before backend is ready
-
Testing edge cases
Tools like Postman or Swagger allow mock server setup.
✅ 37. What is response schema validation?
Example:
-
Field names, types, required fields
In Postman:
pm.test("Schema is valid", function () {pm.response.to.have.jsonSchema(schema);});
✅ 38. What is data-driven testing in API Testing?
In Postman:
-
Use Collection Runner and import CSV/JSON files
Each iteration picks a new row of data and tests the same endpoint with different inputs.
✅ 39. What is the use of assertions in API Testing?
Examples:
-
Status code is 200
-
Response body has a field
-
Value matches expectation
They are essential for automation and validation.
✅ 40. How do you test negative scenarios in API Testing?
-
Sending invalid inputs
-
Missing required fields
-
Using expired or missing tokens
-
Trying unauthorized access
Helps ensure the API handles errors gracefully and returns proper status codes like 400, 401, 403.
✅ 41. What is an API contract?
-
Input parameters
-
Expected output
-
Data formats (JSON, XML)
-
Authentication methods
-
Status codes
Tools like Swagger/OpenAPI document the API contract. It ensures consistency and proper expectations across teams.
✅ 42. What is Swagger?
It provides:
-
Interactive API documentation
-
Mock server support
-
Auto-generated client/server code
Swagger UI lets testers try endpoints directly from the browser.
✅ 43. What is OpenAPI Specification (OAS)?
Swagger is based on OpenAPI Specification. It describes:
-
Paths and methods
-
Request/response structures
-
Security schemes
Helps in automation, documentation, and mock testing.
✅ 44. What is SOAPUI used for?
-
Functional testing
-
Security testing
-
Load testing
-
Assertions
It supports both manual and automated tests and works well with XML-based APIs.
✅ 45. What is a test suite in API Testing?
For example, a Login Test Suite might include:
-
Valid login
-
Invalid login
-
Login without password
-
Login with expired credentials
Used to validate one full feature/module end-to-end.
✅ 46. What is API rate limiting?
Example:
-
100 requests per minute
It's used to:
-
Prevent abuse
-
Protect server performance
Testers validate rate limits and expected error messages (like HTTP 429).
✅ 47. What is throttling in API?
It helps manage load and ensures fair use. When a limit is exceeded, APIs may return:
-
429 Too Many Requests
-
Retry-After headers
✅ 48. How do you perform API security testing?
-
Only accept authorized requests
-
Reject invalid tokens
-
Sanitize inputs (to prevent injection)
-
Don’t expose sensitive data (e.g., passwords)
Test scenarios include:
-
Token tampering
-
Role-based access control
-
HTTPS validation
✅ 49. What is fuzz testing in APIs?
-
Crashes
-
Server errors
-
Unexpected behavior
It’s useful in identifying security vulnerabilities or input validation gaps.
✅ 50. What is API versioning?
Types:
-
URL-based:
/v1/users -
Header-based:
Accept: application/vnd.api+json;version=2.0
Testers validate correct responses for each version.
✅ 51. What is OAuth 2.0?
It uses:
-
Access Tokens
-
Refresh Tokens
-
Authorization Code flows
Testers verify:
-
Token issuance
-
Expiry handling
-
Token reuse
✅ 52. What is JWT in API Testing?
Structure:
-
Header
-
Payload (user data)
-
Signature
Testers ensure:
-
Tokens are encrypted and valid
-
Expired/invalid tokens are rejected
✅ 53. What is Bearer Token Authentication?
Authorization header:Authorization: Bearer eyJhbGciOiJIUzI1...
API validates this token to allow access. Testers must ensure:
-
Only valid tokens allow access
-
Invalid/missing tokens return 401
✅ 54. What is HATEOAS in REST API?
Example:
{"userId": 123,"links": [{"rel": "update", "href": "/users/123/edit"}]}
It guides clients on what actions are possible next.
✅ 55. What is idempotency in API?
Examples:
-
GET: Safe, always idempotent
-
PUT: Should update resource, not duplicate it
Testers validate that repeated calls do not create duplicates or alter data incorrectly.
✅ 56. What are some common API testing challenges?
Answer:
-
Lack of documentation
-
Dynamic data and tokens
-
Authorization complexity
-
Schema changes
-
API dependencies
Testers must adapt by using automation, mocking, and strong assertions.
✅ 57. What is the difference between manual and automated API Testing?
Answer:
| Manual API Testing | Automated API Testing |
|---|---|
| Done via Postman, Curl | Done via tools like Rest Assured, SoapUI |
| Time-consuming | Faster & repeatable |
| Good for ad hoc testing | Best for regression suites |
Use both together for better coverage.
✅ 58. What is dynamic payload testing?
Example in Postman:
{"username": "{{user}}","email": "{{email}}"}
This allows data-driven testing and easy test maintenance.
✅ 59. How do you handle dynamic values in API Testing?
-
Capture dynamic values (like userId, token) from responses
-
Store them in variables
-
Reuse them in future requests
Postman example:
var id = pm.response.json().id;pm.environment.set("userId", id);
✅ 60. What is an API Gateway?
It handles:
-
Routing
-
Authentication
-
Rate limiting
-
Logging
Examples: AWS API Gateway, Apigee. Testers ensure APIs behind gateway are secure and functional.
✅ 61. What is a REST client?
Examples:
-
Postman
-
Insomnia
-
CURL
-
Advanced REST Client (ARC)
Used by testers and developers for manual testing.
✅ 62. What is CURL in API Testing?
Example:
curl -X GET "https://api.example.com/users"
It’s lightweight, scriptable, and useful for quick testing.
✅ 63. What are the components of an API request?
Answer:
-
Endpoint/URL
-
HTTP Method (GET, POST, etc.)
-
Headers
-
Body/Payload (for POST/PUT)
-
Authentication info
All parts are validated during API testing.
✅ 64. What is the difference between PUT and PATCH?
Answer:
| PUT | PATCH |
|---|---|
| Replaces entire resource | Updates only specified fields |
| More strict | More flexible |
Testers check which method is used and validate behavior.
✅ 65. How do you validate API response headers?
-
Postman test scripts:
pm.test("Check content-type", function () {pm.response.to.have.header("Content-Type");});
-
REST Assured:
.then().header("Content-Type", equalTo("application/json"))
✅ 66. What is boundary testing in API?
-
Max/min field values
-
Field length constraints
Example:
-
Username should not exceed 20 characters
-
Age cannot be negative
Used to uncover input validation bugs.
✅ 67. How do you test file uploads via API?
In Postman:
-
Use
Body > form-data -
Add
type: File
Testers verify:
-
File size limits
-
File format
-
Upload status
✅ 68. How do you test API timeouts?
-
Mock servers
-
Sleep delays on server side
Expected behavior:
-
Client retries or fails gracefully
-
Timeout error is handled properly
✅ 69. What is latency in API Testing?
High latency can affect user experience. Testers:
-
Measure latency (in ms)
-
Ensure APIs meet performance SLAs
✅ 70. What is JSONPath?
Example:
{"user": { "name": "Alice", "id": 1 }}
JSONPath: $..name → returns "Alice"
Used in tools like Postman and REST Assured for value extraction.
✅ 71. What is XMLPath?
Example:
<user><name>Alice</name></user>
XPath: /user/name → returns Alice
Useful in SOAP or XML-based API testing.
✅ 72. What are some best practices in API Testing?
Answer:
-
Start early in development cycle
-
Use consistent naming and formatting
-
Validate status codes, headers, and body
-
Test both positive and negative cases
-
Automate tests where possible
✅ 73. What is a REST resource?
Examples:
-
/users– collection of users -
/users/5– single user with ID 5
REST treats everything as a resource accessed via HTTP methods.
✅ 74. What is an integration test in API Testing?
Example:
-
Login → Get Token → Access Profile → Update Profile
These tests ensure end-to-end flow across modules works correctly.
✅ 75. What is API virtualization?
Used to:
-
Test in parallel with development
-
Mimic error conditions
-
Reduce dependency on 3rd-party APIs
Tools: WireMock, MockServer, Postman Mock Servers
✅ 76. What is a schema in API Testing?
Testers validate:
-
All required fields exist
-
Data types are correct
-
No extra fields are present
✅ 77. What is a contract test?
-
The provider’s API meets the consumer’s expectations
-
No breaking changes are introduced
It compares actual API behavior with the documented contract (like Swagger).
✅ 78. What are soft and hard assertions in API Testing?
Answer:
-
Hard Assertion: Stops test if it fails
-
Soft Assertion: Collects all failures, reports at end
Soft assertions are better in automation frameworks for complete reports.
✅ 79. What is a dry run in API Testing?
Used for:
-
Checking scripts
-
Validating request format
-
Pre-production testing
No data is created or updated.
✅ 80. What is the difference between endpoint testing and integration testing?
Answer:
| Endpoint Testing | Integration Testing |
|---|---|
| Tests one endpoint at a time | Tests multiple connected endpoints |
| Focus on isolated behavior | Focus on end-to-end flow |
| Easy to write | More complex setup |
Both are essential for full coverage.
✅ 81. What is schema validation in API Testing?
For JSON:
-
Use JSON Schema
-
Ensures correct field names, data types, required properties
In Postman:
pm.test("Validate schema", function () {var schema = { ... };pm.response.to.have.jsonSchema(schema);});
This avoids issues caused by invalid data structures.
✅ 82. What is negative testing in API Testing?
Examples:
-
Invalid username/password
-
Missing headers
-
Invalid HTTP method
-
Oversized payload
Expected results: proper error codes (e.g., 400, 401) and messages.
✅ 83. How do you test API error responses?
-
Check correct error code (e.g., 404, 401, 500)
-
Validate error message structure
-
Ensure no sensitive information is exposed
Helps improve robustness and user experience.
✅ 84. What are mock APIs?
They are used:
-
During early development
-
For parallel QA/testing
-
To simulate error or boundary cases
Tools: Postman Mock Server, WireMock, Beeceptor.
✅ 85. What is contract-first API development?
Benefits:
-
Clear expectations for frontend/backend
-
Testers can write tests early
-
Avoids integration issues
✅ 86. What is the difference between 401 and 403 status codes?
Answer:
| Status Code | Meaning | When It Happens |
|---|---|---|
| 401 | Unauthorized | Token is missing/invalid |
| 403 | Forbidden | Token is valid, but access is denied |
Both are security-related and must be tested separately.
✅ 87. What is the difference between 500 and 502 errors?
Answer:
| Error Code | Meaning | Cause |
|---|---|---|
| 500 | Internal Server Error | Application crash or bug |
| 502 | Bad Gateway | Upstream server failed |
Testing involves simulating backend failure or misconfiguration.
✅ 88. How do you handle dynamic tokens in automated API tests?
-
Login API to get token
-
Store token in environment variable
-
Use token in headers of next requests
Example in Postman:
pm.environment.set("token", pm.response.json().token);
✅ 89. How to use Postman pre-request scripts?
Used to:
-
Set dynamic values (timestamps, tokens)
-
Chain requests
-
Generate random data
Example:
pm.environment.set("timestamp", new Date().toISOString());
✅ 90. How to use Postman test scripts?
-
Assertions
-
Saving values from response
-
Logging or debugging
Example:
pm.test("Status code is 200", function () {pm.response.to.have.status(200);});
✅ 91. What is chaining in API testing?
Example:
-
Create User → Get User ID → Get Profile using ID
Postman allows chaining using environment variables.
✅ 92. How do you ensure backward compatibility of an API?
Test strategies:
-
Test old requests on new version
-
Validate old response formats
-
Run regression suite
Avoid breaking changes like renaming fields or removing endpoints.
✅ 93. How do you test pagination in an API?
Steps:
-
Use
?page=1,?limit=10, etc. -
Validate total records
-
Ensure next/previous pages return correct data
Helps reduce response size and load.
✅ 94. How do you test sorting and filtering in APIs?
-
Sorting:
?sort=name_asc -
Filtering:
?status=active
Validate:
-
Response is sorted correctly
-
Only relevant records are returned
-
Edge cases (e.g., no results)
✅ 95. How do you perform API load testing?
Tools:
-
JMeter
-
K6
-
Gatling
Testers simulate hundreds/thousands of requests and monitor:
-
Response time
-
Errors
-
CPU/memory usage
✅ 96. What is the use of environment variables in Postman?
-
Base URL
-
Tokens
-
User credentials
Example:
{{baseUrl}}/users → resolves to https://api.example.com/users
Helps in switching between dev, QA, and production environments.
✅ 97. What is token expiration testing?
Steps:
-
Use expired token
-
Check if API returns 401 or appropriate error
-
Test token refresh (if supported)
Ensures secure and predictable authentication behavior.
✅ 98. What is the difference between functional and non-functional API testing?
Answer:
| Functional Testing | Non-Functional Testing |
|---|---|
| Tests correctness of responses | Tests performance, security, usability |
| Examples: status code, body check | Examples: load test, timeout, SSL |
Both are critical for high-quality APIs.
✅ 99. What is an API collection in Postman?
Used for:
-
Organizing test cases
-
Sharing with team
-
Running as test suite with Collection Runner
Can include tests, scripts, and variables.
✅ 100. How do you integrate API tests into CI/CD pipelines?
-
Write tests in Postman, REST Assured, etc.
-
Export or run them via command line (e.g., Newman for Postman)
-
Add to Jenkins, GitHub Actions, or GitLab CI
Automates API validation on every code change.