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.2.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.2.0
File Size Uploaded Provenance
clinikehr-0.2.0.tar.gz 308.4 kB With provenance Details

Built distribution (wheel)

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

Total release size: 1.1 MB

Release files / clinikehr-0.2.0.tar.gz

Download URL clinikehr-0.2.0.tar.gz
Size 308.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1750af7bb6f58ce03acd532e04a8e351a3a31f7eeb2bd88638399684fab2a84b
BLAKE2b-256 checksum
How to use checksums
4ff79738ed04aed16be75b246347feefcf42e4c73464521774333bb48e024e32
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 20, 2026.

Transparency log

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

Download URL clinikehr-0.2.0-py3-none-any.whl
Size 804.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d4239c6733f7552f2086d67e54286d6adfa3e13045e310bc3ec51a011ecd477
BLAKE2b-256 checksum
How to use checksums
549b8071b6d264fecfc35253f6ee64606848e367b824d2f8642dc5385329ff9c
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 20, 2026.

Transparency log

Security for clinikehr 0.2.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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for clinikehr-0.2.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 20, 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.

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