Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Heyrafiki Python SDK

Typed Python client for the Heyrafiki API.

What this SDK is for

Use this SDK to call the Heyrafiki API from a Python service. It provides typed sync and async requests, predictable errors and idempotency support for retried writes. The platform applies access rules; clinical and financial decisions remain with the accountable people and organizations.

Install from source

Python 3.10 or newer is required. Keep API keys on the server.

git clone https://github.com/heyrafiki/rafiki-py.git
cd rafiki-py
python -m pip install -e .

The client connects to Sandbox projects with typed sync and async operations, idempotency keys you control, bounded retries and consistent API errors.

First request

import os

from heyrafiki import create_client, unwrap
from heyrafiki.api.default import list_practitioners


with create_client(os.environ["HEYRAFIKI_API_KEY"]) as client:
    response = list_practitioners.sync_detailed(client=client, limit=5)
    practitioners = unwrap(response)

for practitioner in practitioners.data:
    print(practitioner.name)

Sandbox keys return synthetic data.

Covered Care

Writes that require idempotency expose idempotency_key as a required argument.

import datetime as dt
import os
import uuid

from heyrafiki import create_client, unwrap
from heyrafiki.api.default import create_booking
from heyrafiki.models import BookingInput


starts_at = dt.datetime.now(dt.timezone.utc) + dt.timedelta(days=1)
ends_at = starts_at + dt.timedelta(hours=1)

booking = BookingInput(
    practitioner_id="prc_2481",
    starts_at=starts_at,
    ends_at=ends_at,
    format_="online",
    payment_source="covered",
)

with create_client(os.environ["HEYRAFIKI_API_KEY"]) as client:
    response = create_booking.sync_detailed(
        client=client,
        body=booking,
        idempotency_key=str(uuid.uuid4()),
    )
    created = unwrap(response)

Amounts use the currency's minor unit.

Claim valuation

Reproduce historical claim valuation state and financial amounts at an explicit point in business and knowledge time:

import datetime as dt
import os

from heyrafiki import create_client, unwrap
from heyrafiki.api.default import get_claim_valuation


cutoff = dt.datetime(2026, 8, 28, 10, 0, 0, tzinfo=dt.timezone.utc)

with create_client(os.environ["HEYRAFIKI_API_KEY"]) as client:
    response = get_claim_valuation.sync_detailed(
        claim_id="clm_1001",
        client=client,
        valuation_at=cutoff,
    )
    valuation = unwrap(response)

print(valuation.status, valuation.amount.billed, valuation.amount.settled)

Errors and retries

unwrap raises HeyrafikiApiError for documented API errors and retains the request ID.

from heyrafiki import HeyrafikiApiError

try:
    created = unwrap(response)
except HeyrafikiApiError as error:
    print(error.status_code, error.code, error.request_id)

The default retry policy is bounded to three attempts. It retries 429 and 503 responses for safe reads and for writes carrying an Idempotency-Key. Unkeyed writes are never retried automatically.

Sync and async

Every generated operation provides sync, sync_detailed, asyncio and asyncio_detailed functions. Use the detailed variants with unwrap when you want consistent error handling.

Contract

The client is generated from the public OpenAPI 3.1 contract. GENERATION.md records the contract revision, SHA-256 digest, generator version and the reviewed compatibility transform.

Develop

python -m pip install -e ".[dev]"
ruff check .
ruff format --check .
mypy
pytest
python -m build
python -m twine check dist/*

Contract generation requires Python 3.11 or newer. See GENERATION.md.

Resources

License

Licensed under the Apache License 2.0.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

heyrafiki-0.1.0b2.tar.gz (57.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

heyrafiki-0.1.0b2-py3-none-any.whl (126.5 kB view details)

Uploaded Python 3

File details

Details for the file heyrafiki-0.1.0b2.tar.gz.

File metadata

  • Download URL: heyrafiki-0.1.0b2.tar.gz
  • Upload date:
  • Size: 57.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for heyrafiki-0.1.0b2.tar.gz
Algorithm Hash digest
SHA256 2f1b4aa03412cb8a280f785d094af0b8d69279b65bcbfa5779347b0b413ca9cc
MD5 e46e07714096e48f8c705cf5c7b5946e
BLAKE2b-256 529588c75a0a77f37f92980f514ca4f9be8e0736b00871e958270e5b55bf8cb8

See more details on using hashes here.

Provenance

The following attestation bundles were made for heyrafiki-0.1.0b2.tar.gz:

Publisher: release.yml on heyrafiki/rafiki-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file heyrafiki-0.1.0b2-py3-none-any.whl.

File metadata

  • Download URL: heyrafiki-0.1.0b2-py3-none-any.whl
  • Upload date:
  • Size: 126.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for heyrafiki-0.1.0b2-py3-none-any.whl
Algorithm Hash digest
SHA256 fdc1673f51be95e7be52f200cccbdf7e77181d2e3da175d5fb4c5384a26dcd1d
MD5 5a7f5573122b94fa521019a9d1bdb460
BLAKE2b-256 fedc7a739b8e8361d411f60d439ec31dc71dee5206d4ed08668a2f87522625d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for heyrafiki-0.1.0b2-py3-none-any.whl:

Publisher: release.yml on heyrafiki/rafiki-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0b2 This release

2 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