Luna SaludAPI ReferenceLuna Salud

Get available appointment slots for a date range

GET/availability/range

Lists the open appointment slots for one provider and service on every day from startDate to endDate (inclusive, at most 14 days), computed exactly as GET /availability computes a single day. Every day in the range is returned, with an empty slots list when the provider has no open time. Use it to offer the next available times in one call. Times are ISO 8601 with the clinic's UTC offset. Pass a slot's start_time to POST /appointments to book it.

Code samples

Node.js

const fetch = require('node-fetch');

async function callApi() {
  const apiKey = 'YOUR_API_KEY';
  const staffId = 'your-staffId';
  const serviceId = 'your-serviceId';
  const startDate = 'your-startDate';
  const endDate = 'your-endDate';
  const locationId = 'your-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 ${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/availability/range'
    
    headers = {
        'Authorization': f'Bearer {api_key}',
        'Content-Type': 'application/json'
    }
    
    params = {
    'staffId': 'your-staffId',
    'serviceId': 'your-serviceId',
    'startDate': 'your-startDate',
    'endDate': 'your-endDate',
    'locationId': 'your-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 calling API: {e}')
        raise

call_api()

Parameters

NameInTypeRequiredDescription
staffIdquerystringYesID of the provider (staff member) to check
serviceIdquerystringYesID of the service to book; sets the slot length
startDatequerystringYesFirst calendar day as YYYY-MM-DD, in the provider's timezone
endDatequerystringYesLast calendar day as YYYY-MM-DD, inclusive; at most 14 days after the first day counting both
locationIdquerystringNo—

Responses

StatusDescription
200Successful response
400Invalid input data
401Authorization not provided
403Insufficient access
404Not found
500Internal server error

200 — Successful response

Response fields

NameTypeRequiredDescription
start_datestringYes—
end_datestringYes—
timezonestringYes—
daysarray<object>Yes—

Example response

{
  "start_date": "string",
  "end_date": "string",
  "timezone": "string",
  "days": [
    {
      "date": "string",
      "slots": [
        {
          "start_time": "string",
          "end_time": "string"
        }
      ]
    }
  ]
}

400 — Invalid input data

Response fields

NameTypeRequiredDescription
messagestringYesThe error message
codestringYesThe error code
issuesarray<object>NoAn 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

NameTypeRequiredDescription
messagestringYesThe error message
codestringYesThe error code
issuesarray<object>NoAn array of issues that were responsible for the error

Example response

{
  "code": "UNAUTHORIZED",
  "message": "Authorization not provided",
  "issues": []
}

403 — Insufficient access

Response fields

NameTypeRequiredDescription
messagestringYesThe error message
codestringYesThe error code
issuesarray<object>NoAn array of issues that were responsible for the error

Example response

{
  "code": "FORBIDDEN",
  "message": "Insufficient access",
  "issues": []
}

404 — Not found

Response fields

NameTypeRequiredDescription
messagestringYesThe error message
codestringYesThe error code
issuesarray<object>NoAn array of issues that were responsible for the error

Example response

{
  "code": "NOT_FOUND",
  "message": "Not found",
  "issues": []
}

500 — Internal server error

Response fields

NameTypeRequiredDescription
messagestringYesThe error message
codestringYesThe error code
issuesarray<object>NoAn array of issues that were responsible for the error

Example response

{
  "code": "INTERNAL_SERVER_ERROR",
  "message": "Internal server error",
  "issues": []
}