postmanparser


Namepostmanparser JSON
Version 0.1.7 PyPI version JSON
download
home_pagehttps://github.com/appknox/postmanparser
SummaryPostman collection parser for python
upload_time2023-12-28 06:55:58
maintainer
docs_urlNone
authorAppknox
requires_python>=3.8,<4.0
licenseApache-2.0
keywords postman appknox postmanparser
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # postmanparser
![Build](https://github.com/appknox/postmanparser/actions/workflows/test.yml/badge.svg)
[![codecov](https://codecov.io/gh/appknox/postmanparser/branch/main/graph/badge.svg?token=BXCg5XODJw)](https://codecov.io/gh/appknox/postmanparser)

## Introduction

Postman collection parser written in python3 to extract HTTP requests/responses.
Currently supports reading JSON schema two ways
- Read from `.json` file
- 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

```python
from postmanparser import Collection
collection = Collection()
collection.parse_from_file("path/to/postman/schema.json")
```

- From url

```python
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.

```python
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
```python
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.

```python
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.

```python
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.
- `MissingRequiredFieldException`
- `InvalidPropertyValueException`
- `InvalidObjectException`
- `FolderNotFoundException`

## 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.
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/appknox/postmanparser",
    "name": "postmanparser",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "postman,appknox,postmanparser",
    "author": "Appknox",
    "author_email": "engineering@appknox.com",
    "download_url": "https://files.pythonhosted.org/packages/af/6e/8533023893d9d2c8bd8997828061c05e9ce4f27794daa7eb7352d25b1ad9/postmanparser-0.1.7.tar.gz",
    "platform": null,
    "description": "# postmanparser\n![Build](https://github.com/appknox/postmanparser/actions/workflows/test.yml/badge.svg)\n[![codecov](https://codecov.io/gh/appknox/postmanparser/branch/main/graph/badge.svg?token=BXCg5XODJw)](https://codecov.io/gh/appknox/postmanparser)\n\n## Introduction\n\nPostman collection parser written in python3 to extract HTTP requests/responses.\nCurrently supports reading JSON schema two ways\n- Read from `.json` file\n- Fetch from url where schema is exposed\n\n## Installation\n - Using pip\n\n        pip install postmanparser\n\n- Using poetry\n\n        poetry add postmanparser\n\n## Getting Started\n\n### Parsing API Schema\nYou can parse API schema from file or from url as below.\n- From file\n\n```python\nfrom postmanparser import Collection\ncollection = Collection()\ncollection.parse_from_file(\"path/to/postman/schema.json\")\n```\n\n- From url\n\n```python\nfrom postmanparser import Collection\ncollection = Collection()\ncollection.parse_from_url(\"http://example.com/schema\")\n```\nURL should be a `GET` request.\n\npostmanparser also validates for the required fields mentioned by postman schema documentation which is available at https://schema.postman.com/\n\n### Reading the data\nPostman collection contains group of requests and one or more folders having group of requests and/or nested folders in it.\n\n#### Getting requests from the collection\n\nYou can retreive all the requests present in the collection using `get_requests()` method.\nThis method will recursively search for the requests inside folders is present.\n\n```python\ncollection = Collection()\ncollection.parse_from_file(\"path/to/postman/schema.json\")\nrequests = collection.get_requests()\nfor request in requests:\n        print(request) #Either a Request object or str\n```\n\nYou 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 `/`\n\nFor e.g. to get requests inside folder2 which is nested in folder1\n```python\nrequests = collection.get_requests(folder=\"folder/sub_folder\")\n```\n\nYou can pass `recursive=False` to `get_requests()` if you don't want to do recusrive lookup. In this case\nyou will get all the requests present at the root level of collection or at the folder level is folder is specified.\n\n```python\nrequests = collection.get_requests(recursive=False)\n```\n\n#### Getting requests mapped by folder in the collection\nYou 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`.\nThis will be recursive search for all the folders and sub folders inside it.\n\n```python\ncollection = Collection()\ncollection.parse_from_file(\"path/to/postman/schema.json\")\nrequests = collection.get_requests_map()\nrequests = collection.get_requests_map(folder=\"folder/sub_folder\")\n```\n\n### Validation\nIf schema found to be invalid following exception will be thrown.\n- `MissingRequiredFieldException`\n- `InvalidPropertyValueException`\n- `InvalidObjectException`\n- `FolderNotFoundException`\n\n## Schema Support\npostmanparser is still in early stages and will be updated with missing schema components soon.\n\nFollowing are the objects which are not supported yet but will be added in the future.\n- protocolProfileBehavior\n\n## Collection SDK Compatibility\n\nCurrently postmanparser is not aligned with collection SDK node module. http://www.postmanlabs.com/postman-collection/\n\nThis Might be added in future. Feel free to raise the PR.\n\n\n## Version Compatibility\npostmanparser supports collection schema v2.0.0 and v2.1.0.",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Postman collection parser for python",
    "version": "0.1.7",
    "project_urls": {
        "Homepage": "https://github.com/appknox/postmanparser",
        "Repository": "https://github.com/appknox/postmanparser"
    },
    "split_keywords": [
        "postman",
        "appknox",
        "postmanparser"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b4519c3dcfb0af0a4695216f18576b1f88a7fac986d4616bea0f6e0ab53443ac",
                "md5": "17797dfcc401031ea5c4dc2bb8d01571",
                "sha256": "f16322384c008144fda204764aaa375f1e1d714102ea18061167291e10d5e113"
            },
            "downloads": -1,
            "filename": "postmanparser-0.1.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "17797dfcc401031ea5c4dc2bb8d01571",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 18745,
            "upload_time": "2023-12-28T06:55:56",
            "upload_time_iso_8601": "2023-12-28T06:55:56.950931Z",
            "url": "https://files.pythonhosted.org/packages/b4/51/9c3dcfb0af0a4695216f18576b1f88a7fac986d4616bea0f6e0ab53443ac/postmanparser-0.1.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "af6e8533023893d9d2c8bd8997828061c05e9ce4f27794daa7eb7352d25b1ad9",
                "md5": "56183279d0c13fbe8b1cb746552e41f0",
                "sha256": "f58eee52dfd5f6c93c2ba74e41bd0edcdb1598442ee95811fd2158607e7aa1a8"
            },
            "downloads": -1,
            "filename": "postmanparser-0.1.7.tar.gz",
            "has_sig": false,
            "md5_digest": "56183279d0c13fbe8b1cb746552e41f0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 13957,
            "upload_time": "2023-12-28T06:55:58",
            "upload_time_iso_8601": "2023-12-28T06:55:58.310642Z",
            "url": "https://files.pythonhosted.org/packages/af/6e/8533023893d9d2c8bd8997828061c05e9ce4f27794daa7eb7352d25b1ad9/postmanparser-0.1.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-28 06:55:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "appknox",
    "github_project": "postmanparser",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "postmanparser"
}
        
Elapsed time: 0.15733s