List appointments
GET
/appointmentsRetrieves a paginated list of appointments for your organization. Supports filtering by date range, status, and patient.
Code samples
Node.js
const fetch = require('node-fetch');
async function callApi() {
const apiKey = 'YOUR_API_KEY';
const from = 'your-from';
const to = 'your-to';
const status = 'your-status';
const patientId = 'your-patientId';
const rowsPerPage = 'your-rowsPerPage';
const page = 'your-page';
const sortDir = 'your-sortDir';
const queryString = new URLSearchParams({
from: from,
to: to,
status: status,
patientId: patientId,
rowsPerPage: rowsPerPage,
page: page,
sortDir: sortDir
}).toString();
const url = `https://account.lunahealth.app/api/appointments` + (queryString ? `?${queryString}` : '');
try {
const response = await fetch(url, {
method: 'GET',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
}
});
if (!response.ok) {
throw new Error(`API error: ${response.status}`);
}
const data = await response.json();
console.log(data);
return data;
} catch (error) {
console.error('Error calling API:', error);
throw error;
}
}
callApi();Python
import requests
def call_api():
api_key = 'YOUR_API_KEY'
url = 'https://account.lunahealth.app/api/appointments'
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
params = {
'from': 'your-from',
'to': 'your-to',
'status': 'your-status',
'patientId': 'your-patientId',
'rowsPerPage': 'your-rowsPerPage',
'page': 'your-page',
'sortDir': 'your-sortDir'
}
try:
response = requests.get(
url,
headers=headers,
params=params
)
response.raise_for_status()
data = response.json()
print(data)
return data
except requests.exceptions.RequestException as e:
print(f'Error calling API: {e}')
raise
call_api()Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
from | query | string (date-time) | No | — |
to | query | string (date-time) | No | — |
status | query | string | No | — |
patientId | query | string | No | — |
rowsPerPage | query | number | No | — |
page | query | number | No | — |
sortDir | query | string | No | — |
Responses
| Status | Description |
|---|---|
200 | Successful response |
400 | Invalid input data |
401 | Authorization not provided |
403 | Insufficient access |
404 | Not found |
500 | Internal server error |
200 — Successful response
Response fields
| Name | Type | Required | Description |
|---|---|---|---|
items | array<object> | Yes | — |
meta | object | Yes | — |
Example response
{
"items": [
{
"id": "string",
"status": "NEW",
"type": "APPOINTMENT",
"title": "string",
"description": "string",
"start_time": "string",
"end_time": "string",
"telemedicine": true,
"created_at": "string",
"updated_at": "string",
"patient": {
"id": "string",
"first_name": "string",
"last_name": "string",
"email": "string"
},
"staffs": [
{
"id": "string",
"first_name": "string",
"last_name": "string"
}
],
"service": {
"id": "string",
"name": "string"
},
"location": {
"id": "string",
"name": "string"
}
}
],
"meta": {
"totalRowCount": 0,
"page": 0,
"rowsPerPage": 0
}
}400 — Invalid input data
Response fields
| Name | Type | Required | Description |
|---|---|---|---|
message | string | Yes | The error message |
code | string | Yes | The error code |
issues | array<object> | No | An array of issues that were responsible for the error |
Example response
{
"code": "BAD_REQUEST",
"message": "Invalid input data",
"issues": []
}401 — Authorization not provided
Response fields
| Name | Type | Required | Description |
|---|---|---|---|
message | string | Yes | The error message |
code | string | Yes | The error code |
issues | array<object> | No | An array of issues that were responsible for the error |
Example response
{
"code": "UNAUTHORIZED",
"message": "Authorization not provided",
"issues": []
}403 — Insufficient access
Response fields
| Name | Type | Required | Description |
|---|---|---|---|
message | string | Yes | The error message |
code | string | Yes | The error code |
issues | array<object> | No | An array of issues that were responsible for the error |
Example response
{
"code": "FORBIDDEN",
"message": "Insufficient access",
"issues": []
}404 — Not found
Response fields
| Name | Type | Required | Description |
|---|---|---|---|
message | string | Yes | The error message |
code | string | Yes | The error code |
issues | array<object> | No | An array of issues that were responsible for the error |
Example response
{
"code": "NOT_FOUND",
"message": "Not found",
"issues": []
}500 — Internal server error
Response fields
| Name | Type | Required | Description |
|---|---|---|---|
message | string | Yes | The error message |
code | string | Yes | The error code |
issues | array<object> | No | An array of issues that were responsible for the error |
Example response
{
"code": "INTERNAL_SERVER_ERROR",
"message": "Internal server error",
"issues": []
}