Skip to main content

Postman SDK

Project description

Postman

About

This SDK instruments Python web frameworks to capture http requests and auto-generates Postman Live Collections.

The minimum supported version for Python is: 3.7+.

Installation Process

pip install postman-sdk

Note: If you encounter any issues during installation in Linux and the error is associated with building the SDK, please try running the following commands:

Alpine

apk add --no-cache build-base

Debian / Ubunutu

apt update && apt install -y build-essential

Supported Instrumentations

Instrumentation Supported Version SDK Version Tested
flask >=2.0.3 >=0.0.10
requests >=2.27.x >=0.0.10

Please Note : While other frameworks/variations of these frameworks might work with our SDK, but they have not been extensively tested and might lead to discrepancies in results. We recommend using the specified framework or version to ensure accurate and consistent outcomes.

Initializing the SDK

At the top of your app.py file, before app is initialized, add this.

import postman_sdk as pm

pm.initialize(
    {
        "api_key": "<add-postman-api-key-here>",
        "collection_id": "<add-collection-id-here>"
    }
)

Configuration

For initialization the SDK, the following values can be configured -

  • collection_id: Postman collectionId where requests will be added. This is the id for your live collection.

    • Type: string
  • api_key: Postman api key needed for authentication.

    • Type: string
  • debug: Enable/Disable debug logs.

    • Type: boolean
    • Default: False
  • receiver_base_url: Where the data should be shipped to receiver's http endpoint.

    • Type: string(valid url)
  • enable: Enable/Disable the SDK. Disabled SDK does not capture any new traces, nor does it use up system resources.

    • Type: boolean
    • Default: True
    • Can be set by using an environment variable 'POSTMAN_SDK_ENABLE', which will over-ride any other config.
  • truncate_data: Truncate the request and response body so that no PII data is sent to Postman. This is enabled by default. Disabling it sends actual request and response payloads.

    • Example:

      Sample payload or non-truncated payload:

      {
          "first_name": "John",
          "age": 30
      }
      

      Truncated payload:

      {
          "first_name": {
              "type": "str"
          },
          "age": {
              "type": "int"
          }
      }
      
    • Type: boolean

    • Default: True

  • redact_sensitive_data: Redact sensitive data such as api_keys and auth tokens, before they leave the sdk. When this is enabled, below redaction rules are applied by default (they are not case-sensitive):

      {
          "pm_postman_api_key": r"PMAK-[a-f0-9]{24}-[a-f0-9]{34}",
          "pm_postman_access_key": r"PMAT-[0-9a-z]{26}",
          "pm_basic_auth": r"Basic (?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{4}|[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{2}={2})$",
          "pm_bearer_token": r"Bearer [a-z0-9A-Z\-\._~\+\/]{15,1000}"
      }
    
    • Example:
      {
      "redact_sensitive_data": {
          "enable": True(default), 
          "rules": { # This is optional, if the `rules` key is not passed, the default set of rules will be used.
              "<rule name>": "<regex to match the rule>", # such as -
              "basic_auth": r"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b",
              },
          }
      }
      
    • Type: object
  • ignore_incoming_requests: List of regexes to be ignored from instrumentation. This rule only applies to endpoints that are served by the application/server.

    • Example:
      {
          "ignore_incoming_requests": ["knockknock", "^get.*"]
      }
      
      The above example, will ignore any endpoint that contains the word "knockknock" in it, and all endpoints that start with get, and contain any characters after that.
    • Type: dict
  • ignore_outgoing_requests: List of regexes to be ignored from instrumentation. This rule only applies to endpoints that are called by the application/server.

    • Example:
      {
          "ignore_outgoing_requests": ["knockknock", "^get.*"]
      }
      
      The above example, will ignore any endpoint that contains the word "knockknock" in it, and all endpoints that start with get, and contain any characters after that.
    • Type: dict
  • buffer_interval_in_milliseconds: The interval in milliseconds that the SDK waits before sending data to Postman. The default interval is 5000 milliseconds. This interval can be tweaked for lower or higher throughput systems.

    • Type: int
    • Default: 5000

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

postman-sdk-0.0.12.tar.gz (19.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

postman_sdk-0.0.12-py3-none-any.whl (26.5 kB view details)

Uploaded Python 3

File details

Details for the file postman-sdk-0.0.12.tar.gz.

File metadata

  • Download URL: postman-sdk-0.0.12.tar.gz
  • Upload date:
  • Size: 19.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for postman-sdk-0.0.12.tar.gz
Algorithm Hash digest
SHA256 3c61ae413c25e18e48d8cdc15ff7594fece787d4f31be79d5765ac2c0b565010
MD5 8a02a46c1d84074cd6453e6647296857
BLAKE2b-256 65c97dd6ffdcebf7f10718074167e26402445819d1373e0c56dcb96d26078ffe

See more details on using hashes here.

File details

Details for the file postman_sdk-0.0.12-py3-none-any.whl.

File metadata

  • Download URL: postman_sdk-0.0.12-py3-none-any.whl
  • Upload date:
  • Size: 26.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for postman_sdk-0.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 d18c7e86f3f473f1b48a0180f42ec3629dc43b3d4942131f3f05b5e88c145bea
MD5 6e75614b9e8266dc23e077d3bb51936e
BLAKE2b-256 8723fc5f6fa7319f1fd02f63c5672e19fda7e8ef0df6865c761ff7dd56d0df50

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page