Skip to main content

PermutiveAPI

Python CI

PermutiveAPI is a Python module to interact with the Permutive API. It provides a set of classes and methods to manage users, imports, cohorts, and workspaces within the Permutive ecosystem.

Installation

You can install the PermutiveAPI module using pip:

pip install PermutiveAPI --upgrade

Configuration

Copy the _env file as .env and set the PERMUTIVE_APPLICATION_CREDENTIALS environment variable to the absolute path of your workspace JSON file:

cp _env .env

Edit the .env file to include the path to your workspace JSON file:

PERMUTIVE_APPLICATION_CREDENTIALS="/absolute/path/to/workspace.json"

The workspace credentials JSON can be downloaded from the Permutive dashboard under Settings \u2192 API keys. Save the file somewhere secure and set the PERMUTIVE_APPLICATION_CREDENTIALS variable to its absolute path. The apiKey inside this JSON is used to authenticate API calls.

Usage

Importing the Module

To use the PermutiveAPI module, import the necessary classes. The main classes are exposed at the top level of the PermutiveAPI package:

from PermutiveAPI import (
    Alias,
    Cohort,
    CohortList,
    Identity,
    Import,
    ImportList,
    Segment,
    SegmentList,
    Source,
    Workspace,
    WorkspaceList,
)

Managing Users

You can manage user identities and aliases using the Identity and Alias classes:

# Create an alias
alias = Alias(id="alias_id", tag="alias_tag", priority=1)

# Create an identity
identity = Identity(user_id="user_id", aliases=[alias])

# Convert identity to JSON
identity_json = identity.to_json()

# Identify a user
identity.identify(api_key="your_private_key")

Managing Imports

You can manage imports using the Import and ImportList classes. An Import object may also contain a Source object.

# Fetch an import by ID
import_instance = Import.get_by_id(id="import_id", api_key="your_api_key")

# The source of the import can be accessed via the .source attribute
source_info = import_instance.source

# List all imports
imports = Import.list(api_key="your_api_key")

Managing Cohorts

You can manage cohorts using the Cohort and CohortList classes:

# Create a new cohort
cohort = Cohort(name="cohort_name", query={"property": "value"})
cohort.create(api_key="your_api_key")

# Fetch a cohort by ID
cohort_instance = Cohort.get_by_id(id="cohort_id", api_key="your_api_key")

# List all cohorts
cohorts = Cohort.list(api_key="your_api_key")

Managing Workspaces

You can manage workspaces using the Workspace and WorkspaceList classes:

# Create a workspace instance
workspace = Workspace(name="workspace_name", organization_id="org_id", workspace_id="workspace_id", api_key="your_api_key")

# List cohorts in a workspace
cohorts = workspace.list_cohorts(include_child_workspaces=True)

# List imports in a workspace
imports = workspace.imports

# List segments in a workspace
segments = workspace.list_segments(import_id="import_id")

Contributing

See CONTRIBUTING.md for development setup and pull request guidelines.

Development

Install the dependencies and set up your environment:

pip install -r requirements.txt
cp _env .env  # update the path to your workspace.json

After configuring the .env file you can import the package to verify everything is configured correctly:

python -c "import PermutiveAPI"

License

This project is licensed under the MIT License. See the LICENSE file for details.

Metadata

Release files for PermutiveAPI 5.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PermutiveAPI 5.2.4
File Size Uploaded Provenance Actions
permutiveapi-5.2.4.tar.gz 21.7 kB Without provenance Details for permutiveapi-5.2.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for PermutiveAPI 5.2.4
File Interpreter ABI Platform Actions
permutiveapi-5.2.4-py3-none-any.whl Python 3 none any Details for permutiveapi-5.2.4-py3-none-any.whl

Total release size: 44.0 kB

Release files / permutiveapi-5.2.4.tar.gz

Download URL permutiveapi-5.2.4.tar.gz
Size 21.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f8f52d8a983ce8bd61d9300172debe22f30a5f5c1a2bfba666e77ef5d9f18f02
BLAKE2b-256 checksum
How to use checksums
3085255b46e2522da066bdbcaeb447427f464f761a131e24744fa731cc03e346
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.23

Release files / permutiveapi-5.2.4-py3-none-any.whl

Download URL permutiveapi-5.2.4-py3-none-any.whl
Size 22.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
38dea72ed1d7998dd05599383824636adcd14469ddc04ca88e418372f80a972b
BLAKE2b-256 checksum
How to use checksums
8361ac622e8694a3c3b8535d05ae562ff70f87a1e5faf46975229d930b5ab789
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.23

Security for PermutiveAPI 5.2.4

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.

Release history Release notifications | RSS feed

This release

5.2.4 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page