PyPI version Python Support License: MIT
The Kipu Python library provides convenient access to the Kipu API from any Python 3.8+ application. The library includes HMAC SHA1/SHA256 authentication, recursive JSON flattening capabilities and type definitions for most of the request params and response fields, and offers asynchronous clients powered by [asyncio].
It is generated from our KipuAPI V3 specification
- β Complete API Coverage: All 80+ Kipu API V3 endpoints implemented
- π Secure Authentication: HMAC SHA1/SHA256 signature generation
- π Automatic Flattening: Converts nested JSON responses to pandas DataFrames
- β‘ Async Support: Built with asyncio for high performance
- π‘οΈ Error Handling: Comprehensive exception hierarchy
- π Type Hints: Full typing support for better development experience
- π Flexible Response Format: Choose between raw JSON or flattened DataFrames
pip install kipu-python
import asyncio from kipu import KipuClient async def main(): async with KipuClient( access_id="your_access_id", secret_key="your_secret_key", app_id="your_app_id", version=3 ) as client: # Get patient census as flattened DataFrame census_df = await client.get_patients_census() print(f"Found {len(census_df)} patients") # Get specific patient as raw JSON patient_data = await client.get_patient("patient_id", flatten=False) print(f"Patient: {patient_data['first_name']} {patient_data['last_name']}") asyncio.run(main())
The library handles HMAC SHA1 signature generation automatically. You need three credentials from Kipu:
access_id: Your API access identifiersecret_key: Your secret key for signature generationapp_id: Your application ID (also called recipient_id)version: API version (3 for SHA1, 4 for SHA256)
The library supports both Kipu API v3 and v4:
- V3: Uses HMAC-SHA1 authentication (default, most stable)
- V4: Uses HMAC-SHA256 authentication (newer, more secure)
# Use V3 (SHA1) client_v3 = KipuClient(access_id, secret_key, app_id, version=3) # Use V4 (SHA256 - recommended for new integrations) client_v4 = KipuClient(access_id, secret_key, app_id, version=4)
# Get patient census census_df = await client.get_patients_census(params={ "phi_level": "high", "page": 1, "per": 50 }) # Get specific patient patient = await client.get_patient("patient_id") # Create new patient patient_data = { "document": { "recipient_id": app_id, "data": { "first_name": "John", "last_name": "Doe", "dob": "1990-01-01" } } } new_patient = await client.create_patient(patient_data)
# Get vital signs vital_signs_df = await client.get_vital_signs() patient_vitals = await client.get_patient_vital_signs("patient_id") # Get allergies allergies_df = await client.get_allergies() patient_allergies = await client.get_patient_allergies("patient_id") # Create vital signs vital_data = { "document": { "recipient_id": app_id, "data": { "systolic_blood_pressure": 120, "diastolic_blood_pressure": 80, "heart_rate": 72 } } } await client.create_patient_vital_signs("patient_id", vital_data)
# Get appointments appointments_df = await client.get_scheduler_appointments(params={ "start_date": "2024-01-01", "end_date": "2024-12-31" }) # Get patient appointments patient_appointments = await client.get_patient_appointments("patient_id")
# Get locations, users, providers locations_df = await client.get_locations() users_df = await client.get_users() providers_df = await client.get_providers()
# Returns a flattened pandas DataFrame census_df = await client.get_patients_census() print(type(census_df)) # <class 'pandas.core.frame.DataFrame'>
# Returns raw JSON census_data = await client.get_patients_census(flatten=False) print(type(census_data)) # <class 'dict'> or <class 'list'>
# Disable auto-flattening globally async with KipuClient( access_id, secret_key, app_id, version, auto_flatten=False ) as client: raw_data = await client.get_patients_census() # Raw JSON flat_data = await client.get_patients_census(flatten=True) # DataFrame
from kipu.exceptions import ( KipuAPIError, KipuAuthenticationError, KipuValidationError, KipuNotFoundError, KipuServerError ) try: patient = await client.get_patient("invalid_id") except KipuNotFoundError as e: print(f"Patient not found: {e.message}") except KipuAuthenticationError as e: print(f"Authentication failed: {e.message}") except KipuAPIError as e: print(f"API error: {e.message} (Status: {e.status_code})")
# Patient with attachment patient_data = { "document[recipient_id]": app_id, "document[data][first_name]": "John", "document[data][last_name]": "Doe" } files = { "document[attachments_attributes][0][attachment]": { "content": file_bytes, "filename": "patient_id.jpg", "content_type": "image/jpeg" } } await client.create_patient(patient_data, files=files)
- Patients: Census, individual records, admissions, latest updates
- Medical Records: Vital signs, allergies, assessments, glucose logs
- Evaluations: Patient evaluations, evaluation templates
- Appointments: Scheduling, types, statuses, resources
- Users & Providers: User management, provider records, roles
- Administrative: Locations, care levels, flags, settings
- Insurance: Insurance records, verification
- Groups: Group sessions, patient groups
# Patient endpoints client.get_patients_census() client.get_patient(patient_id) client.create_patient(data) client.update_patient(patient_id, data) client.get_patients_admissions() client.get_patients_latest() # Medical records client.get_vital_signs() client.get_patient_vital_signs(patient_id) client.create_patient_vital_signs(patient_id, data) client.get_allergies() client.get_patient_allergies(patient_id) client.get_cows() client.get_ciwa_ars() client.get_glucose_logs() # And 70+ more endpoints...
# Clone and install git clone [https://github.com/Rahulkumar010/kipu-python.git](https://github.com/Rahulkumar010/kipu-python.git) cd kipu-python # Traditional pip install -e ".[dev]" # Fast with UV (10x faster!) pip install uv && uv pip install -e ".[dev]" make test # Run tests make format # Format code make lint # Check quality make version # Show version make bump-patch # Bump version
- Python: 3.8+
- Dependencies:
aiohttp>=3.8.0- Async HTTP clientpandas>=1.3.0- Data manipulationnumpy>=1.20.0- Numerical computingtqdm>=4.60.0- Progress bars
Welcome contributions! Here's the quick process:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes and add tests
- Run quality checks:
make lintandmake test - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
For detailed guidelines, see CONTRIBUTING.md
For faster development, use UV: See UV_GUIDE.md
This project is licensed under the MIT License - see the LICENSE file for details.
- Documentation: Read the Docs
- Issues: GitHub Issues
- Email: rahul01110100@gmail.com
This library is designed for healthcare applications. Ensure your implementation complies with:
- HIPAA (Health Insurance Portability and Accountability Act)
- Local healthcare data protection regulations
- Kipu's terms of service and security requirements
Built with β€οΈ for the opensource community