Leyr
API

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.

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 Account

2. Register Your Application

Create a developer application to get your Client ID and Client Secret.

Register Application

3. Configure an EHR

Connect to an EHR system and get your credentials. For testing, you can use Leyr's test credentials.

Configure EHR

4. 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

Lookup existing patients and retrieve the right patient identifier for follow-up flows.

Create Patient

Create or upsert a patient record before appointments, notes, and document uploads.

Show Doctor's Availability

Learn how to discover care units, resources, healthcare services, and available timeslots.

Book an Appointment

Create appointments for patients using available timeslots.

Write a Medical Note

Document clinical information in patient records.

Attach a Document

Upload files like lab results or imaging to patient records.

Use this order to avoid missing required IDs:

  1. Start with Show Doctor's Availability to get care_unit_id (step 1), and discover resource_id, healthcare_service_id, and timeslots.
  2. Use Find or Get Patient or Create Patient to get a valid patient_id.
  3. Continue with:

Next Steps

After completing these quickstarts, explore: