# Eka Care SDK for Python
A comprehensive Python SDK for interacting with the Eka Care APIs.
## Installation
```bash
pip install ekacare
```
## Features
The SDK provides easy access to the following Eka Care APIs:
- Authentication
- Records Management (upload, list, update, delete)
- ABDM Connect (profile, consents, care contexts)
- Appointment Management
- Doctor & Clinic Management
- Patient Management
- Webhooks (register, manage, verify)
- Vitals (update patient vitals)
- Medical Document Parsing
- Assessment APIs
- Notifications
- Privacy Management
## Quick Start
### Authentication
```python
from ekacare import EkaCareClient
# Initialize with client credentials
client = EkaCareClient(
client_id="your_client_id",
client_secret="your_client_secret"
)
# Or initialize with an existing access token
client = EkaCareClient(
access_token="your_access_token"
)
# Manually get an access token
token_response = client.auth.login()
access_token = token_response["access_token"]
```
### Records Management
```python
# Upload a document
response = client.records.upload_document(
file_path="/path/to/lab_report.pdf",
document_type="lr", # lab report
tags=["covid", "test"],
title="COVID-19 Test Report"
)
document_id = response["document_id"]
# List documents
documents = client.records.list_documents()
for doc in documents.get("items", []):
print(doc["record"]["item"]["document_id"])
# Get a specific document
document = client.records.get_document(document_id)
# Update a document
client.records.update_document(
document_id=document_id,
document_type="ps", # prescription
tags=["medication"]
)
# Delete a document
client.records.delete_document(document_id)
# Retrieve health records in FHIR format
records = client.records.retrieve_health_records(
identifier="care_context_123",
hip_id="hip123",
health_id="user@abdm"
)
```
### Vitals Management
```python
# Create vital records
heart_rate = client.vitals.create_heart_rate_vital(
value=75,
measured_at="2023-01-01T12:00:00"
)
blood_glucose = client.vitals.create_blood_glucose_vital(
value=120,
measured_at="2023-01-01T08:00:00",
glucose_type="fasting"
)
blood_oxygen = client.vitals.create_blood_oxygen_vital(
value=98,
measured_at="2023-01-01T12:30:00"
)
blood_pressure = client.vitals.create_blood_pressure_vital(
systolic=120,
diastolic=80,
measured_at="2023-01-01T14:45:00"
)
# Update patient vitals
client.vitals.update_vitals(
txn_id="transaction_id",
vitals_data=[heart_rate, blood_glucose, blood_oxygen] + blood_pressure
)
```
### Webhooks
```python
# Register a webhook
response = client.webhooks.register_webhook(
endpoint="https://your-app.com/webhook",
scopes=["appointment.created", "prescription.created"],
signing_key="your_secret_key"
)
webhook_id = response["id"]
# Get all webhooks
webhooks = client.webhooks.get_webhooks()
# Update a webhook's signing key
client.webhooks.update_webhook(
webhook_id=webhook_id,
signing_key="new_secret_key"
)
# Delete a webhook
client.webhooks.delete_webhook(webhook_id)
# Verify a webhook signature
is_valid = client.webhooks.verify_signature(
payload=webhook_payload,
signature=webhook_signature,
secret_key="your_secret_key"
)
```
### Appointment Management
```python
# Get Appointment Details
response = client.appointments.get_appointment_details("YOUR_APPOINTMENT_ID")
```
### Doctor & Clinic Management
```python
# Get Clinic Details
response = client.clinic_doctor.get_clinic_details("YOUR_CLINIC_ID")
# Get Doctor Details
response = client.clinic_doctor.get_doctor_details("YOUR_DOCTOR_ID")
```
### Appointment Management
```python
# Get Appointment Details
response = client.appointments.get_appointment_details("YOUR_APPOINTMENT_ID")
```
### Patient Details
```python
# Get Patient Details
response = client.patient.get_patient("YOUR_PATIENT_ID")
```
### ABDM Profile Management
```python
# Get ABHA profile
profile = client.abdm_profile.get_profile()
print(profile["abha_address"])
# Update profile
client.abdm_profile.update_profile({
"address": "123 Main St",
"pincode": "110001"
})
# Get ABHA card
card_image = client.abdm_profile.get_abha_card()
with open("abha_card.png", "wb") as f:
f.write(card_image)
# Get QR code data
qr_data = client.abdm_profile.get_abha_qr_code()
# Initiate KYC
response = client.abdm_profile.initiate_kyc(
method="abha-number",
identifier="1234-5678-9012"
)
txn_id = response["txn_id"]
# Verify KYC OTP
client.abdm_profile.verify_kyc_otp(
txn_id=txn_id,
otp="123456"
)
```
## Error Handling
The SDK uses custom exceptions to handle errors:
```python
from ekacare import EkaCareClient, EkaCareAPIError, EkaCareAuthError
client = EkaCareClient(
client_id="your_client_id",
client_secret="your_client_secret"
)
try:
documents = client.records.list_documents()
except EkaCareAuthError as e:
print(f"Authentication error: {e}")
except EkaCareAPIError as e:
print(f"API error: {e}")
```
## License
This SDK is distributed under the MIT License.
Raw data
{
"_id": null,
"home_page": "https://developer.eka.care",
"name": "ekacare",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "healthcare, eka care, api, sdk, health records, abdm",
"author": "Eka Care SDK Developer",
"author_email": "developer@eka.care",
"download_url": "https://files.pythonhosted.org/packages/1d/74/23da708e555b75b732b8eeb56b093e31e6e5ea7005fd7bff16ef5d745834/ekacare-0.1.2.tar.gz",
"platform": null,
"description": "# Eka Care SDK for Python\n\nA comprehensive Python SDK for interacting with the Eka Care APIs.\n\n## Installation\n\n```bash\npip install ekacare\n```\n\n## Features\n\nThe SDK provides easy access to the following Eka Care APIs:\n\n- Authentication\n- Records Management (upload, list, update, delete)\n- ABDM Connect (profile, consents, care contexts)\n- Appointment Management\n- Doctor & Clinic Management\n- Patient Management\n- Webhooks (register, manage, verify)\n- Vitals (update patient vitals)\n- Medical Document Parsing\n- Assessment APIs\n- Notifications\n- Privacy Management\n\n## Quick Start\n\n### Authentication\n\n```python\nfrom ekacare import EkaCareClient\n\n# Initialize with client credentials\nclient = EkaCareClient(\n client_id=\"your_client_id\",\n client_secret=\"your_client_secret\"\n)\n\n# Or initialize with an existing access token\nclient = EkaCareClient(\n access_token=\"your_access_token\"\n)\n\n# Manually get an access token\ntoken_response = client.auth.login()\naccess_token = token_response[\"access_token\"]\n```\n\n### Records Management\n\n```python\n# Upload a document\nresponse = client.records.upload_document(\n file_path=\"/path/to/lab_report.pdf\",\n document_type=\"lr\", # lab report\n tags=[\"covid\", \"test\"],\n title=\"COVID-19 Test Report\"\n)\ndocument_id = response[\"document_id\"]\n\n# List documents\ndocuments = client.records.list_documents()\nfor doc in documents.get(\"items\", []):\n print(doc[\"record\"][\"item\"][\"document_id\"])\n\n# Get a specific document\ndocument = client.records.get_document(document_id)\n\n# Update a document\nclient.records.update_document(\n document_id=document_id,\n document_type=\"ps\", # prescription\n tags=[\"medication\"]\n)\n\n# Delete a document\nclient.records.delete_document(document_id)\n\n# Retrieve health records in FHIR format\nrecords = client.records.retrieve_health_records(\n identifier=\"care_context_123\",\n hip_id=\"hip123\",\n health_id=\"user@abdm\"\n)\n```\n\n### Vitals Management\n\n```python\n# Create vital records\nheart_rate = client.vitals.create_heart_rate_vital(\n value=75,\n measured_at=\"2023-01-01T12:00:00\"\n)\n\nblood_glucose = client.vitals.create_blood_glucose_vital(\n value=120,\n measured_at=\"2023-01-01T08:00:00\",\n glucose_type=\"fasting\"\n)\n\nblood_oxygen = client.vitals.create_blood_oxygen_vital(\n value=98,\n measured_at=\"2023-01-01T12:30:00\"\n)\n\nblood_pressure = client.vitals.create_blood_pressure_vital(\n systolic=120,\n diastolic=80,\n measured_at=\"2023-01-01T14:45:00\"\n)\n\n# Update patient vitals\nclient.vitals.update_vitals(\n txn_id=\"transaction_id\",\n vitals_data=[heart_rate, blood_glucose, blood_oxygen] + blood_pressure\n)\n```\n\n### Webhooks\n\n```python\n# Register a webhook\nresponse = client.webhooks.register_webhook(\n endpoint=\"https://your-app.com/webhook\",\n scopes=[\"appointment.created\", \"prescription.created\"],\n signing_key=\"your_secret_key\"\n)\nwebhook_id = response[\"id\"]\n\n# Get all webhooks\nwebhooks = client.webhooks.get_webhooks()\n\n# Update a webhook's signing key\nclient.webhooks.update_webhook(\n webhook_id=webhook_id,\n signing_key=\"new_secret_key\"\n)\n\n# Delete a webhook\nclient.webhooks.delete_webhook(webhook_id)\n\n# Verify a webhook signature\nis_valid = client.webhooks.verify_signature(\n payload=webhook_payload,\n signature=webhook_signature,\n secret_key=\"your_secret_key\"\n)\n```\n\n### Appointment Management\n\n```python\n# Get Appointment Details\nresponse = client.appointments.get_appointment_details(\"YOUR_APPOINTMENT_ID\")\n\n```\n\n\n### Doctor & Clinic Management\n\n```python\n# Get Clinic Details\nresponse = client.clinic_doctor.get_clinic_details(\"YOUR_CLINIC_ID\")\n\n\n# Get Doctor Details\nresponse = client.clinic_doctor.get_doctor_details(\"YOUR_DOCTOR_ID\")\n\n```\n\n### Appointment Management\n\n```python\n# Get Appointment Details\nresponse = client.appointments.get_appointment_details(\"YOUR_APPOINTMENT_ID\")\n\n```\n\n### Patient Details\n\n```python\n# Get Patient Details\nresponse = client.patient.get_patient(\"YOUR_PATIENT_ID\")\n\n```\n\n\n\n### ABDM Profile Management\n\n```python\n# Get ABHA profile\nprofile = client.abdm_profile.get_profile()\nprint(profile[\"abha_address\"])\n\n# Update profile\nclient.abdm_profile.update_profile({\n \"address\": \"123 Main St\",\n \"pincode\": \"110001\"\n})\n\n# Get ABHA card\ncard_image = client.abdm_profile.get_abha_card()\nwith open(\"abha_card.png\", \"wb\") as f:\n f.write(card_image)\n\n# Get QR code data\nqr_data = client.abdm_profile.get_abha_qr_code()\n\n# Initiate KYC\nresponse = client.abdm_profile.initiate_kyc(\n method=\"abha-number\",\n identifier=\"1234-5678-9012\"\n)\ntxn_id = response[\"txn_id\"]\n\n# Verify KYC OTP\nclient.abdm_profile.verify_kyc_otp(\n txn_id=txn_id,\n otp=\"123456\"\n)\n```\n\n## Error Handling\n\nThe SDK uses custom exceptions to handle errors:\n\n```python\nfrom ekacare import EkaCareClient, EkaCareAPIError, EkaCareAuthError\n\nclient = EkaCareClient(\n client_id=\"your_client_id\",\n client_secret=\"your_client_secret\"\n)\n\ntry:\n documents = client.records.list_documents()\nexcept EkaCareAuthError as e:\n print(f\"Authentication error: {e}\")\nexcept EkaCareAPIError as e:\n print(f\"API error: {e}\")\n```\n\n## License\n\nThis SDK is distributed under the MIT License.\n",
"bugtrack_url": null,
"license": null,
"summary": "Python SDK for Eka Care APIs",
"version": "0.1.2",
"project_urls": {
"Homepage": "https://developer.eka.care"
},
"split_keywords": [
"healthcare",
" eka care",
" api",
" sdk",
" health records",
" abdm"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "f8cabdb706d8d2624f7a301c1b2bb3e9c4c7d82bed62ca8ef3da4f67ce50fa15",
"md5": "e05cd9e798fcc1f52f032513c89854ab",
"sha256": "f65c4439eae7c15311d6c892e7c4282a11248a641dcf48249b53283773a0af42"
},
"downloads": -1,
"filename": "ekacare-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e05cd9e798fcc1f52f032513c89854ab",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 23923,
"upload_time": "2025-08-28T11:52:48",
"upload_time_iso_8601": "2025-08-28T11:52:48.047347Z",
"url": "https://files.pythonhosted.org/packages/f8/ca/bdb706d8d2624f7a301c1b2bb3e9c4c7d82bed62ca8ef3da4f67ce50fa15/ekacare-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "1d7423da708e555b75b732b8eeb56b093e31e6e5ea7005fd7bff16ef5d745834",
"md5": "a43cd9b375b09b4693631b7d93205e7d",
"sha256": "f071a3a558db9b965cf86b4fd270866c5512dc2e1eb7be39559c4261e9ed50af"
},
"downloads": -1,
"filename": "ekacare-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "a43cd9b375b09b4693631b7d93205e7d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 19408,
"upload_time": "2025-08-28T11:52:49",
"upload_time_iso_8601": "2025-08-28T11:52:49.284318Z",
"url": "https://files.pythonhosted.org/packages/1d/74/23da708e555b75b732b8eeb56b093e31e6e5ea7005fd7bff16ef5d745834/ekacare-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-28 11:52:49",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "ekacare"
}