Pulse Python SDK
Official Python client for Pulse, the data analysis API for market researchers.
Install
Requires Python 3.9 or newer.
pip install pulse-sdk
Quickstart
Analyze sentiment for a small set of inputs. Replace placeholders with your credentials.
from pulse.starters import analyze_sentiment
from pulse.auth import ClientCredentialsAuth
inputs = [
"The new features are fantastic!",
"It's okay, but could be better.",
"Customer service was disappointing.",
]
auth = ClientCredentialsAuth(
client_id="<CLIENT_ID>",
client_secret="<CLIENT_SECRET>",
)
result = analyze_sentiment(inputs=inputs, auth=auth)
print(result)
Authentication
The SDK supports client credentials. You can also provide credentials via environment variables.
# Option 1: Pass explicitly
from pulse.auth import ClientCredentialsAuth
auth = ClientCredentialsAuth(client_id="<CLIENT_ID>", client_secret="<CLIENT_SECRET>")
# Option 2: Environment variables
# export PULSE_CLIENT_ID=...
# export PULSE_CLIENT_SECRET=...
# Then in code:
from pulse.auth import ClientCredentialsAuth
auth = ClientCredentialsAuth.from_env()
Usage
Sentiment
from pulse.starters import analyze_sentiment
from pulse.auth import ClientCredentialsAuth
auth = ClientCredentialsAuth.from_env()
result = analyze_sentiment(inputs=["Loved it", "Not great"], auth=auth)
print(result)
Themes
from pulse.starters import generate_themes
from pulse.auth import ClientCredentialsAuth
auth = ClientCredentialsAuth.from_env()
result = generate_themes(inputs=["Love the camera", "Battery life is long"], auth=auth)
print(result)
Similarity
from pulse.starters import similarity_matrix
from pulse.auth import ClientCredentialsAuth
auth = ClientCredentialsAuth.from_env()
result = similarity_matrix(inputs=["alpha", "beta", "gamma"], auth=auth)
print(result)
Configuration
Customize the SDK with timeouts, retries, base URL (for self‑hosted), and proxies.
from pulse.client import PulseClient
client = PulseClient(
timeout_seconds=30,
max_retries=3,
base_url="https://core.researchwiseai.com/pulse/v1",
proxy_url=None,
)
# Pass client=client to functions that accept it, e.g. analyze_sentiment(..., client=client)
Error Handling
API errors raise typed exceptions. Inspect the status code and message for details.
from pulse.errors import PulseAPIError
try:
result = analyze_sentiment(inputs=[""], auth=auth)
except PulseAPIError as e:
print(e.status_code, e.message)
Logging & Debug
Enable verbose logging for request/response troubleshooting during development.
import logging
logging.basicConfig(level=logging.DEBUG)
# SDK will emit debug logs via the standard logging module.
Models & Types
Responses are standard Python dicts today. Upcoming releases will add typed models (dataclasses/TypedDict) for better IDE support.
Resources
- API Reference: OpenAPI docs
- Quickstart: /pulse/quickstart
- Examples: coming soon
- Changelog: coming soon