---
title: "Quickstart"
description: "Step-by-step quickstarts with working Python and JavaScript examples for common Leyr API workflows."
canonical_url: "http://localhost/api/quickstart"
---
# Quickstart
> Step-by-step quickstarts with working Python and JavaScript examples for common Leyr API workflows.
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:
```python
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)}")
```
```javascript
// Your credentials from Leyr Developer Portal
const CLIENT_ID = "your-client-id";
const CLIENT_SECRET = "your-client-secret";
// Base URL for Leyr API
const BASE_URL = "https://api.leyr.io/api";
// Headers for all requests
const headers = {
"x-leyr-client-id": CLIENT_ID,
"x-leyr-client-secret": CLIENT_SECRET,
"Content-Type": "application/json"
};
// Example: Get list of supported EHRs
const response = await fetch(`${BASE_URL}/emrs`, { headers });
const emrs = await response.json();
console.log(`Available EHRs: ${emrs.length}`);
```
## Use Cases
Choose a use case to get started:
Lookup existing patients and retrieve the right patient identifier for follow-up flows.
Create or upsert a patient record before appointments, notes, and document uploads.
Learn how to discover care units, resources, healthcare services, and available timeslots.
Create appointments for patients using available timeslots.
Document clinical information in patient records.
Upload files like lab results or imaging to patient records.
## Recommended Order
Use this order to avoid missing required IDs:
1. Start with [Show Doctor's Availability](http://localhost/api/quickstart/show-availability) to get `care_unit_id` (step 1), and discover `resource_id`, `healthcare_service_id`, and `timeslots`.
2. Use [Find or Get Patient](http://localhost/api/quickstart/find-patient) or [Create Patient](http://localhost/api/quickstart/create-patient) to get a valid `patient_id`.
3. Continue with:
- [Book an Appointment](http://localhost/api/quickstart/book-appointment) using `care_unit_id` + `timeslot` + `patient_id`
- [Write a Medical Note](http://localhost/api/quickstart/write-medical-note) using `care_unit_id` + `resource_id` + `patient_id`
- [Attach a Document](http://localhost/api/quickstart/attach-document) using `care_unit_id` + `resource_id` + `patient_id`
## Next Steps
After completing these quickstarts, explore:
- [API Guides](http://localhost/api/guides) - Advanced topics and best practices
- [Test Data](http://localhost/api/test-data) - Sample data for testing
- [Error Handling](http://localhost/api/error-handling) - How to handle API errors
## Sitemap
See the full [sitemap](http://localhost/sitemap.md) for all pages.