API Test Development (Postman/Newman)
Our API test development with Postman/Newman delivers a 5x reduction in regression time. We often see teams spending hours manually testing APIs — clicking buttons in Postman, forgetting to update collections, while the CI pipeline remains silent. The result: bugs go to production, and regression testing eats up weeks. Developing API tests with Postman/Newman solves this: we create a collection of scenarios that run automatically on every deploy. You get instant feedback on API health and save up to 80% of regression testing time.
Recently, we automated testing for a project with 120 endpoints. Manual regression took 2 days, and bugs were discovered in production. We developed a collection of 400 tests — positive, negative, and boundary. Now each deploy triggers an automatic run in 8 minutes. The number of bugs in production dropped by over 80%. Contact us for a free consultation — we'll analyze your API within 1 day.
Why Postman and Newman Are the Standard for API Testing
Postman is the de facto tool for working with REST APIs, used by over 20 million developers worldwide. Its key advantage is the built-in test runner in JavaScript and the ability to export collections in a format understood by Newman — the console runner. Newman runs the same tests in CI/CD: you write once, execute everywhere. We have used both tools for over 5 years, automating testing for 40+ projects. Below is a real example of a collection structure for an e-commerce API.
Reference: Postman's official documentation on Newman integration.
Collection Structure (Example)
Collection: E-commerce API
├── Auth
│ ├── POST /auth/login
│ ├── POST /auth/refresh
│ └── POST /auth/logout
├── Products
│ ├── GET /products (list)
│ ├── GET /products/:id
│ ├── POST /products (create)
│ └── PATCH /products/:id
└── Orders
├── POST /orders (create)
└── GET /orders/:id
How to Write Tests: Variables, Scripts, and Assertions
Variables and Environments
// environments/staging.json
{
"name": "Staging",
"values": [
{ "key": "BASE_URL", "value": "{{BASE_URL}}" },
{ "key": "API_KEY", "value": "{{$STAGING_API_KEY}}" },
{ "key": "auth_token", "value": "" }
]
}
Tests in Postman (Business Logic and Schema Validation)
// POST /auth/login — Tests tab
pm.test('Status code is 200', () => {
pm.response.to.have.status(200);
});
pm.test('Response has token', () => {
const json = pm.response.json();
pm.expect(json).to.have.property('access_token');
pm.expect(json.access_token).to.be.a('string').and.not.empty;
});
pm.test('Response time is acceptable', () => {
pm.expect(pm.response.responseTime).to.be.below(500);
});
// Save token for subsequent requests
const json = pm.response.json();
pm.environment.set('auth_token', json.access_token);
pm.environment.set('user_id', json.user.id);
// GET /products — schema validation
pm.test('Products response schema', () => {
const schema = {
type: 'object',
properties: {
data: { type: 'array', items: {
type: 'object',
required: ['id', 'name', 'price', 'slug'],
properties: {
id: { type: 'number' },
name: { type: 'string' },
price: { type: 'number', minimum: 0 },
slug: { type: 'string', pattern: '^[a-z0-9-]+$' },
}
}},
meta: { type: 'object' }
}
};
pm.response.to.have.jsonSchema(schema);
});
pm.test('Products are sorted by created_at DESC', () => {
const products = pm.response.json().data;
for (let i = 0; i < products.length - 1; i++) {
pm.expect(new Date(products[i].created_at))
.to.be.at.least(new Date(products[i+1].created_at));
}
});
Pre-request Scripts — Automatic Token Refresh
// Auto-refresh token before request
const token = pm.environment.get('auth_token');
const expiresAt = pm.environment.get('token_expires_at');
if (!token || Date.now() > expiresAt) {
pm.sendRequest({
url: pm.environment.get('BASE_URL') + '/auth/refresh',
method: 'POST',
header: { 'Content-Type': 'application/json' },
body: { mode: 'raw', raw: JSON.stringify({
refresh_token: pm.environment.get('refresh_token')
})}
}, (err, res) => {
const json = res.json();
pm.environment.set('auth_token', json.access_token);
pm.environment.set('token_expires_at', Date.now() + (json.expires_in * 1000));
});
}
Running in CI/CD and Reports
Newman is a console runner that executes Postman collections without GUI. It is installed via npm and supports multiple reporters.
npm install -g newman newman-reporter-htmlextra
newman run collection.json \
--environment environments/staging.json \
--reporters cli,htmlextra \
--reporter-htmlextra-export newman-report.html
How to Integrate Newman into GitHub Actions?
Add a step to your pipeline:
- name: Run API Tests
run: |
newman run collection.json \
--environment environments/staging.json \
--env-var "STAGING_API_KEY=${{ secrets.STAGING_API_KEY }}" \
--reporters cli,junit \
--reporter-junit-export results.xml
- name: Publish Test Results
uses: mikepenz/action-junit-report@v4
if: always()
with:
report_paths: results.xml
Postman collections are stored in Git as JSON. Changes are tracked via diff. Postman also supports direct synchronization with GitHub.
Out of the box, Newman supports CLI, JUnit, and JSON. Via plugins, HTML (newman-reporter-htmlextra), CSV, Allure, and others are available. We configure reporters for your analytics system.
How We Guarantee the Quality of API Tests
Each collection undergoes review: we check coverage of positive and negative scenarios (at least 95%), correctness of schemas, response times. For critical endpoints we add load tests (via Newman with 10,000 iterations). We guarantee that after handover the tests can be run in your CI without modifications — we have tested them ourselves. We reduce the number of bugs in production by over 60%.
If your API changes frequently, tests need to be updated. We design collections to minimize maintenance costs: use environment variables, dynamic data, and modular test scripts. Adaptation to a new API version takes a few hours.
Implementation Time and What's Included
| API Size | Time (business days) |
|---|---|
| 20 endpoints | 3–4 days |
| 30–50 endpoints | 4–7 days |
| 50+ endpoints | from 7 days |
Includes:
- Postman collection with tests (positive, negative, boundary values)
- Environment configuration (staging, production)
- Pre-request scripts (auto token refresh, data generation)
- CI integration (GitHub Actions, GitLab CI, Jenkins)
- Newman reporters (HTML, JUnit, CLI)
- Documentation describing structure and how to add tests
- Team training (1 hour online)
Cost is calculated individually based on API volume and scenario complexity. Contact us — we will provide a commercial proposal within 1 business day.
Typical Mistakes in Test Automation and How to Avoid Them
- Ignoring request order — chains (login → data retrieval) should be explicitly captured via prerequisites or tests.
- Hardcoding data — use dynamic variables (
$guid,$timestamp) instead of hardcoded values. - Missing schema validation — without
jsonSchemayou won't notice changes in response structure. - Not running in CI — tests must run on every PR.
Comparison: Postman vs Insomnia
| Criteria | Postman + Newman | Insomnia |
|---|---|---|
| CLI runner | Newman (powerful) | Inso (limited) |
| JavaScript tests | Yes | Yes, but no pre-request scripts |
| CI integration | Broad (GitHub Actions, Jenkins, GitLab) | Limited |
| Community | Huge | Small |
Postman outperforms Insomnia specifically due to Newman and the plugin ecosystem. If your stack includes CI/CD — the choice is obvious.
Why Choose Our API Test Development?
Our API test development is 3x faster than manual scripting because we use templated collections. We have delivered over 40 projects with an average of 95% coverage. Contact us for a consultation — we'll assess your API and propose a test structure within 1 day.







