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 typedhttpx+attrsclient for every operation and schema in the ClinikEHR API description, produced byopenapi-python-client. - Hand-written, small, and tested (
src/clinikehr/*.py,tests/): authentication, automaticIdempotency-Keygeneration and reuse across retries, the retry policy, cursor pagination, typed errors, the FHIRAcceptopt-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, 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 gets one automatically, generated once and
reused across retries — never regenerated); PATCH is never auto-retried on a
5xx, because this API gives it no Idempotency-Key and a stale If-Match on
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.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| clinikehr-0.1.0.tar.gz | 293.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| clinikehr-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.1 MB
Release files / clinikehr-0.1.0.tar.gz
| Download URL | clinikehr-0.1.0.tar.gz |
|---|---|
| Size | 293.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
27442c60f0eeb2b0e4d340305a016418c6d02593b7ef9738c8001f61bd8144dc
|
|
BLAKE2b-256 checksum How to use checksums |
9b0873fc42ee12951bd4ede2965bf225b70fa4bf242ff06ac5e1c329dfe93eeb
|
| 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 logRelease files / clinikehr-0.1.0-py3-none-any.whl
| Download URL | clinikehr-0.1.0-py3-none-any.whl |
|---|---|
| Size | 763.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4231b2d47ae717ff0a68018655456e26725147b5a411fd0398d3a394e8d2186b
|
|
BLAKE2b-256 checksum How to use checksums |
8ea114981769351c5e1fe5adaa1cd757df23820f759f37ef8647b0648ba0eb45
|
| 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