Luna Health API / Referencia de la API / Obtener horarios disponibles en un rango de fechas Obtener horarios disponibles en un rango de fechas GET /availability/range
Lista los horarios disponibles para un profesional de salud y un servicio en cada día de startDate a endDate (inclusive, máximo 14 días), calculados igual que GET /availability calcula un solo día. Se devuelven todos los días del rango, con la lista slots vacía cuando el profesional no tiene horarios libres. Úselo para ofrecer los próximos horarios disponibles en una sola llamada. Las horas están en ISO 8601 con el desfase UTC de la clínica. Envíe el start_time de un horario a POST /appointments para agendarlo.
Ejemplos de código Node.js const fetch = require('node-fetch');
async function llamarApi() {
const claveApi = 'YOUR_API_KEY';
const staffId = 'su-staffId';
const serviceId = 'su-serviceId';
const startDate = 'su-startDate';
const endDate = 'su-endDate';
const locationId = 'su-locationId';
const queryString = new URLSearchParams({
staffId: staffId,
serviceId: serviceId,
startDate: startDate,
endDate: endDate,
locationId: locationId
}).toString();
const url = `https://account.lunahealth.app/api/availability/range` + (queryString ? `?${queryString}` : '');
try {
const response = await fetch(url, {
method: 'GET',
headers: {
'Authorization': `Bearer ${claveApi}`,
'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 al llamar a la API:', error);
throw error;
}
}
llamarApi();Python import requests
def llamarApi():
claveApi = 'YOUR_API_KEY'
url = 'https://account.lunahealth.app/api/availability/range'
headers = {
'Authorization': f'Bearer {claveApi}',
'Content-Type': 'application/json'
}
params = {
'staffId': 'su-staffId',
'serviceId': 'su-serviceId',
'startDate': 'su-startDate',
'endDate': 'su-endDate',
'locationId': 'su-locationId'
}
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 al llamar a la API: {e}')
raise
llamarApi()Parámetros Nombre Ubicación Tipo Requerido Descripción staffIdquery string Sí ID del profesional de salud serviceIdquery string Sí ID del servicio startDatequery string Sí Primer día en formato YYYY-MM-DD, en la zona horaria del profesional de salud endDatequery string Sí Último día en formato YYYY-MM-DD, inclusive locationIdquery string No ID de la sucursal
Respuestas Estado Descripción 200Respuesta exitosa 400Datos de entrada no válidos 401Autorización no proporcionada 403Acceso insuficiente 404No encontrado 500Error interno del servidor
200 — Respuesta exitosaCampos de la respuesta Nombre Tipo Requerido Descripción start_datestring Sí — end_datestring Sí — timezonestring Sí — daysarray<object> Sí —
Ejemplo de respuesta {
"start_date": "string",
"end_date": "string",
"timezone": "string",
"days": [
{
"date": "string",
"slots": [
{
"start_time": "string",
"end_time": "string"
}
]
}
]
}400 — Datos de entrada no válidosCampos de la respuesta Nombre Tipo Requerido Descripción messagestring Sí The error message codestring Sí The error code issuesarray<object> No An array of issues that were responsible for the error
Ejemplo de respuesta {
"code": "BAD_REQUEST",
"message": "Invalid input data",
"issues": []
}401 — Autorización no proporcionadaCampos de la respuesta Nombre Tipo Requerido Descripción messagestring Sí The error message codestring Sí The error code issuesarray<object> No An array of issues that were responsible for the error
Ejemplo de respuesta {
"code": "UNAUTHORIZED",
"message": "Authorization not provided",
"issues": []
}403 — Acceso insuficienteCampos de la respuesta Nombre Tipo Requerido Descripción messagestring Sí The error message codestring Sí The error code issuesarray<object> No An array of issues that were responsible for the error
Ejemplo de respuesta {
"code": "FORBIDDEN",
"message": "Insufficient access",
"issues": []
}404 — No encontradoCampos de la respuesta Nombre Tipo Requerido Descripción messagestring Sí The error message codestring Sí The error code issuesarray<object> No An array of issues that were responsible for the error
Ejemplo de respuesta {
"code": "NOT_FOUND",
"message": "Not found",
"issues": []
}500 — Error interno del servidorCampos de la respuesta Nombre Tipo Requerido Descripción messagestring Sí The error message codestring Sí The error code issuesarray<object> No An array of issues that were responsible for the error
Ejemplo de respuesta {
"code": "INTERNAL_SERVER_ERROR",
"message": "Internal server error",
"issues": []
}Abrir en la referencia interactiva →