# Postman Collection Exporter
Export your Postman collections via a simple CLI.
---
# ๐ Table of Content
- [โจ Features](#-features)
- [๐ Usage](#-usage)
- [Export Collections](#-export-collections)
- [Archive collections](#-archive-collections)
- [Scheduling CLI actions](#-scheduling-cli-actions)
- [โ๏ธ Requirements](#-requirements)
- [๐ Environment Variables](#-environment-variables)
- [๐ ๏ธ Project Structure](#-project-structure)
- [๐งน TODO](#-todo)
- [๐ License](#-license)
- [๐ค Authors](#-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`, and `xztar`.
- **Asynchronous API Interaction**: Leverages `asyncio`, `httpx`, and `aiofiles` for 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 `asyncclick` to 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-path` option).
---
## ๐ Usage
### Export Collections
```bash
# 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
```bash
# 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]
### Scheduling CLI actions
In order to use scheduling functionality **it's necessary to install** the package with an extra dependency:
```bash
pip install postman_collection_exporter"[schedule]"
# or install needed package later via
pip install python-crontab
```
```bash
# 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):
```bash
export POSTMAN_API_KEY=<actual_api_key>
```
The script will fail gracefully if no API key is found.
---
## ๐ ๏ธ 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
```
---
## ๐งน TODO
- [x] Add unit tests for archiving
- [x] Add unit tests for exporting
- [x] Add logging to CLI command
- [ ] Add logging to helpers functions
- [x] 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.
## ๐ค Authors
Sergey Vernigora volt.awp.dev@gmail.com
Raw data
{
"_id": null,
"home_page": null,
"name": "postman-collection-exporter",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": "Sergey Vernigora <volt.awp.dev@gmail.com>",
"keywords": "cli, crontab, export, json, postman",
"author": null,
"author_email": "Sergey Vernigora <volt.awp.dev@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/f4/0f/0fbd39e8635208a4cd4747fb7b6099cc68d545ac16e7f77a9744cc489491/postman_collection_exporter-0.0.6.tar.gz",
"platform": null,
"description": "# Postman Collection Exporter\n\nExport your Postman collections via a simple CLI.\n\n---\n\n# \ud83d\udcd1 Table of Content\n\n - [\u2728 Features](#-features)\n - [\ud83d\ude80 Usage](#-usage)\n - [Export Collections](#-export-collections)\n - [Archive collections](#-archive-collections)\n - [Scheduling CLI actions](#-scheduling-cli-actions)\n - [\u2699\ufe0f Requirements](#-requirements)\n - [\ud83d\udcd1 Environment Variables](#-environment-variables)\n - [\ud83d\udee0\ufe0f Project Structure](#-project-structure)\n - [\ud83e\uddf9 TODO](#-todo)\n - [\ud83d\udcdc License](#-license)\n - [\ud83d\udc64 Authors](#-authors)\n\n\n## \u2728 Features\n\n- **Export Multiple Collections**: Export several Postman collections simultaneously with just a few commands.\n- **Archive Collections in Known Formats**: Archive exported Postman collections to formats like `tar`, `zip`, `gztar`, `bztar`, and `xztar`.\n- **Asynchronous API Interaction**: Leverages `asyncio`, `httpx`, and `aiofiles` for efficient, non-blocking communication with the Postman API.\n- **Save Collections in JSON Format**: Save Postman collections locally in a clean, standardized JSON format.\n- **CLI Built with asyncclick Library**: A powerful and user-friendly command-line interface, built with `asyncclick` to handle async operations gracefully.\n- **Error Handling**: Gracefully handles errors from the Postman API, ensuring that authentication issues or rate limits are reported clearly.\n- **Modular and Extendable**: The app's modular structure makes it easy to add new features or adjust behavior as needed.\n- **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.\n- **Logging**: Logs CLI command results and errors to a user-specified log file (via the `--log-path` option). \n---\n\n## \ud83d\ude80 Usage\n\n### Export Collections\n```bash\n# Using Python module\npython -m postman_collection_exporter.cli export --path /home/user/exports -n Collection1 -n Collection2 --api-key postman-api-key\n\n# Using directly (--api-key is optional if POSTMAN_API_KEY is set)\nexport-collections --path /home/user/exports -n Collection1 -n Collection2 --api-key postman-api-key\n```\n- `-p, --path-to-collections`: Directory, where exported collections will be located.\n- `-n, --collection-names`: Names of the Postman collections to be export.\n- `-k, --api-key`: Optional Postman API key for authentication. Overrides environment variable.\n- `-l, --log-path`: Path to the log file for the command output. [default: /home/username/crontab/cron.log]\n\n### Archive collections\n```bash\n# Using Python module\npython -m postman_collection_exporter.cli archive --path-to-collections /home/user/exports --path-to-archive /home/user/archives -n My_Collections --archive-type tar\n\n# Using directly (--api-key is optional if POSTMAN_API_KEY is set)\narchive-collections --path-to-collections /home/user/exports --path-to-archive /home/user/archives -n My_Collections --archive-type tar\n```\n- `-c, --path-to-collections`: Path to directory with collections being archived.\n- `-a, --path-to-archive`: Path to directory with an archive being created.\n- `-n, --name`: Name of the archive being created.\n- `--archive-type`: Type of an archive being created. [default:zip]\n- `-l, --log-path`: Path to the log file for the command output. [default: /home/username/crontab/cron.log]\n\n### Scheduling CLI actions\nIn order to use scheduling functionality **it's necessary to install** the package with an extra dependency:\n```bash\npip install postman_collection_exporter\"[schedule]\"\n\n# or install needed package later via\npip install python-crontab\n```\n```bash\n# Using Python module\npython -m postman_collection_exporter.cli set-schedule --action export --pattern \"1 * * * *\" --comment \"Export Postman collections every hour.\"\n\n# Using directly\nset-schedule --action export --pattern \"1 * * * *\" --comment \"Export Postman collections every hour.\"\n```\n- `-a, --action`: Choose the Postman action to schedule. (export or archive at this time) [required]\n- `-p, --pattern`: Crontab pattern (e.g., \"0 0 * * *\" for daily at midnight). Must be written within quotes! [required]\n- `-c, --comment`: Comment added to the crontab entry (displayed next to the pattern) [required]\n- `-u, --user`: Username for the target crontab (default: current user). Assigning dynamically.\n- `--dry-run`: Show the crontab entry that would be created, without applying it.\n---\n\n## \u2699\ufe0f Requirements\n\n- Python 3.11+\n\n## \ud83d\udcd1 Environment Variables\n\nSet the Postman API key as an environment variable (optional):\n\n```bash\nexport POSTMAN_API_KEY=<actual_api_key>\n```\n\nThe script will fail gracefully if no API key is found.\n\n---\n\n## \ud83d\udee0\ufe0f Project Structure\n\n```\n.\n\u251c\u2500\u2500 LICENSE\n\u251c\u2500\u2500 pyproject.toml\n\u251c\u2500\u2500 README.md\n\u251c\u2500\u2500 requirements.txt\n\u251c\u2500\u2500 src\n\u2502 \u2514\u2500\u2500 postman_collection_exporter\n\u2502 \u251c\u2500\u2500 cli.py\n\u2502 \u251c\u2500\u2500 dependencies\n\u2502 \u2502 \u251c\u2500\u2500 __init__.py\n\u2502 \u2502 \u2514\u2500\u2500 utils.py\n\u2502 \u251c\u2500\u2500 enums.py\n\u2502 \u251c\u2500\u2500 exceptions.py\n\u2502 \u251c\u2500\u2500 exporters.py\n\u2502 \u251c\u2500\u2500 helpers.py\n\u2502 \u251c\u2500\u2500 __init__.py\n\u2502 \u251c\u2500\u2500 logging\n\u2502 \u2502 \u251c\u2500\u2500 config.py\n\u2502 \u2502 \u2514\u2500\u2500 __init__.py\n\u2502 \u251c\u2500\u2500 scheduling\n\u2502 \u2502 \u251c\u2500\u2500 cli.py\n\u2502 \u2502 \u251c\u2500\u2500 crontab_helpers.py\n\u2502 \u2502 \u251c\u2500\u2500 __init__.py\n\u2502 \u2502 \u2514\u2500\u2500 utils.py\n\u2502 \u2514\u2500\u2500 structures.py\n\u2514\u2500\u2500 tests\n \u251c\u2500\u2500 fixtures\n \u2502 \u251c\u2500\u2500 test_data_collection_1.json\n \u2502 \u2514\u2500\u2500 test_data_collection_2.json\n \u251c\u2500\u2500 __init__.py\n \u251c\u2500\u2500 mocks.py\n \u251c\u2500\u2500 test_crontab_helpers.py\n \u2514\u2500\u2500 test_helpers.py\n```\n---\n\n## \ud83e\uddf9 TODO\n\n- [x] Add unit tests for archiving\n- [x] Add unit tests for exporting\n- [x] Add logging to CLI command\n- [ ] Add logging to helpers functions\n- [x] Add unit tests for scheduling\n- [ ] Add GitHub Actions CI\n- [ ] Add logging\n\n---\n\n## \ud83d\udcdc License\nThis project is licensed under the MIT License. See the LICENSE file for details.\n\n## \ud83d\udc64 Authors\nSergey Vernigora volt.awp.dev@gmail.com",
"bugtrack_url": null,
"license": null,
"summary": "Export Postman collections via CLI.",
"version": "0.0.6",
"project_urls": null,
"split_keywords": [
"cli",
" crontab",
" export",
" json",
" postman"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "41eca6ffe3e128cd28d78569904525c27e778ec10c6126944a9dabb172a9eceb",
"md5": "f8c18b8f0c6acf6dcab01bfb36b031fb",
"sha256": "d04ba92fbf26b1f634f9506156454730ad5ee0ff01399877b1d8357678fe077a"
},
"downloads": -1,
"filename": "postman_collection_exporter-0.0.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f8c18b8f0c6acf6dcab01bfb36b031fb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 18587,
"upload_time": "2025-08-04T10:46:40",
"upload_time_iso_8601": "2025-08-04T10:46:40.397311Z",
"url": "https://files.pythonhosted.org/packages/41/ec/a6ffe3e128cd28d78569904525c27e778ec10c6126944a9dabb172a9eceb/postman_collection_exporter-0.0.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "f40f0fbd39e8635208a4cd4747fb7b6099cc68d545ac16e7f77a9744cc489491",
"md5": "e063e7c11b00a4368d349f9821691ed1",
"sha256": "ad5c1683b674370720ab0f4f5dd508c8eff445509c98e02ae8c64af0100a42ca"
},
"downloads": -1,
"filename": "postman_collection_exporter-0.0.6.tar.gz",
"has_sig": false,
"md5_digest": "e063e7c11b00a4368d349f9821691ed1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 21533,
"upload_time": "2025-08-04T10:46:42",
"upload_time_iso_8601": "2025-08-04T10:46:42.431118Z",
"url": "https://files.pythonhosted.org/packages/f4/0f/0fbd39e8635208a4cd4747fb7b6099cc68d545ac16e7f77a9744cc489491/postman_collection_exporter-0.0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-04 10:46:42",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "postman-collection-exporter"
}