Python SDK
parallelworks-client is the official Python client for the ACTIVATE platform API.
Installation
pip install parallelworks-clientQuick Start
The simplest way to create a client is to pass your credential. The platform host is automatically extracted from it:
import os
from parallelworks_client import Client
with Client.from_credential(os.environ["PW_API_KEY"]).sync() as client:
response = client.get("/api/buckets")
for bucket in response.json():
print(f"Bucket: {bucket['name']}")Authentication
Signed in with pw auth
For scripts you run yourself, sign in with pw auth once, then create the client from the CLI's credentials file. The client uses your sign-in and renews it automatically by running pw auth token --print -o json, so the CLI must be installed and on your PATH.
from parallelworks_client import Client
with Client.from_credential_config().sync() as client:
response = client.get("/api/buckets")The client uses the same context as the CLI: PW_API_KEY if set, then the context argument, PW_CONTEXT, and the current context. The cli_command argument sets the path to pw. If pw can't renew the sign-in, requests raise SignInExpiredError; run pw auth again.
For CI and other automation that runs without you, use an API key in PW_API_KEY instead.
Automatic Host Detection
An API key (pwt_...) contains your platform host, so from_credential connects to it with no URL. An access token from pw auth token --print doesn't name a host: the client uses PW_PLATFORM_HOST if set, otherwise the server of the selected CLI context.
# API key: host decoded from the key
client = Client.from_credential("pwt_Y2xvdWQucGFyYWxsZWwud29ya3M.xxxxx")
# Connects to: https://cloud.parallel.works
# Access token from `pw auth token --print`: host from PW_PLATFORM_HOST,
# else the server of the selected context
client = Client.from_credential(token)Explicit Host
If you prefer to specify the host explicitly:
# API key (Basic Auth) - for CI and other unattended automation
client = Client.with_api_key(
"https://cloud.parallel.works",
"pwt_..."
)
# Access token (Bearer), sent as is and never renewed
client = Client.with_token(
"https://cloud.parallel.works",
token
)
# Auto-detect credential type
client = Client.with_credential(
"https://cloud.parallel.works",
os.environ["PW_CREDENTIAL"]
)Credential Helpers
from parallelworks_client import is_api_key, is_token, extract_platform_host
is_api_key("pwt_abc.xyz") # True
is_token("eyJ.abc.def") # True
extract_platform_host("pwt_...") # "cloud.parallel.works"Async Support
The client supports async/await natively:
import asyncio
import os
from parallelworks_client import Client
async def main():
async with Client.from_credential(os.environ["PW_API_KEY"]) as client:
response = await client.get("/api/buckets")
print(response.json())
asyncio.run(main())Related Documentation
- SDKs Overview — Authentication basics and other languages
- API Reference — Browse every endpoint, with schemas and examples
- Creating API Keys — Generate a credential for the SDK