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.1.1

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.1.1
File Size Uploaded
clinikehr-0.1.1.tar.gz 294.6 kB Details

Built distribution (wheel)

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

Total release size: 1.1 MB

Release files / clinikehr-0.1.1.tar.gz

Download URL clinikehr-0.1.1.tar.gz
Size 294.6 kB
Tags Source
SHA-256 checksum
How to use checksums
164c5a62843ece6ce81d36c3f496aa5a9bfa5f9a904b86510fe7a29af8cc048f
BLAKE2b-256 checksum
How to use checksums
e24edcee0f23ba48f8a60a64b137dc5c304d41c635e7337d3836a29a5ab4a43a
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 13, 2026.

Transparency log

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

Download URL clinikehr-0.1.1-py3-none-any.whl
Size 763.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
03adc249c5ce4caabdde061ac86f0fe0b61a597c807b9ac6850012e24f5fe6e3
BLAKE2b-256 checksum
How to use checksums
8854e754199d66a14b8cf4d5d9f11806153c676cc0c251a931b7fc43e59ea4c5
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 13, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

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