Installation

Install the Protegrity Anonymization Python SDK, configure client access through the PPC gateway, and verify the connection.

Note: These steps are not part of the server install. They are intended for consuming the Anonymization service from a Python application using the SDK.

Use this section to install, configure, and validate the Python SDK for Protegrity Anonymization.

Prerequisites

Ensure one of the following is met:

  • pip is available in your active Python virtual environment.
  • A conda environment is activated.

Overview

Use the Python SDK to access the Anonymization service programmatically.

1. Install the Anonymization Python SDK

Install the SDK using pip or conda using the version that matches the deployed Anonymization service.

Using pip:

pip install protegrity-anonymization-sdk>=2.0.1

Using conda:

conda install -c protegrity protegrity-anonymization-sdk>=2.0.1

2. Configure the SDK

  1. Create a ClientConfig pointing to your PPC gateway.

    Note: Contact your administrator to obtain the gateway URL, username, and password for the Anonymization service.

  2. Configure the client in Python:

    from anonymization_sdk.config import ClientConfig
    
    config = ClientConfig(
        base_url="<GATEWAY_URL>/pty/anonymization/v3",
        username="<USERNAME>",
        password="<PASSWORD>",
    )
    

    Alternatively, configure using environment variables. For example, for Linux use the following commands:

    export ANON_API_URL="<GATEWAY_URL>/pty/anonymization/v3"
    export ANON_USERNAME="<USERNAME>"
    export ANON_PASSWORD="<PASSWORD>"
    
    from anonymization_sdk.config import ClientConfig
    
    config = ClientConfig.from_env()
    

    Note: Replace default credentials and URLs for production environments. For example, for <USERNAME>, enter anonymization_admin and for <PASSWORD>, enter StrongPassword123!.

3. Test the Anonymization Python SDK

from anonymization_sdk import AnonymizationClient
from anonymization_sdk.config import ClientConfig

config = ClientConfig(
    base_url="<GATEWAY_URL>/pty/anonymization/v3",
    username="anonymization_admin",
    password="StrongPassword123!",
)

with AnonymizationClient(config=config) as client:
    print("Connection established successfully.")

The connection is established successfully. If the connection fails, an error message is displayed.

For more information about the SDK Reference, refer to Python SDK Reference.


Last modified : August 03, 2026