Search.../

getService( )

Developer Preview

Retrieves a service.

Syntax

function getService(serviceId: string): Promise<Service>

getService Parameters

NAME
TYPE
DESCRIPTION
serviceId
string

ID of the service to retrieve.

Returns

The retrieved service.

Return Type:

Promise<
Service
>
NAME
TYPE
DESCRIPTION
_createdDate
Date

Date and time the service was created.

_id
string

Service ID.

_updatedDate
Date

Date and time the service was updated.

bookingPolicy
BookingPolicy

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.

category
V2Category

The category the service is associated with.

conferencing
Conferencing

Conferencing options for this service.

defaultCapacity
number

Default maximum number of customers that can book the service. The service cannot be booked beyond this capacity.

description
string

Service description, such as High-class hair styling, cuts, straightening and color.

extendedFields
ExtendedFields

Extensions enabling users to save custom data related to the service.

form
Form

The form used when booking the service.

hidden
boolean

Whether the service is hidden from the site.

locations
Array<
Location
>

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.

mainSlug
Slug

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
Media

Media associated with the service.

name
string

Service name.

onlineBooking
OnlineBooking

Online booking settings.

payment
Payment

Payment options for booking the service.

revision
string

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.

schedule
Schedule

The service's schedule, which can be used to manage the service's sessions.

seoData
SeoSchema

Custom SEO data for the service.

sortOrder
number

Order of a service within a category.

staffMemberIds
Array<
string
>

IDs of the staff members providing the service. For appointments only.

supportedSlugs
Array<
Slug
>

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.

tagLine
string

Short service description, such as Hair styling.

type
string

Service type.

Supported Values:

  • "APPOINTMENT"
  • "CLASS"
  • "COURSE"
urls
URLs

URLs to various service-related pages, such as the calendar page and the booking page.

Was this helpful?

Retrieve a service

Copy Code
1import { services } from 'wix-bookings.v2';
2
3/*
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 error
12 }
13}
14
15/* 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": false
46 },
47 "pricingPlanIds": []
48 },
49 "onlineBooking": {
50 "enabled": true
51 },
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": 10080
68 },
69 "limitLateBookingPolicy": {
70 "enabled": false,
71 "latestBookingInMinutes": 1440
72 },
73 "bookAfterStartPolicy": {
74 "enabled": false
75 },
76 "cancellationPolicy": {
77 "enabled": true,
78 "limitLatestCancellation": false,
79 "latestCancellationInMinutes": 1440
80 },
81 "reschedulePolicy": {
82 "enabled": true,
83 "limitLatestReschedule": false,
84 "latestRescheduleInMinutes": 1440
85 },
86 "waitlistPolicy": {
87 "enabled": false,
88 "capacity": 10,
89 "reservationTimeInMinutes": 10
90 },
91 "participantsPolicy": {
92 "enabled": true,
93 "maxParticipantsPerBooking": 1
94 },
95 "resourcesPolicy": {
96 "enabled": false,
97 "autoAssignAllowed": false
98 },
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