🚀 Why API Testing Matters
API testing is a must-have skill for modern QA professionals. It helps you test the logic and functionality behind the user interface — often before the UI is even built.
Postman is one of the easiest tools to start with. Whether you’re a manual tester or learning automation, Postman helps you send requests, validate responses, and even write test scripts — all without needing to write full code.
🔧 What Is Postman?
Postman is a free API client that lets you:
- Send requests to REST APIs
- Inspect responses (status, body, headers)
- Write basic tests using JavaScript
- Group requests into collections and environments
✅ Step-by-Step: Writing Your First API Test in Postman
Let’s go through an example using a public API:
🔗 https://jsonplaceholder.typicode.com
Step 1: Set Up Postman
- Download Postman from postman.com
- Open the app and create a free account
Step 2: Make a Simple GET Request
Let’s get a list of fake posts from JSONPlaceholder:
URL:
arduinoCopyEdithttps://jsonplaceholder.typicode.com/posts
Method:GET
Click Send — you’ll see a JSON response containing posts.
Step 3: Write a Test to Validate the Response
Scroll down to the Tests tab and paste this code:
javascriptCopyEditpm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
pm.test("Response has at least one post", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.length).to.be.above(0);
});
🔍 What this does:
- Asserts that the status code is
200 - Checks that the response contains at least one post
Step 4: Test a POST Request
Let’s send a POST request to create a new post.
URL:
arduinoCopyEdithttps://jsonplaceholder.typicode.com/posts
Method:POST
Body → raw → JSON:
jsonCopyEdit{
"title": "QA Playbook",
"body": "Learning API testing with Postman",
"userId": 1
}
Tests Tab:
javascriptCopyEditpm.test("Status code is 201", function () {
pm.response.to.have.status(201);
});
pm.test("Post contains correct title", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.title).to.eql("QA Playbook");
});
✅ This validates the response from a simulated post creation.
🧪 More Test Snippets for Beginners
✅ Check Response Time
javascriptCopyEditpm.test("Response time is less than 500ms", function () {
pm.expect(pm.response.responseTime).to.be.below(500);
});
✅ Check Content Type Header
javascriptCopyEditpm.test("Content-Type is application/json", function () {
pm.response.to.have.header("Content-Type");
});
✅ Validate a Property in the Response
javascriptCopyEditpm.test("User ID is 1", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.userId).to.eql(1);
});
💡 Bonus Tips
- Use Environment Variables for dynamic data (e.g.,
{{base_url}}) - Save your requests to Collections to reuse them
- Export your tests and share with your team
- Integrate with Newman CLI to run Postman tests from the command line
📁 Common Use Cases for Postman in QA
| Use Case | Postman Feature |
|---|---|
| Validate API response format | Tests with pm.response.json() |
| Check auth/login APIs | Use Authorization tab |
| Automate test runs | Use Newman CLI + scripts |
| Mock APIs for frontend devs | Postman’s Mock Server feature |
🎯 Final Thoughts
API testing doesn’t have to be overwhelming. Postman makes it simple to:
- Explore and understand how APIs work
- Validate backend logic without waiting for the UI
- Build confidence in testing more than just interfaces