getService( )
Retrieves a service.
Syntax
function getService(serviceId: string): Promise<Service>
getService Parameters
NAME
TYPE
DESCRIPTION
ID of the service to retrieve.
Returns
The retrieved service.
Return Type:
NAME
TYPE
DESCRIPTION
Date and time the service was created.
Service ID.
Date and time the service was updated.
Policy determining under what conditions this service can be booked. For example, whether the service can only be booked up to 30 minutes before it begins.
The category the service is associated with.
Conferencing options for this service.
Default maximum number of customers that can book the service. The service cannot be booked beyond this capacity.
Service description, such as High-class hair styling, cuts, straightening and color.
Extensions enabling users to save custom data related to the service.
The form used when booking the service.
Whether the service is hidden from the site.
The locations this service is offered at.
In case of multiple (more than 1) location, All locations must be of type BUSINESS
.
For courses only: Currently, only 1 location is supported, for all location types.
The main slug for the service. mainSlug
is either taken from the current service name or is a custom slug set by the business owner.
mainSlug
is used to construct the service's URLs.
Media associated with the service.
Service name.
Online booking settings.
Payment options for booking the service.
Revision number, which increments by 1 each time the service is updated. To prevent conflicting changes, the existing revision must be used when updating a service.
The service's schedule, which can be used to manage the service's sessions.
Custom SEO data for the service.
Order of a service within a category.
IDs of the staff members providing the service. For appointments only.
A slug is the last part of the URL address that serves as a unique identifier of the service. The list of supported slugs includes past service names for backwards compatibility, and a custom slug if one was set by the business owner.
Short service description, such as Hair styling.
Service type.
Supported Values:
- "APPOINTMENT"
- "CLASS"
- "COURSE"
URLs to various service-related pages, such as the calendar page and the booking page.
Was this helpful?
Retrieve a service
1import { services } from 'wix-bookings.v2';23/*4 * Sample serviceId value: 'ff61204b-b19a-5cc8-823b-7eed8ae5fc28'5 */6async function getService(serviceId) {7 try {8 return services.getService(serviceId);9 } catch (error) {10 console.error(error);11 // Handle the error12 }13}1415/* Promise resolves to:16 * {17 "type": "CLASS",18 "sortOrder": 4,19 "name": "Group Cat Hugging",20 "description": "Introducing the Purrfect Hug - the ultimate cat cuddling experience! Our team of expert cuddlers will come to your home and provide your furry feline with the warmest and snuggliest hugs around.",21 "tagLine": "Get some purr therapy with our cat hugging service!",22 "defaultCapacity": 30,23 "hidden": false,24 "category": {25 "name": "Our Services",26 "sortOrder": 0,27 "_id": "99b3c3af-3dd1-4fcd-8d97-2fcedcb2908c"28 },29 "payment": {30 "rateType": "FIXED",31 "fixed": {32 "price": {33 "value": "25",34 "currency": "USD"35 },36 "deposit": {37 "value": "5",38 "currency": "USD"39 }40 },41 "options": {42 "online": true,43 "inPerson": false,44 "deposit": false,45 "pricingPlan": false46 },47 "pricingPlanIds": []48 },49 "onlineBooking": {50 "enabled": true51 },52 "locations": [53 {54 "type": "BUSINESS"55 }56 ],57 "bookingPolicy": {58 "revision": "1",59 "name": "Default policy",60 "customPolicyDescription": {61 "enabled": true,62 "description": ""63 },64 "default": true,65 "limitEarlyBookingPolicy": {66 "enabled": false,67 "earliestBookingInMinutes": 1008068 },69 "limitLateBookingPolicy": {70 "enabled": false,71 "latestBookingInMinutes": 144072 },73 "bookAfterStartPolicy": {74 "enabled": false75 },76 "cancellationPolicy": {77 "enabled": true,78 "limitLatestCancellation": false,79 "latestCancellationInMinutes": 144080 },81 "reschedulePolicy": {82 "enabled": true,83 "limitLatestReschedule": false,84 "latestRescheduleInMinutes": 144085 },86 "waitlistPolicy": {87 "enabled": false,88 "capacity": 10,89 "reservationTimeInMinutes": 1090 },91 "participantsPolicy": {92 "enabled": true,93 "maxParticipantsPerBooking": 194 },95 "resourcesPolicy": {96 "enabled": false,97 "autoAssignAllowed": false98 },99 "_id": "ede8ad9e-44e1-480e-833f-542aea019bd0",100 "_createdDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)",101 "_updatedDate": "Thu Dec 14 2023 16:14:33 GMT+0100 (Central European Standard Time)"102 },103 "schedule": {104 "_id": "81aa34a4-0cbc-4476-b8ec-62878024cd97"105 },106 "staffMemberIds": [],107 "staffMembers": [],108 "resourceGroups": [],109 "serviceResources": [],110 "supportedSlugs": [111 {112 "name": "group-cat-hugging-1",113 "custom": false,114 "_createdDate": "Tue Jan 16 2024 17:20:11 GMT+0100 (Central European Standard Time)"115 }116 ],117 "mainSlug": {118 "name": "group-cat-hugging-1",119 "custom": false,120 "_createdDate": "Tue Jan 16 2024 17:20:11 GMT+0100 (Central European Standard Time)"121 },122 "urls": {123 "servicePage": "https://www.example.com/services-v2-test/service-page/group-cat-hugging-1",124 "bookingPage": "https://www.example.com/services-v2-test/booking-calendar/group-cat-hugging-1",125 "calendarPage": "https://www.example.com/services-v2-test/booking-calendar/group-cat-hugging-1"126 },127 "revision": "1",128 "_id": "fad1a29c-d06b-4ce7-ab80-98c54c4e0772",129 "_createdDate": "Tue Jan 16 2024 17:20:12 GMT+0100 (Central European Standard Time)",130 "_updatedDate": "Tue Jan 16 2024 17:20:12 GMT+0100 (Central European Standard Time)"131 }132 */133