Skip to main content
POST
/
v1
/
state
/
logs
/
query
import olira

olira.init(api_key="YOUR_API_KEY")

# Whole org
rows = (
    olira.population_logs()
        .eq("type", "health_metric")
        .order("timestamp", desc=True)
        .limit(50)
        .execute()
)
print(rows.count)

# Explicit cohort + aggregation
agg = (
    olira.population_logs(patient_ids=["8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82", "other-patient-id"])
        .group_by("type")
        .count_agg("n")
        .execute()
)
for row in agg:
    print(row["type"], row["n"])
LogQueryResult(
    count=3,
    rows=[
        {"id": "log-a", "type": "health_metric", "timestamp": "2026-01-06T00:00:00Z", "payload": {...}},
        {"id": "log-b", "type": "health_metric", "timestamp": "2026-01-05T00:00:00Z", "payload": {...}},
        {"id": "log-c", "type": "health_metric", "timestamp": "2026-01-01T00:00:00Z", "payload": {...}},
    ],
    patient_id=None,
    organization_id="org-001",
)
olira.population_logs(patient_ids: list[str] | None = None) -> LogQueryResult
Requires scope: sdk:state-read Omit patient_ids (or pass None) for org-wide queries; pass a list to restrict to a cohort. All chainable builder methods are identical to logs — see that entry.

Parameters

patient_ids
list[str] | None
default:"None"
Cohort of patient ids. None = whole org. Omitting queries all patients org-wide — use filters and limits when running at scale.

Returns

LogQueryResult — Same shape as logs — call .execute() or another terminal to run.
count
int
Total rows matched.
rows
list[dict]
Log dicts or aggregated dicts.
organization_id
str | None
Echo of the org id.
patient_id
str | None
Null for population queries.

Raises

ExceptionWhen
ValidationErrorUnknown operator (client-side) or HTTP 422 from server.
AuthErrorHTTP 401 or 403 — invalid API key or insufficient OAuth scope for this endpoint.
ServerErrorHTTP 409 (e.g. conflicting external identifier) or repeated 5xx after retries; includes status_code when applicable.
RateLimitErrorHTTP 429 — rate limited; check retry_after (seconds).
NetworkErrorConnection timeout, DNS failure, or read error after retries.
import olira

olira.init(api_key="YOUR_API_KEY")

# Whole org
rows = (
    olira.population_logs()
        .eq("type", "health_metric")
        .order("timestamp", desc=True)
        .limit(50)
        .execute()
)
print(rows.count)

# Explicit cohort + aggregation
agg = (
    olira.population_logs(patient_ids=["8a4fde23-0f1b-4c2a-9d7e-b36c1a5f0e82", "other-patient-id"])
        .group_by("type")
        .count_agg("n")
        .execute()
)
for row in agg:
    print(row["type"], row["n"])
LogQueryResult(
    count=3,
    rows=[
        {"id": "log-a", "type": "health_metric", "timestamp": "2026-01-06T00:00:00Z", "payload": {...}},
        {"id": "log-b", "type": "health_metric", "timestamp": "2026-01-05T00:00:00Z", "payload": {...}},
        {"id": "log-c", "type": "health_metric", "timestamp": "2026-01-01T00:00:00Z", "payload": {...}},
    ],
    patient_id=None,
    organization_id="org-001",
)