Luna Health API / Referencia de la API / Obtener biomarcadores de un usuario Obtener biomarcadores de un usuario GET /biomarkers
Recupera una lista paginada de biomarcadores para un paciente específico con opciones de filtrado completas. Devuelve valores de biomarcadores, rangos de referencia, clasificaciones de estado e información de unidades. Incluye metadatos con estadísticas sobre la distribución del estado de biomarcadores.
Ejemplos de código Node.js const fetch = require('node-fetch');
async function llamarApi() {
const claveApi = 'YOUR_API_KEY';
const patientId = 'su-patientId';
const start_date = 'su-start_date';
const end_date = 'su-end_date';
const status = 'su-status';
const page = 'su-page';
const limit = 'su-limit';
const queryString = new URLSearchParams({
patientId: patientId,
start_date: start_date,
end_date: end_date,
status: status,
page: page,
limit: limit
}).toString();
const url = `https://account.lunahealth.app/api/biomarkers` + (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/biomarkers'
headers = {
'Authorization': f'Bearer {claveApi}',
'Content-Type': 'application/json'
}
params = {
'patientId': 'su-patientId',
'start_date': 'su-start_date',
'end_date': 'su-end_date',
'status': 'su-status',
'page': 'su-page',
'limit': 'su-limit'
}
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 patientIdquery string Sí ID del paciente para filtrar los resultados start_datequery string No Fecha de inicio opcional para filtrar (formato ISO) end_datequery string No Fecha de fin opcional para filtrar (formato ISO) statusquery string No Filtrar por estado pagequery number No Número de página (indexado en 0) limitquery number No Número de elementos por página
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 itemsarray<object> Sí — metaobject Sí —
Ejemplo de respuesta {
"items": [
{
"id": "string",
"name": "string",
"value": 0,
"original_value": 0,
"units": "string",
"status": "ACCEPTABLE",
"reference_range": null,
"qualitative_value": "string",
"is_numeric": true,
"created_at": "string"
}
],
"meta": {
"totalCount": 0,
"currentPage": 0,
"totalPages": 0,
"status": {
"OPTIMAL": 0,
"ACCEPTABLE": 0,
"CRITICAL": 0
}
}
}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 →