| name | clari-sdk-patterns |
| description | Production-ready Clari API client patterns in Python and TypeScript.
Use when building reusable Clari clients, implementing export pipelines,
or wrapping the Clari v4 API for team use.
Trigger with phrases like "clari API patterns", "clari client wrapper",
"clari Python client", "clari TypeScript client".
|
| allowed-tools | Read, Write, Edit |
| version | 1.6.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","revenue-intelligence","forecasting","clari"] |
| compatibility | Designed for Claude Code |
Clari SDK Patterns
Overview
Clari has no official SDK -- build typed wrappers around the v4 REST API. These patterns cover the Export API for forecasts, job polling, and data transformation pipelines.
Prerequisites
- Completed
clari-install-auth setup
- Python 3.10+ (primary) or TypeScript 5+
Instructions
Step 1: Python Client
import os
import time
import requests
from dataclasses import dataclass, field
from typing import Optional
@dataclass
class ClariConfig:
api_key: str
base_url: str = "https://api.clari.com/v4"
poll_interval: int = 5
max_poll_attempts: int = 60
class ClariClient:
def __init__(self, config: Optional[ClariConfig] = None):
self.config = config or ClariConfig(
api_key=os.environ["CLARI_API_KEY"]
)
self.session = requests.Session()
self.session.headers.update({
"apikey": self.config.api_key,
"Content-Type": "text/plain",
})
def list_forecasts(self) -> list[dict]:
resp = .session.get()
resp.raise_for_status()
resp.json()[]
() -> :
payload = {
: time_period,
: types [
, , ,
, ,
],
: currency,
: ,
: ,
: export_format,
}
resp = .session.post(
,
json=payload,
)
resp.raise_for_status()
resp.json()
() -> :
attempt (.config.max_poll_attempts):
resp = .session.get(
,
)
resp.raise_for_status()
status = resp.json()
status[] == :
status
status[] == :
ClariExportError()
time.sleep(.config.poll_interval)
ClariExportError()
() -> :
resp = requests.get(download_url)
resp.raise_for_status()
resp.json()
() -> :
job = .export_forecast(forecast_name, time_period)
completed = .wait_for_job(job[])
.download_export(completed[])
():