Learn how to seamlessly integrate Lovable with Acuity Scheduling using our step-by-step guide to streamline appointments and boost workflow efficiency.
Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
src
folder and name it config.ts
.config.ts
. Replace the placeholder text with your actual Acuity Scheduling API credentials.
export const ACUITYAPIUSERID = "YOURACUITYAPIUSER_ID";
export const ACUITYAPIKEY = "YOURACUITYAPI_KEY";
export const ACUITYAPIURL = "https://acuityscheduling.com/api/v1";
services
inside your src
folder if it does not already exist.src/services
named acuityService.ts
.acuityService.ts
. This TypeScript class uses Acuity’s API to fetch and create appointments.
import { ACUITYAPIUSERID, ACUITYAPIKEY, ACUITYAPI_URL } from "../config";
interface Appointment {
id: number;
datetime: string;
firstName: string;
lastName: string;
email: string;
}
export class AcuityService {
private headers: HeadersInit;
constructor() {
const auth = Buffer.from(${ACUITY_API_USER_ID}:${ACUITY_API_KEY}).toString('base64');
this.headers = {
"Authorization": Basic ${auth},
"Content-Type": "application/json"
};
}
async getAppointments(): Promise {
const response = await fetch(${ACUITY_API_URL}/appointments, {
method: 'GET',
headers: this.headers
});
if (!response.ok) {
throw new Error('Failed to fetch appointments');
}
return response.json();
}
async createAppointment(appointmentData: Partial): Promise {
const response = await fetch(${ACUITY_API_URL}/appointments, {
method: 'POST',
headers: this.headers,
body: JSON.stringify(appointmentData)
});
if (!response.ok) {
throw new Error('Failed to create appointment');
}
return response.json();
}
}
fetch
API. If fetch
isn’t available in your project environment, you may need to include a polyfill by adding the polyfill’s code directly into your project.
src/app.ts
).AcuityService
class and instantiate it. Then call its methods as needed in your application.
import { AcuityService } from "./services/acuityService";
const acuityService = new AcuityService();
// Example function to fetch and log appointments
async function showAcuityAppointments() {
try {
const appointments = await acuityService.getAppointments();
console.log("Acuity Appointments:", appointments);
} catch (error) {
console.error("Error fetching appointments:", error);
}
}
showAcuityAppointments();
config.ts
file contains your valid Acuity Scheduling credentials.
AcuityService
class by adding more methods for other Acuity Scheduling endpoints, following the same pattern as in getAppointments
and createAppointment
.When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.