Skip to main content

clinikehr

Official Python client for the ClinikEHR API — a server-to-server REST API over a clinic's own inventory, appointments, CRM and patient data, reached with an API key.

Base URL: https://api.clinikehr.com/v1

What's generated, what's hand-written

  • Generated, never hand-edited: src/clinikehr/_generated/ — a typed httpx + attrs client for every operation and schema in the ClinikEHR API description, produced by openapi-python-client.
  • Hand-written, small, and tested (src/clinikehr/*.py, tests/): authentication, automatic Idempotency-Key generation and reuse across retries, the retry policy, cursor pagination, typed errors, the FHIR Accept opt-in and the webhook signature verifier.

Keep your live key on the server. A live key (ehr_live_…) must never ship in code that runs on an end user's device. Python has no browser guard the way the TypeScript SDK does, so that discipline is yours.

Install

pip install clinikehr

Requires Python 3.11 or later.

Quickstart

import os

import clinikehr
from clinikehr._generated.api.me import get_me
from clinikehr._generated.api.inventory import list_inventory_items

client = clinikehr.create_client(os.environ["CLINIKEHR_API_KEY"])  # ehr_test_… for the sandbox

me = clinikehr.raise_for_response(get_me.sync_detailed(client=client))
print(me)

items = clinikehr.raise_for_response(
    list_inventory_items.sync_detailed(client=client, clinic_id="YOUR_CLINIC_ID", limit=25)
)
print(items)

Async

async_response = await list_inventory_items.asyncio_detailed(client=client, clinic_id="YOUR_CLINIC_ID")
items = clinikehr.raise_for_response(async_response)

Error handling

raise_for_response() raises ClinikEHRApiError — built from the API's application/problem+json body — for any non-2xx response:

from clinikehr import ClinikEHRApiError

try:
    clinikehr.raise_for_response(get_patient.sync_detailed(client=client, clinic_id=clinic_id, patient_id=patient_id))
except ClinikEHRApiError as err:
    print(err.status, err.code, err.request_id, err.detail)
    if err.code == "rate_limited":
        ...  # err.retry_after_seconds is set from the Retry-After header

A network-level failure (no response at all) raises httpx's own exception (httpx.ConnectError, httpx.TimeoutException, …) after this SDK's own retry policy has exhausted its attempts — the retry rule is identical to the TypeScript SDK's: a 429 always retries (honouring Retry-After); a 5xx or a transport failure retries only for a GET/HEAD, or a request that carried an Idempotency-Key (every POST and PATCH gets one automatically when you set none, generated once and reused across retries — never regenerated; several PATCH routes require one). PATCH is still never auto-retried on a 5xx: a stale If-Match on a retry is a different, correct 412.

Pagination

from clinikehr import CursorPage, paginate

def fetch_page(cursor):
    resp = clinikehr.raise_for_response(
        list_inventory_items.sync_detailed(client=client, clinic_id=clinic_id, starting_after=cursor)
    )
    return CursorPage(data=resp.data, has_more=resp.has_more, next_cursor=resp.next_cursor)

for item in paginate(fetch_page):
    print(item)

FHIR

client = clinikehr.create_client(api_key, fhir=True)  # every call now sends Accept: application/fhir+json

Verifying a webhook notification

from clinikehr import verify_webhook, WebhookVerificationError

try:
    verify_webhook(
        {"webhook-id": request.headers["webhook-id"], "webhook-timestamp": request.headers["webhook-timestamp"], "webhook-signature": request.headers["webhook-signature"]},
        raw_body,  # the RAW request body, before json.loads
        secrets=[os.environ["CLINIKEHR_WEBHOOK_SECRET"]],  # pass BOTH secrets during a rotation's overlap window
    )
except WebhookVerificationError:
    ...  # reject the delivery

Development

python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest

License

MIT, Copyright (c) 2026-present Bettar Platforms, Inc. See LICENSE.

© Bettar Platforms, Inc. ClinikEHR is a product of Bettar Platforms, Inc.

How this repository works

This code is generated from ClinikEHR's API description and published from a private source. Issues are welcome here. Pull requests cannot be merged directly, because every change is made in the private source and mirrored here: describe the change you need in an issue and we will make it there.

Questions about the API itself belong at docs.clinikehr.com; to report a vulnerability, see SECURITY.md.

Metadata

Release files for clinikehr 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for clinikehr 0.3.0
File Size Uploaded Provenance Actions
clinikehr-0.3.0.tar.gz 309.9 kB With provenance Details for clinikehr-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for clinikehr 0.3.0
File Interpreter ABI Platform Actions
clinikehr-0.3.0-py3-none-any.whl Python 3 none any Details for clinikehr-0.3.0-py3-none-any.whl

Total release size: 1.1 MB

Release files / clinikehr-0.3.0.tar.gz

Download URL clinikehr-0.3.0.tar.gz
Size 309.9 kB
Tags Source
SHA-256 checksum
How to use checksums
19f62e55e86b9aff7ab601f5504263ff5a4930d6950843e5009ae16380b7674c
BLAKE2b-256 checksum
How to use checksums
deab24525c27750f9f6ac5c90d4aceb2b9f34e78b2cb796988bca8a7671583b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Release files / clinikehr-0.3.0-py3-none-any.whl

Download URL clinikehr-0.3.0-py3-none-any.whl
Size 805.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c96a3eebb8ab33d165e71e2cddd5aa06d50456b832009e03d0240bd0a230f31f
BLAKE2b-256 checksum
How to use checksums
0a16e306bb0ffea52e61084a8837dad667fd017091efce092b7356ac5e67b038
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Security for clinikehr 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for clinikehr-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page