Skip to main content

No project description provided

Project description

PermutiveAPI

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"

Usage

Importing the Module

To use the PermutiveAPI module, import the necessary classes:

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

Managing Users

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

from PermutiveAPI.User import Identity, Alias

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

from PermutiveAPI.Import import Import, ImportList

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

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

Managing Cohorts

You can manage cohorts using the Cohort and CohortList classes:

from PermutiveAPI.Cohort import Cohort, CohortList

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

from PermutiveAPI.Workspace import Workspace, WorkspaceList

# 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")

License

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

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

permutiveapi-5.0.1.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

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

permutiveapi-5.0.1-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file permutiveapi-5.0.1.tar.gz.

File metadata

  • Download URL: permutiveapi-5.0.1.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for permutiveapi-5.0.1.tar.gz
Algorithm Hash digest
SHA256 49a6b1978ec033725b553900e77cc299757b670d275b091001f1a169e3494a12
MD5 383205fc34c0a9c1e621f0c3c4baaf79
BLAKE2b-256 6a9470bba0762426d5ae8b46f730c134268e20a18008296dcb6fed43e0d488ad

See more details on using hashes here.

File details

Details for the file permutiveapi-5.0.1-py3-none-any.whl.

File metadata

  • Download URL: permutiveapi-5.0.1-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for permutiveapi-5.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4f2ffb72b70790a7c26065bea8bbb375ce0e0891891da5a2d10eb0cb8c4811af
MD5 4456d34517e659c1d12de59f22717152
BLAKE2b-256 fb643ac9d7c89ec4d071a58c7a2cc30d36f90169dd246c8295e12d4de5169c79

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