Setmore SDK
This is a Javascript SDK for the Setmore API. Setmore is a free online appointment scheduling software for small businesses. It allows you to manage your appointments, staff, services, and customers. This SDK allows you to easily integrate Setmore into your Node.js application.
Table of Contents
Installation
npm install setmore-sdk
Environment Variables
Create a .env
file in the root of your project and add the following variables:
SETMORE_API_KEY=your-api-key
Usage
Initialize Setmore
const { Setmore, formatDateToSetmore } = require('setmore-sdk');
const setmore = new Setmore(process.env.SETMORE_API_KEY);
STAFF
setmore.staff.getStaff().then((staff) => {
console.log(staff);
});
CATEGORIES
setmore.categories.getCategories().then((categories) => {
console.log(categories);
});
SERVICES
setmore.services.getServices().then((services) => {
console.log(services);
});
setmore.services.getServicesWithCategories().then((services) => {
console.log(services);
});
CUSTOMERS
setmore.customers
.getCustomer({
given_name: 'John',
email: 'john@example.com',
})
.then((customer) => {
console.log(customer);
});
setmore.customers
.createCustomer({
given_name: 'John',
family_name: 'Doe',
email: 'johndoe@example.com',
picture: 'https://example.com/photo.jpg',
phone: '555-555-5555',
})
.then((customer) => {
console.log(customer);
});
APPOINTMENTS
const user = {
given_name: 'John',
email: 'john@example.com',
};
const months = 3;
setmore.appointments.getAppointments(user, months).then((appointments) => {
console.log(appointments);
});
const { formatDateToSetmore } = require('setmore-sdk');
const start = new Date('2023-02-09T15:30Z');
const [startDate, endDate] = formatDateToSetmore(start);
const appointment = {
staff_key: staff.staffs[0].key,
service_key: services[1].serviceIdList[1],
customer_key: customer[0].key,
start_time: startDate,
end_time: endDate,
cost: 30,
};
setmore.appointments.createAppointment(appointment).then((res) => {
console.log(res);
});
const { formatDateToSetmore } = require('setmore-sdk');
const start = new Date('2023-02-09T15:30Z');
const [startDate, endDate] = formatDateToSetmore(start);
const appointment = {
appointment_key: '<appointment key>',
staff_key: '<staff key>',
service_key: '<service key>',
customer_key: '<customer key>',
start_time: startDate,
end_time: endDate,
cost: 30,
};
setmore.appointments.createAppointment(appointment).then((res) => {
console.log(res);
});
setmore.appointments.deleteAppointment('<appointment key>').then((res) => {
console.log(res);
});
TIME SLOTS
setmore.appointments
.getAppointmentSlots({
staff_key: '<staff key>',
service_key: '<service key>',
selected_date: 'DD/MM/YYYY',
slot_limit: 30,
})
.then((slots) => {
console.log(slots);
});
Questions
If you have any questions, please feel free to reach out to me by email or LinkedIn.
Email
LinkedIn
My Portfolio
https://raulwebdev.com