Skip to main content

Official Python SDK for the WioClinic Developer API

Project description

WioClinic Python SDK

Official Python SDK for the WioClinic Developer API.

PyPI version Python Versions License: MIT

Requirements

  • Python 3.9+
  • httpx ≥ 0.25

Installation

pip install wioclinic

Authentication

Generate an API key from the WioClinic Developer Portal (Settings → API Keys). You will receive:

  • Key ID — starts with pk_live_ (public, safe to log)
  • Secret — starts with wcs_live_ (treat like a password)

Quick Start

from wioclinic import WioClinic

client = WioClinic(
    key_id="pk_live_your_key_id",
    secret="wcs_live_your_secret",
)

# List patients
page = client.patients.list(limit=10)
print(f"Found {page.total} patients")
for patient in page:
    print(patient["full_name"])

# Get a single patient
patient = client.patients.get("patient-uuid")

# Create a patient
new_patient = client.patients.create(
    first_name="Jane",
    last_name="Smith",
    date_of_birth="1985-06-15",
    gender="female",
    phone_number="+14155550100",
    email_address="jane.smith@example.com",
)

Patients

# List with filters
page = client.patients.list(
    page=1,
    limit=20,
    search="smith",      # Searches name, phone, email, national ID
    is_active=True,
)

# CRUD
patient = client.patients.get(patient_id)
patient = client.patients.create(first_name="Jane", last_name="Smith")
patient = client.patients.update(patient_id, phone_number="+14155550199")
client.patients.deactivate(patient_id)

Appointments

# List appointments (date range max 31 days)
page = client.appointments.list(
    date_from="2026-06-01",
    date_to="2026-06-30",
    patient_id="patient-uuid",   # optional
    status="scheduled",          # optional
)

# Get / create / update
appt = client.appointments.get(appointment_id)
appt = client.appointments.create(
    patient_id="patient-uuid",
    doctor_id="doctor-uuid",
    appointment_date="2026-07-01",
    start_time="10:00",
    end_time="10:30",
)
appt = client.appointments.update(appointment_id, start_time="11:00")

# Lifecycle transitions
client.appointments.confirm(appointment_id)
client.appointments.check_in(appointment_id)
client.appointments.complete(appointment_id)
client.appointments.cancel(appointment_id, reason="Patient request")
client.appointments.no_show(appointment_id)

Availability

result = client.availability.check(
    doctor_id="doctor-uuid",
    date="2026-07-01",
    duration=30,   # minutes, optional
)

for slot in result["available_slots"]:
    print(slot["start"], "–", slot["end"])

Clinic

clinic      = client.clinic.get()
doctors     = client.clinic.doctors()
depts       = client.clinic.departments()
rooms       = client.clinic.rooms()
treatments  = client.clinic.treatments()
price_lists = client.clinic.price_lists()

Finance

# Invoices
page    = client.finance.list_invoices(status="paid", from_date="2026-01-01")
invoice = client.finance.get_invoice(invoice_id)
pmts    = client.finance.invoice_payments(invoice_id)

# Payments
page = client.finance.list_payments(from_date="2026-01-01", to_date="2026-12-31")

# Shortcuts: client.invoices / client.payments also work
page = client.invoices.list_invoices(limit=5)

Messages (SMS / Email)

# Send SMS
client.messages.send(
    patient_id="patient-uuid",
    channel="sms",
    message="Your appointment is tomorrow at 10:00.",
)

# Send email
client.messages.send(
    patient_id="patient-uuid",
    channel="email",
    subject="Appointment Reminder",
    message="<p>Your appointment is tomorrow at 10:00.</p>",
)

# List sent messages
page = client.messages.list(channel="sms")

Webhooks

# List webhooks
hooks = client.webhooks.list()

# Create
hook = client.webhooks.create(
    target_url="https://example.com/wio-events",
    subscribed_events=["appointment.created", "patient.created"],
    signing_secret="my-hmac-secret",
)

# Update
client.webhooks.update(hook["id"], subscribed_events=["appointment.cancelled"])

# Test connectivity
client.webhooks.test(hook["id"])

# View recent deliveries
deliveries = client.webhooks.deliveries(hook["id"])

# Replay a failed delivery
client.webhooks.replay_delivery(hook["id"], delivery_id)

# Delete
client.webhooks.delete(hook["id"])

Pagination

List methods return a Page object:

page = client.patients.list(page=1, limit=20)

page.data        # list of result dicts
page.total       # total record count
page.page        # current page number
page.limit       # records per page
page.has_more    # True if there are additional pages

# Iterate directly
for patient in page:
    print(patient["full_name"])

# Fetch all pages manually
all_patients = []
p = 1
while True:
    page = client.patients.list(page=p, limit=100)
    all_patients.extend(page.data)
    if not page.has_more:
        break
    p += 1

Error Handling

from wioclinic import (
    WioClinicError,           # base class
    AuthenticationError,      # 401 — bad key/secret
    PermissionDeniedError,    # 403
    NotFoundError,            # 404
    UnprocessableEntityError, # 422 — validation errors
    RateLimitError,           # 429
    InternalServerError,      # 5xx
    APIConnectionError,       # network issues
)

try:
    patient = client.patients.get("some-id")
except NotFoundError as e:
    print(f"Patient not found (request_id={e.request_id})")
except AuthenticationError:
    print("Check your API key and secret")
except WioClinicError as e:
    print(f"API error {e.status_code}: {e.message}")

Advanced: Custom HTTP Client

Pass a custom httpx.Client for proxy support, custom TLS, etc.:

import httpx
from wioclinic import WioClinic

transport = httpx.HTTPTransport(proxy="http://my-proxy:8080")
http = httpx.Client(transport=transport, timeout=60)

client = WioClinic(key_id="pk_live_your_key_id", secret="wcs_live_your_secret", http_client=http)

Context Manager

with WioClinic(key_id="pk_live_your_key_id", secret="wcs_live_your_secret") as client:
    doctors = client.clinic.doctors()
# connection pool is automatically closed

Supported Events (Webhooks)

Event Triggered when
appointment.created New appointment is booked
appointment.updated Appointment details change
appointment.cancelled Appointment is cancelled
appointment.completed Appointment is marked complete
patient.created New patient is registered
patient.updated Patient profile is updated
invoice.created Invoice is generated
invoice.paid Invoice is fully paid
payment.received Payment transaction recorded

Support

License

MIT

Project details


Download files

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

Source Distribution

wioclinic-0.1.1.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

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

wioclinic-0.1.1-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file wioclinic-0.1.1.tar.gz.

File metadata

  • Download URL: wioclinic-0.1.1.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for wioclinic-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8a3fe76bbb3aeeb30afb7074e6e90d65eb4cfa0574690be2aae40c1e555b36c8
MD5 b5ffa255f8efdea189c02f56fafcda03
BLAKE2b-256 9edd83971b25e038e297208b9b2650f61364f1d8599674a75cba6477ddf87c93

See more details on using hashes here.

File details

Details for the file wioclinic-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: wioclinic-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for wioclinic-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f4089349b28c3c90eaa3bb50b2ccd0a166dd0acc2cd32087afddfcb1303f6300
MD5 fedb280a005c4dc2699a6ceba9246b67
BLAKE2b-256 09e7e36c1bee43c95b2cb5cfdb8a0b63b4896ba3e9b40494dd3e001179353e99

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page