Postman is one of the most popular tools used in API development and testing. It offers an easy way to send, receive and manipulate API requests. Nowadays, Postman is used by more than 11 million developers and 500,000 companies, including big names like Shopify and Microsoft.
Postman Collections are a group of saved requests that are related in some way. This is a more organized way to reuse requests than digging through Postman History tab.
Newman is a CLI (command line interface) program that allows you to run Postman Collections directly from the command line. This is great news for anyone who are searching for a way to execute automated tests in a CI/CD pipeline.
In this article, we will show you how to install Newman on Ubuntu. The guide is applicable to older versions of Ubuntu and many as well as Linux distros based on Debian, such as Linux Mint or Pop! OS.
Update the system
Before installing any new package or application, it is recommended that you update your system, GNOME Deksktop is no exception. To do this, run the commands below which invoke
apt package manager to fetch a fresh package list from Ubuntu repository.
sudo apt update
Newman is built on Node.js. In order to run Newman, you have to install Node.js first. There are several ways that you can do so :
- From the official Ubuntu repositories. This is by far the easiest way to install Node.js and npm on Ubuntu.
- From the NodeSource repository. Currently, NodeSource supports Node.js
nvm(Node Version Manager). This tool allows you to have multiple Node.js versions installed on the same machine.
At the time of writing, the Node.js version included in the Ubuntu 20.04 repositories is
10.19.0 which is the previous TLS version.
Run the following commands to update the package index and install Node.js and npm:
sudo apt update sudo apt install nodejs npm -y
Once the installation completes, you can verify the newly installed package by running:
After you install Node.js, Newman is just a command away. Run the following command to install Newman from npm globally on your system:
npm install -g newman
If you want to install it locally, remove the
-g flag in the command.
Run Postman collection with newman
In order to run the
newman commands, you must export a Postman collection first. In order to do so, click the “three-dots” icon next to the collection name and select Export.
Suppose the exported collection is named
sample-collection.json, you can run it with the syntax below.
newman run examples/sample-collection.json
Newman also supports adding flags to enable advanced features, such as run with a custom environment or run collection multiple times. The full list option is available in Newman Github repository.
We hope that the information above helped you successfully install Newman on your Ubuntu system. You may be interested in our other Linux software roundups, including 8 Best Open Source CMDB software, Best Linux Video Converters or Best Python Graphics Libraries. If you have any suggestion, please feel free to leave a comment below.