Skip to main content

PermutiveAPI

PyPI version Python versions License: MIT

PermutiveAPI is a typed, governed Python SDK and AI-agent platform for the Permutive API.

It provides one canonical synchronous client, optional asynchronous support, typed queries and errors, a safe Codex plugin, OpenAI-compatible tools, and optional hosted MCP configuration. Python 3.9 through 3.13 are supported.

Install

Core SDK and CLI:

python -m pip install --upgrade PermutiveAPI

Optional asynchronous transport:

python -m pip install --upgrade "PermutiveAPI[async]"

Optional pandas integration:

python -m pip install --upgrade "PermutiveAPI[dataframe]"

The core package does not import or require pandas or HTTPX.

Configure safely

Run the local credential wizard from the project where you will use the SDK:

permutiveapi configure
permutiveapi doctor
permutiveapi validate

configure writes PERMUTIVE_API_KEY to a local .env file without echoing it. Existing files are not overwritten unless --force is supplied. doctor checks that the variable is present, the file has restrictive permissions where supported, and .env is ignored by Git. validate checks the installed SDK, CLI, Python plugin entry point, and tool contract without making a network request or requiring credentials.

Credential lookup is deterministic:

  1. Explicit API key passed by the application.
  2. PERMUTIVE_API_KEY in the process environment.
  3. .env in the current project.
  4. ~/.config/permutive/.env.

Credentials are never uploaded, logged, or included in object representations.

First request

PermutiveClient is the canonical synchronous entry point:

from PermutiveAPI import PermutiveClient

with PermutiveClient("api-key") as client:
    cohort = client.cohorts.get("cohort-id")
    first_page = client.segments.list(page_size=50)

print(cohort)
print(first_page.items)

The resource namespaces are:

  • client.cohorts
  • client.imports
  • client.segments
  • client.sources
  • client.workspaces

Supported resource operations use consistent get, list, create, update, and delete methods where the Permutive endpoint supports them. See API_COVERAGE.md for the maintained endpoint matrix.

Async usage

Install the async extra, then use the asynchronous client as a context manager:

import asyncio

from PermutiveAPI import AsyncPermutiveClient


async def main() -> None:
    async with AsyncPermutiveClient("api-key") as client:
        cohort = await client.request(
            "GET",
            "cohorts-api/v2/cohorts/cohort-id",
        )
        print(cohort)


asyncio.run(main())

The async client shares the same typed JSON, error, retry, redaction, pagination, and bounded-batch contracts as the synchronous SDK.

Typed queries

Query helpers compose immutable, deterministic JSON payloads while preserving raw payload compatibility:

from PermutiveAPI import all_of, event, property_condition

query = all_of(
    [
        event("Pageview"),
        property_condition("client.country", "equals", "FR"),
    ]
)

payload = query.to_json()

Invalid operator and value combinations fail before the request is sent.

Codex plugin

Install the repository-backed Codex marketplace plugin:

codex plugin marketplace add fatmambot33/PermutiveAPI --ref main
codex plugin add permutiveapi@fatmambot33-permutiveapi

The Python plugin surface is also available directly:

from PermutiveAPI.plugins.codex import CodexPlugin

plugin = CodexPlugin.from_env()
tools = plugin.tools().as_openai_tools()
agent_kit = plugin.agent_kit()

The default policy is read-only. To expose write tools, applications must explicitly select mode="read_write"; each mutating invocation still requires confirmed=True unless a deliberately approved policy says otherwise.

plugin = CodexPlugin.from_env(mode="read_write")
result = plugin.invoke(
    "permutive_create_cohort",
    {"payload": {"name": "Example", "query": {}}},
    confirmed=True,
)

The plugin reuses the canonical SDK. It does not duplicate transport, authentication, models, or business rules. See docs/AI_NATIVE_PLUGIN.md, docs/AI_NATIVE.md, and docs/MCP.md.

CLI lifecycle

Command Purpose
permutiveapi configure Create a protected local .env credential file.
permutiveapi doctor Check local credential safety without showing values.
permutiveapi validate Validate the installed product surface.
permutiveapi test Run the deterministic installed-package self-test.
permutiveapi docs Print canonical documentation locations.
permutiveapi examples Print minimal SDK and plugin examples.
permutiveapi upgrade Print the explicit interpreter-specific upgrade command.
permutiveapi uninstall Print the explicit interpreter-specific removal command.

upgrade and uninstall print commands only. They never mutate the active environment automatically. Full behavior and exit codes are documented in docs/CLI.md.

Compatibility

PUBLIC_API.md is the source of truth for canonical, compatibility, deprecated, and internal exports. Legacy resource classes remain available as compatibility APIs, but new code should use PermutiveClient, AsyncPermutiveClient, typed queries, and the canonical plugin/tool surfaces.

See MIGRATION.md before replacing older call patterns and COMPATIBILITY_MATRIX.md for the supported Python and optional-dependency matrix.

Development

Clone and install the repository in editable mode:

git clone https://github.com/fatmambot33/PermutiveAPI.git
cd PermutiveAPI
python -m pip install -e ".[dev]"

Run the same primary checks used by CI:

black --check src tests typing_examples
pydocstyle src/PermutiveAPI
python scripts/validate_typing_scope.py
pyright
pyright typing_examples/downstream.py
pytest -q
python scripts/validate_ai_native_platform.py
python scripts/validate_release_metadata.py
python -m build
python -m twine check dist/*

NumPy-style docstrings, strict typing, deterministic network-free tests, clean package installation, and secret redaction are required for supported changes.

Project contracts

License

MIT. See LICENSE.

Metadata

Release files for PermutiveAPI 6.5.1

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 6.5.1
File Size Uploaded Provenance Actions
permutiveapi-6.5.1.tar.gz 104.6 kB Without provenance Details for permutiveapi-6.5.1.tar.gz

Built distribution (wheel)

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

Total release size: 185.2 kB

Release files / permutiveapi-6.5.1.tar.gz

Download URL permutiveapi-6.5.1.tar.gz
Size 104.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1df56e6ab54a16411fd7b5aa2e869214dc8f9a0114f8fd507cfd7615371349ed
BLAKE2b-256 checksum
How to use checksums
9c913319ed3c46fa74f84043afc693dbd43d37839a3ac61aff3fe61acda458ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

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

Download URL permutiveapi-6.5.1-py3-none-any.whl
Size 80.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5e192bf96d64aceb0e619e14c47542efa18957393e8cab440c8c3e5117adec9e
BLAKE2b-256 checksum
How to use checksums
f8cd4a5ea68515851e7e2e06d5c123c331a031f82dee257c84da85fa62465aeb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for PermutiveAPI 6.5.1

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

6.5.1 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