Quickstart
Quickstart
Get started with Leyr API in minutes. This guide walks you through common integration scenarios with complete, working code examples in Python and JavaScript.
What You'll Learn
By following these quickstart guides, you'll learn how to:
- Find an existing patient - Lookup patients by demographics and retrieve patient details
- Create a new patient - Register or upsert patient records in an EHR
- Show doctor's availability - Discover care units, resources, and available timeslots
- Book appointments - Create appointments for patients
- Write medical notes - Document clinical information
- Attach documents - Upload files to patient records
Prerequisites
Before you start, you'll need:
1. Create a Leyr Account
Sign up for a free sandbox account to test the API.
Create Account2. Register Your Application
Create a developer application to get your Client ID and Client Secret.
3. Configure an EHR
Connect to an EHR system and get your credentials. For testing, you can use Leyr's test credentials.
Configure EHR4. Authentication Headers
All API requests require these headers:
import requests
# Your credentials from Leyr Developer Portal
CLIENT_ID = "your-client-id"
CLIENT_SECRET = "your-client-secret"
# Base URL for Leyr API
BASE_URL = "https://api.leyr.io/api"
# Headers for all requests
headers = {
"x-leyr-client-id": CLIENT_ID,
"x-leyr-client-secret": CLIENT_SECRET,
"Content-Type": "application/json"
}
# Example: Get list of supported EHRs
response = requests.get(f"{BASE_URL}/emrs", headers=headers)
emrs = response.json()
print(f"Available EHRs: {len(emrs)}")
Use Cases
Choose a use case to get started:
Find or Get Patient
Recommended Order
Use this order to avoid missing required IDs:
- Start with Show Doctor's Availability to get
care_unit_id(step 1), and discoverresource_id,healthcare_service_id, andtimeslots. - Use Find or Get Patient or Create Patient to get a valid
patient_id. - Continue with:
- Book an Appointment using
care_unit_id+timeslot+patient_id - Write a Medical Note using
care_unit_id+resource_id+patient_id - Attach a Document using
care_unit_id+resource_id+patient_id
- Book an Appointment using
Next Steps
After completing these quickstarts, explore:
- API Guides - Advanced topics and best practices
- Test Data - Sample data for testing
- Error Handling - How to handle API errors
Getting Started
In a very brief, you only need 3 steps (with a prerequisite of registration in our Developer Portal) to call any EHR API through Leyr:
Show Doctor's Availability
Learn how to discover available timeslots for booking appointments. This guide walks through the complete flow from finding care units to checking doctor availability.