How to Save Get response to local file?

Archived topic — this may be out of date.
Newman has been replaced by the Postman CLI, Postman’s official, signed command-line tool. It runs collections as Newman did, and also lints API specs, runs mocks and monitors, and syncs local files with Postman from your terminal, CI/CD pipeline or coding agent.
Working with an AI coding agent? The Postman plugin lets agents in Claude Code, Cursor, Codex and others design, mock, test and ship APIs with Postman.
For current help, see the Postman docs, try the free Postman tools (no account needed), or join us on Discord.

I have Get request without Body. How to save response (json) to a local file using newman?

Hey @bukhari.adac

This is a very common question and doing a quick search in the forum would have returned a few different ways of writing those to file. :grin:

Using Newman as a library and paring that with the Node fs module you can save the responses to a file like this:

const newman = require('newman'),
      fs = require('fs');

newman.run({
  collection: '<Postman Collection>'
}).on('request', (err, args) => {
  fs.writeFile(`./results/${args.item.name}.json`, args.response.stream, (err) => {
    if (err) { 
        console.error(err); 
    }
  });
})

Thank you @danny-dainton for your help.