postmanparser
Introduction
Postman collection parser written in python3 to extract HTTP requests/responses. Currently supports reading JSON schema two ways
- Read from
.jsonfile - Fetch from url where schema is exposed
Installation
-
Using pip
pip install postmanparser -
Using poetry
poetry add postmanparser
Getting Started
Parsing API Schema
You can parse API schema from file or from url as below.
- From file
from postmanparser import Collection
collection = Collection()
collection.parse_from_file("path/to/postman/schema.json")
- From url
from postmanparser import Collection
collection = Collection()
collection.parse_from_url("http://example.com/schema")
URL should be a GET request.
postmanparser also validates for the required fields mentioned by postman schema documentation which is available at https://schema.postman.com/
Reading the data
Postman collection contains group of requests and one or more folders having group of requests and/or nested folders in it.
Getting requests from the collection
You can retreive all the requests present in the collection using get_requests() method.
This method will recursively search for the requests inside folders is present.
collection = Collection()
collection.parse_from_file("path/to/postman/schema.json")
requests = collection.get_requests()
for request in requests:
print(request) #Either a Request object or str
You can retrieve the requests inside specific folder by using folder="folder_name" in get_requests method. To get requests from the nested folder, use folder path separated by /
For e.g. to get requests inside folder2 which is nested in folder1
requests = collection.get_requests(folder="folder/sub_folder")
You can pass recursive=False to get_requests() if you don't want to do recusrive lookup. In this case
you will get all the requests present at the root level of collection or at the folder level is folder is specified.
requests = collection.get_requests(recursive=False)
Getting requests mapped by folder in the collection
You can access requests in the collections as requests map using get_requests_map(). The key of the dict is path to the folder separated by backlash and value is list of requests of type Request or str.
This will be recursive search for all the folders and sub folders inside it.
collection = Collection()
collection.parse_from_file("path/to/postman/schema.json")
requests = collection.get_requests_map()
requests = collection.get_requests_map(folder="folder/sub_folder")
Validation
If schema found to be invalid following exception will be thrown.
MissingRequiredFieldExceptionInvalidPropertyValueExceptionInvalidObjectExceptionFolderNotFoundException
Schema Support
postmanparser is still in early stages and will be updated with missing schema components soon.
Following are the objects which are not supported yet but will be added in the future.
- protocolProfileBehavior
Collection SDK Compatibility
Currently postmanparser is not aligned with collection SDK node module. http://www.postmanlabs.com/postman-collection/
This Might be added in future. Feel free to raise the PR.
Version Compatibility
postmanparser supports collection schema v2.0.0 and v2.1.0.
Metadata
Release files for postmanparser 0.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| postmanparser-0.1.9.tar.gz | 13.3 kB | Without provenance | Details for postmanparser-0.1.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| postmanparser-0.1.9-py3-none-any.whl | Python 3 | none | any | Details for postmanparser-0.1.9-py3-none-any.whl |
Total release size: 32.1 kB
Release files / postmanparser-0.1.9.tar.gz
| Download URL | postmanparser-0.1.9.tar.gz |
|---|---|
| Size | 13.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e44f74cd962dc082ab7330de2062b3a8da281cc5be28d2a9e3ab7f11fd3c4b4b
|
|
BLAKE2b-256 checksum How to use checksums |
647d00fbf858bff8d7cf9754bf6a1361eca025b5ed2303cde86f3691d2c5afcc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.0 CPython/3.13.1 Darwin/24.2.0
|
Release files / postmanparser-0.1.9-py3-none-any.whl
| Download URL | postmanparser-0.1.9-py3-none-any.whl |
|---|---|
| Size | 18.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b964049b65c60897122c5b16d9f3bb01f10a74c989b82e62866c21385d6dca69
|
|
BLAKE2b-256 checksum How to use checksums |
a7dc355aabff03e20f6f36b4365aa72c878fb68747f51ea58abb9a8716959456
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.0 CPython/3.13.1 Darwin/24.2.0
|
Security for postmanparser 0.1.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.