This tool allows you to retrieve all your Postman collections and environments using the Postman API.
- Node.js (v14 or later recommended)
- A Postman API key with read access to your collections and environments
-
Install dependencies:
npm install -
OPTIONAL: Set your Postman API key as an environment variable:
export POSTMAN_API_KEY="your-api-key-here"If no POSTMAN_API_KEY environment variable is defined, the export script will give you an opportunity to enter it.
The easiest way to use this tool is with the interactive shell script:
./export-content/run-export.sh
This script will:
- Check if you have Node.js installed
- Prompt you to set your Postman API key if not already set
- Let you choose which export operation to perform
- Allow you to specify a custom output directory
- Run the appropriate export script
You can also just run with Node, specifying a custom output directory:
node export-content/get-collections.js [output-directory] [--consolidated]
node export-content/get-environments.js [output-directory]
node export-content/export-all.js [output-directory] [--consolidated]
node export-content/export-consolidated.js [output-directory]
Options:
--consolidated: Export collections as a single consolidated file instead of individual files- For
get-collections.js: Saves all collections to a single JSON file namedall-collections.json - For
export-all.js: Saves all collections to a single file while still exporting environments as individual files
- For
Example with custom output directory:
node export-content/get-collections.js ./my-custom-path
node export-content/get-collections.js ./my-custom-path --consolidated
node export-content/export-all.js ./my-custom-path --consolidated
node export-content/export-consolidated.js ./exports/postman
If no output directory is specified, the scripts will use these defaults:
export-content/get-collections.js:./postman-export/collectionsexport-content/get-environments.js:./postman-export/environmentsexport-all.js:./postman-export(with subdirectories for collections and environments)export-consolidated.js:./postman-export(with the consolidated file)
When specifying a custom output directory:
get-collections.jswill create acollectionssubdirectory in your specified pathget-environments.jswill create anenvironmentssubdirectory in your specified pathexport-all.jswill create both subdirectories in your specified pathexport-consolidated.jswill create a single JSON file in your specified path
The scripts will create the following directories and files:
-
postman-export/collections/: Contains all your Postman collectionscollections-metadata.json: A summary of all your collections- Individual JSON files for each collection, named after the collection (in default mode)
consolidated-collections.json: A single file containing all collections (when using --consolidated flag)
-
postman-export/environments/: Contains all your Postman environmentsenvironments-metadata.json: A summary of all your environments- Individual JSON files for each environment, named after the environment
-
postman-export/: Contains consolidated export filespostman-export.json: A single JSON file containing all collections and environments in the structure:{ "collections": [ // Collection objects ], "environments": [ // Environment objects ] }
If you specify a custom output directory, the files will be created in that location instead.
- Log in to your Postman account
- Go to your API Keys page
- Create a new API key with appropriate scopes (at minimum, you need read access to collections and environments)
- Copy the generated key and use it in this script
- If you encounter permission issues, make sure your API key has the correct scopes
- If you get rate limit errors, the script may need to be modified to include pagination or delays