Export Postman collections via CLI.
Reason this release was yanked:
This release has not updated github workflow files for testing and publishing to GitHub and PyPI. Other code is still the same as the code in version 0.0.8
Project description
Postman Collection Exporter
Export your Postman collections via a simple CLI
Table of Content
- โจ Features
- ๐ Usage
- โ๏ธ Requirements
- ๐ Environment Variables
- ๐ ๏ธ Project Structure
- ๐งน TODO
- ๐ License
- ๐ค Authors
Features
- Export Multiple Collections: Export several Postman collections simultaneously with just a few commands.
- Archive Collections in Known Formats: Archive exported Postman collections to formats like
tar,zip,gztar,bztar, andxztar. - Asynchronous API Interaction: Leverages
asyncio,httpx, andaiofilesfor efficient, non-blocking communication with the Postman API. - Save Collections in JSON Format: Save Postman collections locally in a clean, standardized JSON format.
- CLI Built with asyncclick Library: A powerful and user-friendly command-line interface, built with
asyncclickto handle async operations gracefully. - Error Handling: Gracefully handles errors from the Postman API, ensuring that authentication issues or rate limits are reported clearly.
- Modular and Extendable: The app's modular structure makes it easy to add new features or adjust behavior as needed.
- Crontab Scheduling (Unix-based Systems): Automate exporting or archiving actions using crontab. This feature is only available on Unix-based systems and requires an additional dependency.
- Logging: Logs CLI command results and errors to a user-specified log file (via the
--log-pathoption).
Usage
Installation
$ pip install postman_collection_exporter
# or if you intended to use scheduling
$ pip install "postman_collection_exporter[schedule]"
# or install needed package later via
$ pip install python-crontab
Export Collections
# Using Python module
$ python -m postman_collection_exporter.cli export --path /home/user/exports -n Collection1 -n Collection2 --api-key postman-api-key
# Using directly (--api-key is optional if POSTMAN_API_KEY is set)
$ export-collections --path /home/user/exports -n Collection1 -n Collection2 --api-key postman-api-key
-p, --path-to-collections: Directory, where exported collections will be located.-n, --collection-names: Names of the Postman collections to be export.-k, --api-key: Optional Postman API key for authentication. Overrides environment variable.-l, --log-path: Path to the log file for the command output. [default: /home/username/crontab/cron.log]
Archive collections
# Using Python module
$ python -m postman_collection_exporter.cli archive --path-to-collections /home/user/exports --path-to-archive /home/user/archives -n My_Collections --archive-type tar
# Using directly (--api-key is optional if POSTMAN_API_KEY is set)
$ archive-collections --path-to-collections /home/user/exports --path-to-archive /home/user/archives -n My_Collections --archive-type tar
-c, --path-to-collections: Path to directory with collections being archived.-a, --path-to-archive: Path to directory with an archive being created.-n, --name: Name of the archive being created.--archive-type: Type of an archive being created. [default:zip]-l, --log-path: Path to the log file for the command output. [default: /home/username/crontab/cron.log]
# Using Python module
$ python -m postman_collection_exporter.cli set-schedule --action export --pattern "1 * * * *" --comment "Export Postman collections every hour."
# Using directly
$ set-schedule --action export --pattern "1 * * * *" --comment "Export Postman collections every hour."
-a, --action: Choose the Postman action to schedule. (export or archive at this time) [required]-p, --pattern: Crontab pattern (e.g., "0 0 * * *" for daily at midnight). Must be written within quotes! [required]-c, --comment: Comment added to the crontab entry (displayed next to the pattern) [required]-u, --user: Username for the target crontab (default: current user). Assigning dynamically.--dry-run: Show the crontab entry that would be created, without applying it.
Requirements
- Python 3.11+
Environment Variables
Set the Postman API key as an environment variable (optional):
$ export POSTMAN_API_KEY=<actual_api_key>
The script will fail gracefully if no API key is found.
Note:
Exporting POSTMAN_API_KEY will have an effect only with manual exporting collection(s). In order to schedule exporting collections it's necessary to pass API key via api-key option like below:
$ set-schedule --action export --comment "comment" --pattern "* * * * *"
Please, fill out params to schedule for the <export> command. Continue? [Y/n]:
==> path (required): path
==> collection-names (required): name
Any other value for 'collection-names'? [y/N]: N
==> api-key []: # pass here your API-key (it will be hidden)
# other prompts
Project Structure
.
โโโ LICENSE
โโโ pyproject.toml
โโโ README.md
โโโ requirements.txt
โโโ src
โ โโโ postman_collection_exporter
โ โโโ cli.py
โ โโโ dependencies
โ โ โโโ __init__.py
โ โ โโโ utils.py
โ โโโ enums.py
โ โโโ exceptions.py
โ โโโ exporters.py
โ โโโ helpers.py
โ โโโ __init__.py
โ โโโ logging
โ โ โโโ config.py
โ โ โโโ __init__.py
โ โโโ scheduling
โ โ โโโ cli.py
โ โ โโโ crontab_helpers.py
โ โ โโโ __init__.py
โ โ โโโ utils.py
โ โโโ structures.py
โโโ tests
โโโ fixtures
โ โโโ test_data_collection_1.json
โ โโโ test_data_collection_2.json
โโโ __init__.py
โโโ mocks.py
โโโ test_crontab_helpers.py
โโโ test_helpers.py
Contributing
We welcome contributions of all kinds โ bug fixes, new features, documentation improvements, or suggestions!
To contribute:
- Fork this repository to your own GitHub account.
- Clone your fork locally and create a new branch:
$ git clone https://github.com/sergey-vernyk/PostmanCollectionExporter.git
$ git checkout -b my-feature-branch
- Make your changes and follow the existing coding style.
- Test your changes if applicable.
- Commit your changes with a clear message:
$ git commit -m "Add brief description of changes"
- Push your branch to your fork:
$ git push origin my-feature-branch
- Open a Pull Request from your branch to the main repository, explaining what you changed and why.
We appreciate all contributions and will review pull requests as quickly as possible. Be respectful and constructive when interacting with others in this project.
TODO
- Add unit tests for archiving
- Add unit tests for exporting
- Add logging to CLI command
- Add logging to helpers functions
- Add unit tests for scheduling
- Add GitHub Actions CI
- Add logging
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file postman_collection_exporter-0.0.7.tar.gz.
File metadata
- Download URL: postman_collection_exporter-0.0.7.tar.gz
- Upload date:
- Size: 22.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b458cd79ac355404a0d8b37b892de548821df5f9fe965aba62badd4fe6e54fd2
|
|
| MD5 |
70b36f6e1005cc1057b9af72b2cbe92c
|
|
| BLAKE2b-256 |
4f85a649cde2b98c06e7c419cc06547d463332452c225a4e7d0ff87365407ded
|
Provenance
The following attestation bundles were made for postman_collection_exporter-0.0.7.tar.gz:
Publisher:
release.yaml on sergey-vernyk/PostmanCollectionExporter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
postman_collection_exporter-0.0.7.tar.gz -
Subject digest:
b458cd79ac355404a0d8b37b892de548821df5f9fe965aba62badd4fe6e54fd2 - Sigstore transparency entry: 390985484
- Sigstore integration time:
-
Permalink:
sergey-vernyk/PostmanCollectionExporter@143ce77037cb60a7242fe696e5d0e97c50ad9160 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/sergey-vernyk
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@143ce77037cb60a7242fe696e5d0e97c50ad9160 -
Trigger Event:
workflow_run
-
Statement type:
File details
Details for the file postman_collection_exporter-0.0.7-py3-none-any.whl.
File metadata
- Download URL: postman_collection_exporter-0.0.7-py3-none-any.whl
- Upload date:
- Size: 19.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22b2269ff119c6550db7d61fd9be6c257d594158ae02db2f63b289278a1cf2ff
|
|
| MD5 |
8856211a75719649d2cf50a6d841b310
|
|
| BLAKE2b-256 |
c0a44139e670a179dfe16748cdcc9e0e27e6b4749a13ff7c7b593cf3e98440c9
|
Provenance
The following attestation bundles were made for postman_collection_exporter-0.0.7-py3-none-any.whl:
Publisher:
release.yaml on sergey-vernyk/PostmanCollectionExporter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
postman_collection_exporter-0.0.7-py3-none-any.whl -
Subject digest:
22b2269ff119c6550db7d61fd9be6c257d594158ae02db2f63b289278a1cf2ff - Sigstore transparency entry: 390985509
- Sigstore integration time:
-
Permalink:
sergey-vernyk/PostmanCollectionExporter@143ce77037cb60a7242fe696e5d0e97c50ad9160 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/sergey-vernyk
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@143ce77037cb60a7242fe696e5d0e97c50ad9160 -
Trigger Event:
workflow_run
-
Statement type: