Olira Python SDK — event ingestion client for the Olira platform
Project description
Olira Python SDK
Log ingestion, patient management, and patient token client for the Olira platform.
Install
pip install olira
Documentation
Full API reference: https://olira.ai/api-docs (Python SDK tab).
Local copy: SDK_DOCUMENTATION.md.
Authentication
All SDK methods authenticate with an Olira API key (olira_prod_...). Create keys from the Olira Console under Settings → API Keys, selecting the scopes you need:
| Scope | What it unlocks |
|---|---|
sdk:event-log |
Log events |
api:manage-patients |
Create, read, update, delete patients |
sdk:patient-token |
Mint short-lived patient-scoped JWTs |
See API key scopes for the full list.
Pass the key to OliraClient or to olira.init():
import olira
olira.init(api_key="olira_prod_...") # or set OLIRA_API_KEY env var
Patient Management
Patients must exist before you can log events against them. Use the api:manage-patients scope.
Olira assigns a stable id to each patient at creation time. The id returned in the Patient object is what you use in all subsequent calls.
from olira import OliraClient
client = OliraClient(api_key="olira_prod_...")
# Create — Olira assigns the id; store it for future calls
patient = client.create_patient(
first_name="Jane",
last_name="Smith",
timezone="America/New_York",
primary_disease_site="breast",
disease_stage="II",
)
patient_id = patient.id
# Get
patient = client.get_patient(patient_id=patient_id)
# List (paginated, returns PatientListResult)
result = client.list_patients(limit=50, offset=0)
for p in result.patients:
print(p.id, p.first_name, p.last_name)
# Update (only supplied fields are changed)
patient = client.update_patient(patient_id=patient_id, disease_stage="III")
# Soft-delete
client.delete_patient(patient_id=patient_id)
Event Logging
Log a single event in the background (fire-and-forget):
import olira
from olira import OliraLogType
olira.init(api_key="olira_prod_...")
olira.log(
log_type=OliraLogType.USER_LOGIN,
patient_id=patient_id, # id from patient.id
)
olira.flush() # block until delivery
Send a batch directly and get back a result:
from olira import OliraClient, LogSpec, OliraLogType, EsasItem
client = OliraClient(api_key="olira_prod_...")
result = client.log_batch([
LogSpec(log_type=OliraLogType.USER_LOGIN, patient_id=patient_id),
LogSpec(
log_type=OliraLogType.SYMPTOM_REPORT,
patient_id=patient_id,
payload={
"instrument": "esas_r",
"symptoms": [EsasItem(name="pain", score=4).model_dump()],
},
),
])
print(f"accepted={result.accepted}, failed={result.failed}")
client.close()
Patient Token
Mint a short-lived JWT scoped to a single patient. Requires the sdk:patient-token scope.
Use this when a patient device needs to communicate with the Olira MCP Patient State server — pass the token as a Bearer header. The token expires after 15 minutes and is locked to the specified patient.
from olira import OliraClient
client = OliraClient(api_key="olira_prod_...")
token = client.get_patient_token(patient_id=patient_id)
print(token.access_token) # forward this to the patient device
print(token.expires_in) # 900 (seconds)
client.close()
Async client
All methods are available on AsyncOliraClient as coroutines:
import asyncio
from olira import AsyncOliraClient, OliraLogType
async def main():
async with AsyncOliraClient(api_key="olira_prod_...") as client:
patient = await client.create_patient(
first_name="Jane",
last_name="Smith",
)
await client.log(
log_type=OliraLogType.USER_LOGIN,
patient_id=patient.id,
)
asyncio.run(main())
Error handling
from olira import AuthError, ValidationError, RateLimitError, ServerError
try:
client.log_batch([...])
except AuthError:
# Invalid or revoked API key, or missing scope
...
except ValidationError:
# Bad request (400/404/422) — e.g. unknown event type or missing required field
...
except RateLimitError as e:
# Retry after e.retry_after seconds
...
except ServerError:
# Transient server error after all retries exhausted
...
Contributing
Dependencies are public PyPI packages only:
bash scripts/install-dev.sh
./scripts/pre-pr.sh
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file olira-1.0.0.tar.gz.
File metadata
- Download URL: olira-1.0.0.tar.gz
- Upload date:
- Size: 101.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af4ae9da5431a1f1363c17baa2d80c6bd9ea528c26c1501fb47ee6889da85ab0
|
|
| MD5 |
3aa233610f98e9c6e68f501900e585aa
|
|
| BLAKE2b-256 |
f89c2ecaf423b2d0ed518510cfee742210dd53d3505c19c85e789e38ee31c00f
|
Provenance
The following attestation bundles were made for olira-1.0.0.tar.gz:
Publisher:
publish.yml on olira-ai/olira
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
olira-1.0.0.tar.gz -
Subject digest:
af4ae9da5431a1f1363c17baa2d80c6bd9ea528c26c1501fb47ee6889da85ab0 - Sigstore transparency entry: 1584845541
- Sigstore integration time:
-
Permalink:
olira-ai/olira@c0508afda038ad31793e7480a72553f9cd2b7b7c -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/olira-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c0508afda038ad31793e7480a72553f9cd2b7b7c -
Trigger Event:
push
-
Statement type:
File details
Details for the file olira-1.0.0-py3-none-any.whl.
File metadata
- Download URL: olira-1.0.0-py3-none-any.whl
- Upload date:
- Size: 30.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
defecf1833203b91327ad805ff9d2d98395dd54890a0ce54085923b082d60fca
|
|
| MD5 |
f3b0c1f875c79017efc084614535027b
|
|
| BLAKE2b-256 |
458308cc129525f8ac8ab936b1037ba972bcfda1e24292860df8912b73cce5e0
|
Provenance
The following attestation bundles were made for olira-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on olira-ai/olira
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
olira-1.0.0-py3-none-any.whl -
Subject digest:
defecf1833203b91327ad805ff9d2d98395dd54890a0ce54085923b082d60fca - Sigstore transparency entry: 1584845819
- Sigstore integration time:
-
Permalink:
olira-ai/olira@c0508afda038ad31793e7480a72553f9cd2b7b7c -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/olira-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c0508afda038ad31793e7480a72553f9cd2b7b7c -
Trigger Event:
push
-
Statement type: