@findhotel/sapi 1.11.2 → 1.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -56,9 +56,9 @@ hotels, hotels\' offers and rooms.
|
|
|
56
56
|
- [Callbacks](#callbacks-1)
|
|
57
57
|
- [Response](#response-7)
|
|
58
58
|
- [Rooms configuration](#rooms-configuration)
|
|
59
|
-
|
|
59
|
+
- [Examples](#examples)
|
|
60
60
|
- [How to generate `searchId`?](#how-to-generate-searchid)
|
|
61
|
-
|
|
61
|
+
- [Example](#example)
|
|
62
62
|
|
|
63
63
|
# Release process
|
|
64
64
|
|
|
@@ -68,71 +68,78 @@ releases SAPI SDK uses [Ship.js](https://github.com/algolia/shipjs)
|
|
|
68
68
|
tool. It gives more control over the process. Ship.js automatically
|
|
69
69
|
creates a PR before publishing every release, so this allows:
|
|
70
70
|
|
|
71
|
-
-
|
|
72
|
-
-
|
|
73
|
-
|
|
74
|
-
-
|
|
75
|
-
|
|
71
|
+
- Confirm the next version is correct.
|
|
72
|
+
- Confirm which commits are going to be released and discuss them with
|
|
73
|
+
colleagues.
|
|
74
|
+
- Edit the automatically generated changelog for clarity &
|
|
75
|
+
readability.
|
|
76
76
|
|
|
77
77
|
## GitHub Token
|
|
78
78
|
|
|
79
79
|
GitHub token is required for the release process:
|
|
80
80
|
|
|
81
|
-
-
|
|
82
|
-
-
|
|
83
|
-
-
|
|
84
|
-
-
|
|
81
|
+
- Go to [your GitHub account](https://github.com/settings/tokens/new)
|
|
82
|
+
- Check \"repo(Full control of private repositories)\"
|
|
83
|
+
- Generate/copy the token
|
|
84
|
+
- Add it in your command line like: `GITHUB_TOKEN=xxx`
|
|
85
85
|
|
|
86
86
|
## New release
|
|
87
87
|
|
|
88
88
|
To create and deploy a new release of SAPI SDK please follow the next
|
|
89
89
|
steps:
|
|
90
90
|
|
|
91
|
-
-
|
|
92
|
-
-
|
|
93
|
-
-
|
|
94
|
-
|
|
95
|
-
-
|
|
96
|
-
-
|
|
97
|
-
|
|
98
|
-
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
-
|
|
103
|
-
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
-
|
|
91
|
+
- Merge your changes. There can be multiple changes in one release
|
|
92
|
+
- Checkout the latest version of the `main` branch
|
|
93
|
+
- In the root directory run `make release` command - this
|
|
94
|
+
will start the release process
|
|
95
|
+
- Review and confirm (or change) the new release version number
|
|
96
|
+
- After installing dependencies and running deployment scripts a new
|
|
97
|
+
pull request will be automatically created
|
|
98
|
+
- Review/update `CHANGELOG.md` in the root directory. Write down
|
|
99
|
+
changes with descriptions using [keep a changelog] guiding
|
|
100
|
+
principles and commit your changes to the newly created release
|
|
101
|
+
PR
|
|
102
|
+
- Review the PR/ask SAPI engineer(s) for approval
|
|
103
|
+
- `Squash and merge` the PR. This will trigger automated
|
|
104
|
+
release process using GitHub actions and after some time the new
|
|
105
|
+
release will be published to NMP
|
|
106
|
+
- Check if the new version has been published to NPM
|
|
107
107
|
|
|
108
108
|
[keep a changelog]: https://keepachangelog.com/
|
|
109
109
|
|
|
110
110
|
## New release from a development branch
|
|
111
111
|
|
|
112
112
|
Sometimes You might want to test your changes on the website for example on the local or custom/test environment before merging your branch to main and before making a new SAPI SDK release. To do so You can create and publish a pre-release.
|
|
113
|
-
Pre-release publishes a new version to NPM with a tag other than `latest` (the default tag).
|
|
113
|
+
Pre-release publishes a new version to NPM with a tag other than `latest` (the default tag).
|
|
114
114
|
To publish a pre-release please follow the next steps:
|
|
115
|
+
|
|
115
116
|
- commit your changes to your development branch
|
|
116
117
|
- build SAPI SDK from the root of the project:
|
|
117
118
|
```sh
|
|
118
119
|
make core-build
|
|
119
120
|
```
|
|
120
121
|
- create a new version `npm version prepatch (preminor, premajor) --preid=beta (alpha, beta, etc...)`:
|
|
122
|
+
|
|
121
123
|
```sh
|
|
122
124
|
npm version prepatch --preid=beta
|
|
123
125
|
```
|
|
126
|
+
|
|
124
127
|
this would result in something like this `1.4.1-beta.0`
|
|
128
|
+
|
|
125
129
|
- If you’ve already released a pre-release and want to increment the pre-release part of the version only, run:
|
|
126
130
|
|
|
127
131
|
```sh
|
|
128
132
|
npm version prerelease
|
|
129
133
|
```
|
|
134
|
+
|
|
130
135
|
this would result in something like this `1.4.1-beta.1`
|
|
136
|
+
|
|
131
137
|
- publish your changes with a tag other than `latest`:
|
|
132
138
|
|
|
133
139
|
```sh
|
|
134
140
|
npm publish --tag=next
|
|
135
141
|
```
|
|
142
|
+
|
|
136
143
|
- after the new version is published to npm, install it to your local environment specifying the new version:
|
|
137
144
|
|
|
138
145
|
```sh
|
|
@@ -153,20 +160,20 @@ npm install @findhotel/sapi
|
|
|
153
160
|
Then, import SAPI into your project:
|
|
154
161
|
|
|
155
162
|
```js
|
|
156
|
-
import sapi from
|
|
163
|
+
import sapi from "@findhotel/sapi";
|
|
157
164
|
```
|
|
158
165
|
|
|
159
166
|
Create SAPI client:
|
|
160
167
|
|
|
161
168
|
```js
|
|
162
|
-
const profileKey =
|
|
169
|
+
const profileKey = "profile-key";
|
|
163
170
|
|
|
164
171
|
const sapiClient = await sapi(profileKey, {
|
|
165
|
-
anonymousId:
|
|
166
|
-
language:
|
|
167
|
-
currency:
|
|
168
|
-
countryCode:
|
|
169
|
-
})
|
|
172
|
+
anonymousId: "fd9dbb5f-b337-4dd7-b640-1f177d1d3caa",
|
|
173
|
+
language: "en",
|
|
174
|
+
currency: "USD",
|
|
175
|
+
countryCode: "US",
|
|
176
|
+
});
|
|
170
177
|
```
|
|
171
178
|
|
|
172
179
|
Now SAPI client is ready to be used in your application.
|
|
@@ -188,64 +195,67 @@ found [here](https://www.npmjs.com/package/react-native-get-random-values)
|
|
|
188
195
|
## Usage
|
|
189
196
|
|
|
190
197
|
### Search
|
|
198
|
+
|
|
191
199
|
<a id="tutorial-hotels-search"></a>
|
|
192
200
|
|
|
193
201
|
Search for the hotels and hotels\' offers:
|
|
194
202
|
|
|
195
203
|
```js
|
|
196
204
|
const searchParameters = {
|
|
197
|
-
placeId:
|
|
198
|
-
checkIn:
|
|
199
|
-
checkOut:
|
|
200
|
-
rooms:
|
|
201
|
-
}
|
|
205
|
+
placeId: "47319",
|
|
206
|
+
checkIn: "2021-10-10",
|
|
207
|
+
checkOut: "2021-10-11",
|
|
208
|
+
rooms: "2",
|
|
209
|
+
};
|
|
202
210
|
|
|
203
|
-
const callbacks =
|
|
211
|
+
const callbacks = {
|
|
204
212
|
onStart: (response) => {
|
|
205
|
-
log(
|
|
213
|
+
log("Search started", response);
|
|
206
214
|
},
|
|
207
215
|
onAnchorReceived: (response) => {
|
|
208
|
-
log(
|
|
216
|
+
log("Anchor received", response);
|
|
209
217
|
},
|
|
210
218
|
onHotelsReceived: (response) => {
|
|
211
|
-
log(
|
|
219
|
+
log("Hotels received", response);
|
|
212
220
|
},
|
|
213
221
|
onOffersReceived: (response) => {
|
|
214
|
-
log(
|
|
222
|
+
log("Offers received", response);
|
|
215
223
|
},
|
|
216
224
|
onComplete: (response) => {
|
|
217
|
-
log(
|
|
218
|
-
}
|
|
219
|
-
}
|
|
225
|
+
log("Search completed", response);
|
|
226
|
+
},
|
|
227
|
+
};
|
|
220
228
|
|
|
221
|
-
const search = await sapiClient.search(searchParameters, callbacks)
|
|
229
|
+
const search = await sapiClient.search(searchParameters, callbacks);
|
|
222
230
|
```
|
|
223
231
|
|
|
224
232
|
For full documentation, check [search method api](#search-method).
|
|
225
233
|
|
|
226
234
|
### Get hotel\'s rooms offers
|
|
235
|
+
|
|
227
236
|
<a id="tutorial-get-rooms"></a>
|
|
228
237
|
|
|
229
238
|
Get rooms data and rooms\' offers:
|
|
230
239
|
|
|
231
240
|
```js
|
|
232
241
|
const rooms = await sapiClient.rooms({
|
|
233
|
-
hotelId:
|
|
234
|
-
checkIn:
|
|
235
|
-
checkOut:
|
|
236
|
-
rooms:
|
|
237
|
-
})
|
|
242
|
+
hotelId: "47319",
|
|
243
|
+
checkIn: "2021-10-10",
|
|
244
|
+
checkOut: "2021-10-11",
|
|
245
|
+
rooms: "2",
|
|
246
|
+
});
|
|
238
247
|
```
|
|
239
248
|
|
|
240
249
|
For full documentation, check [rooms method api](#rooms-method).
|
|
241
250
|
|
|
242
251
|
### Get hotel
|
|
252
|
+
|
|
243
253
|
<a id="tutorial-get-hotel"></a>
|
|
244
254
|
|
|
245
255
|
Get hotel by id:
|
|
246
256
|
|
|
247
257
|
```js
|
|
248
|
-
const hotel = await sapiClient.hotel(
|
|
258
|
+
const hotel = await sapiClient.hotel("1196472");
|
|
249
259
|
```
|
|
250
260
|
|
|
251
261
|
For full documentation, check [hotel method api](#hotel-method).
|
|
@@ -255,7 +265,7 @@ For full documentation, check [hotel method api](#hotel-method).
|
|
|
255
265
|
Get hotels by ids:
|
|
256
266
|
|
|
257
267
|
```js
|
|
258
|
-
const hotels = await sapiClient.hotels([
|
|
268
|
+
const hotels = await sapiClient.hotels(["1714808", "1380416", "1710829"]);
|
|
259
269
|
```
|
|
260
270
|
|
|
261
271
|
For full documentation, check [hotels method api](#hotels-method).
|
|
@@ -266,22 +276,22 @@ Get offers for a single hotel:
|
|
|
266
276
|
|
|
267
277
|
```js
|
|
268
278
|
const parameters = {
|
|
269
|
-
hotelId:
|
|
270
|
-
}
|
|
279
|
+
hotelId: "1196472",
|
|
280
|
+
};
|
|
271
281
|
|
|
272
282
|
const callbacks = {
|
|
273
|
-
|
|
274
|
-
log(
|
|
283
|
+
onStart: (response) => {
|
|
284
|
+
log("Offers started", response);
|
|
275
285
|
},
|
|
276
286
|
onOffersReceived: (response) => {
|
|
277
|
-
log(
|
|
287
|
+
log("Offers received", response);
|
|
278
288
|
},
|
|
279
289
|
onComplete: (response) => {
|
|
280
|
-
log(
|
|
281
|
-
}
|
|
282
|
-
}
|
|
290
|
+
log("Offers completed", response);
|
|
291
|
+
},
|
|
292
|
+
};
|
|
283
293
|
|
|
284
|
-
const offers = await sapiClient.offers(parameters, callbacks)
|
|
294
|
+
const offers = await sapiClient.offers(parameters, callbacks);
|
|
285
295
|
```
|
|
286
296
|
|
|
287
297
|
For full documentation, check [offers method api](#offers-method).
|
|
@@ -292,26 +302,26 @@ Get hotel(s) availability:
|
|
|
292
302
|
|
|
293
303
|
```js
|
|
294
304
|
const parameters = {
|
|
295
|
-
hotelIds: [
|
|
296
|
-
startDate:
|
|
297
|
-
endDate:
|
|
305
|
+
hotelIds: ["1380416", "1359951"],
|
|
306
|
+
startDate: "2023-08-05",
|
|
307
|
+
endDate: "2023-08-12",
|
|
298
308
|
nights: 2,
|
|
299
|
-
rooms:
|
|
300
|
-
}
|
|
309
|
+
rooms: "2",
|
|
310
|
+
};
|
|
301
311
|
|
|
302
312
|
const callbacks = {
|
|
303
313
|
onStart: (response) => {
|
|
304
|
-
log(
|
|
314
|
+
log("Availability request started", response);
|
|
305
315
|
},
|
|
306
316
|
onAvailabilityReceived: (response) => {
|
|
307
|
-
log(
|
|
317
|
+
log("Availability received", response);
|
|
308
318
|
},
|
|
309
319
|
onComplete: (response) => {
|
|
310
|
-
log(
|
|
311
|
-
}
|
|
312
|
-
}
|
|
320
|
+
log("Availability completed", response);
|
|
321
|
+
},
|
|
322
|
+
};
|
|
313
323
|
|
|
314
|
-
const response = await sapiClient.hotelAvailability(parameters, callbacks)
|
|
324
|
+
const response = await sapiClient.hotelAvailability(parameters, callbacks);
|
|
315
325
|
```
|
|
316
326
|
|
|
317
327
|
For full documentation, check [availability method api](#hotel-availability-method).
|
|
@@ -319,22 +329,22 @@ For full documentation, check [availability method api](#hotel-availability-meth
|
|
|
319
329
|
# API Reference
|
|
320
330
|
|
|
321
331
|
## SAPI client
|
|
332
|
+
|
|
322
333
|
<a id="sapi-client"></a>
|
|
323
334
|
|
|
324
335
|
Create SAPI client:
|
|
325
336
|
|
|
326
337
|
```js
|
|
327
|
-
const profileKey =
|
|
338
|
+
const profileKey = "profile-key";
|
|
328
339
|
|
|
329
340
|
const sapiClient = await sapi(profileKey, {
|
|
330
|
-
anonymousId:
|
|
331
|
-
language:
|
|
332
|
-
currency:
|
|
333
|
-
countryCode:
|
|
334
|
-
deviceType:
|
|
341
|
+
anonymousId: "fd9dbb5f-b337-4dd7-b640-1f177d1d3caa",
|
|
342
|
+
language: "en",
|
|
343
|
+
currency: "USD",
|
|
344
|
+
countryCode: "US",
|
|
345
|
+
deviceType: "mobile",
|
|
335
346
|
pageSize: 20,
|
|
336
|
-
initWithAppConfig: {
|
|
337
|
-
},
|
|
347
|
+
initWithAppConfig: {},
|
|
338
348
|
algoliaClientOptions: {
|
|
339
349
|
timeouts: {
|
|
340
350
|
connect: 1, // Connection timeout in seconds
|
|
@@ -344,20 +354,21 @@ const sapiClient = await sapi(profileKey, {
|
|
|
344
354
|
},
|
|
345
355
|
callbacks: {
|
|
346
356
|
onConfigReceived: (config) => {
|
|
347
|
-
log(
|
|
348
|
-
}
|
|
357
|
+
log("Config received", config);
|
|
358
|
+
},
|
|
349
359
|
},
|
|
350
360
|
getTotalRate: (rate) => {
|
|
351
|
-
let totalRate = rate.base
|
|
352
|
-
if (includeTaxes) totalRate += rate.taxes
|
|
353
|
-
if (includeHotelFees) totalRate += rate.hotelFees
|
|
361
|
+
let totalRate = rate.base;
|
|
362
|
+
if (includeTaxes) totalRate += rate.taxes;
|
|
363
|
+
if (includeHotelFees) totalRate += rate.hotelFees;
|
|
354
364
|
|
|
355
|
-
return totalRate
|
|
356
|
-
}
|
|
357
|
-
})
|
|
365
|
+
return totalRate;
|
|
366
|
+
},
|
|
367
|
+
});
|
|
358
368
|
```
|
|
359
369
|
|
|
360
370
|
### Supported options
|
|
371
|
+
|
|
361
372
|
<a id="client-options"></a>
|
|
362
373
|
|
|
363
374
|
| name | required | type | default | description | example |
|
|
@@ -375,6 +386,7 @@ const sapiClient = await sapi(profileKey, {
|
|
|
375
386
|
| `getTotalRate` | no | `function` | Total rate including taxes and fees | Function to calculate total display rate based on tax display logic. Used for price filter and sort by price functionalities. | |
|
|
376
387
|
|
|
377
388
|
### Available client callbacks
|
|
389
|
+
|
|
378
390
|
<a id="client-callbacks"></a>
|
|
379
391
|
|
|
380
392
|
1. onConfigReceived(configs)
|
|
@@ -382,6 +394,7 @@ const sapiClient = await sapi(profileKey, {
|
|
|
382
394
|
Returns configuration settings that are used by sapiClient.
|
|
383
395
|
|
|
384
396
|
### Response
|
|
397
|
+
|
|
385
398
|
<a id="config-response"></a>
|
|
386
399
|
|
|
387
400
|
```json
|
|
@@ -411,49 +424,54 @@ const sapiClient = await sapi(profileKey, {
|
|
|
411
424
|
```
|
|
412
425
|
|
|
413
426
|
## `search()` method
|
|
427
|
+
|
|
414
428
|
<a id="search-method"></a>
|
|
415
429
|
|
|
416
430
|
Search is a method of **sapiClient** for searching hotels and offers for
|
|
417
431
|
provided `searchParameters`:
|
|
418
432
|
|
|
419
433
|
```js
|
|
420
|
-
const search = await sapiClient.search(searchParameters, callbacks)
|
|
434
|
+
const search = await sapiClient.search(searchParameters, callbacks);
|
|
421
435
|
```
|
|
422
436
|
|
|
423
437
|
### Search parameters
|
|
438
|
+
|
|
424
439
|
<a id="search-parameters"></a>
|
|
425
440
|
|
|
426
441
|
All parameters are optional.
|
|
427
442
|
|
|
428
|
-
| name
|
|
429
|
-
|
|
430
|
-
| `hotelId`
|
|
431
|
-
| `placeId`
|
|
432
|
-
| `geolocation`
|
|
433
|
-
| `address`
|
|
434
|
-
| `boundingBox`
|
|
435
|
-
| `checkIn`
|
|
436
|
-
| `checkOut`
|
|
437
|
-
| `rooms`
|
|
438
|
-
| `dayDistance`
|
|
439
|
-
| `nights`
|
|
440
|
-
| `sortField`
|
|
441
|
-
| `sortOrder`
|
|
442
|
-
| `filters`
|
|
443
|
-
| `cugDeals`
|
|
444
|
-
| `tier`
|
|
445
|
-
| `originId`
|
|
446
|
-
| `preferredRate`
|
|
447
|
-
| `label`
|
|
448
|
-
| `userId`
|
|
449
|
-
| `emailDomain`
|
|
450
|
-
| `deviceId`
|
|
451
|
-
| `screenshots`
|
|
452
|
-
| `metadata`
|
|
453
|
-
| `offerSort`
|
|
454
|
-
| `
|
|
443
|
+
| name | type | description | example |
|
|
444
|
+
| --------------------- | ----------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- |
|
|
445
|
+
| `hotelId` | `string` | Hotel Id for hotel search | `1371626` |
|
|
446
|
+
| `placeId` | `string` | Place Id for place search | `47319` |
|
|
447
|
+
| `geolocation` | `{lat: number, lon: number, precision: string}` | Geolocation query | `{lat: 36.114303, lon: -115.178312}` |
|
|
448
|
+
| `address` | `string` | Address search string | `Nieuwe Looiersdwarsstraat 17,` |
|
|
449
|
+
| `boundingBox` | `[p1Lat, p1Lng, p2Lat, p2Lng]` | `topLeft` and `bottomRight` coordinates of bounding box to perform search inside it | `[46.650828100116044, 7.123046875, 45.17210966999772, 1.009765625]` |
|
|
450
|
+
| `checkIn` | `string` | Check in date (`YYYY-MM-DD`) | `2021-10-10` |
|
|
451
|
+
| `checkOut` | `string` | Check out date (`YYYY-MM-DD`) | `2021-10-11` |
|
|
452
|
+
| `rooms` | `string` | [Rooms configuration](#rooms-configuration) | `2` |
|
|
453
|
+
| `dayDistance` | `number` | Amount of full days from now to desired check in date (works in combination with `nights` parameter) | `15` |
|
|
454
|
+
| `nights` | `number` | Number of nights of stay | `3` |
|
|
455
|
+
| `sortField` | `string` | Defines the sort by criteria | `popularity, price` |
|
|
456
|
+
| `sortOrder` | `string` | Defines the sort order | `ascending, descending` |
|
|
457
|
+
| `filters` | `Object` | Object with [filters](#search-filters) | `{starRatings: 5}` |
|
|
458
|
+
| `cugDeals` | `string[]` | Codes of closed user group deals to retrieve offers | `['signed_in', 'offline']` |
|
|
459
|
+
| `tier` | `string` | User tier | `member` |
|
|
460
|
+
| `originId` | `string` | Identifier of origin where the request was originated | `c3po6twr70` |
|
|
461
|
+
| `preferredRate` | `number` | Offer\'s price user saw on a CA (meta) platform | `196` |
|
|
462
|
+
| `label` | `string` | Opaque value that will be passed to tracking systems | `gha-vr` |
|
|
463
|
+
| `userId` | `string` | An authenticated user ID, e.g. the Google ID of a user. Used by ACL | `c34b0018-d434-4fad-8de6-9d8e8e18cb35` |
|
|
464
|
+
| `emailDomain` | `string` | Email domain for authenticated user, Used by ACL | `@manatuscostarica.com` |
|
|
465
|
+
| `deviceId` | `string` | Device ID, Used by ACL (the IDFV of an iOS device or the GAID of an Android device) | |
|
|
466
|
+
| `screenshots` | `number` | Number of of screenshot taken by the user and detected by website, Used by ACL | `2` |
|
|
467
|
+
| `metadata` | `Record<string, string>` | Additional metadata to be passed to the search | `{esd: 'abcds', epv: 'qwert'}` |
|
|
468
|
+
| `offerSort` | `string` | If present, sorts offers by price (see [explanation](#sort-offers)) | |
|
|
469
|
+
| `optimizeRooms` | `boolean` | If `true` then rooms optimization logic is enabled for non anchor hotels. Rooms optimization tries to find best offer across possible rooms configurations for a given occupancy | `true` |
|
|
470
|
+
| `optimizeAnchorRooms` | `boolean` | If `true` then rooms optimization logic is enabled for an anchor hotel. Rooms optimization tries to find best offer across possible rooms configurations for a given occupancy | `false` |
|
|
471
|
+
| `sbc` | `string` | [Split Booking Configuration](#splitbookingconfiguration). If present, searches for split booking offers | `sbc: '2~3'` |
|
|
455
472
|
|
|
456
473
|
#### Split Booking Configuration
|
|
474
|
+
|
|
457
475
|
<a id="splitbookingconfiguration"></a>
|
|
458
476
|
The format for the split booking configuration is as follows:
|
|
459
477
|
|
|
@@ -468,7 +486,7 @@ for example if we have these parameters:
|
|
|
468
486
|
|
|
469
487
|
`checkOut:'2023-08-15'`
|
|
470
488
|
|
|
471
|
-
`sbc:2~3`
|
|
489
|
+
`sbc:2~3`
|
|
472
490
|
|
|
473
491
|
The first part of the split booking will be 2 nights and the second part will be 3 nights.
|
|
474
492
|
So, SAPI searches for two stays:
|
|
@@ -477,9 +495,8 @@ split1: `checkIn: '2023-08-10'` `checkOut: '2023-08-12'`
|
|
|
477
495
|
|
|
478
496
|
split2: `checkIn: '2023-08-12'` `checkOut: '2023-08-15'`
|
|
479
497
|
|
|
480
|
-
|
|
481
|
-
|
|
482
498
|
#### Filters
|
|
499
|
+
|
|
483
500
|
<a id="search-filters"></a>
|
|
484
501
|
|
|
485
502
|
| name | type | description | example | filter scope |
|
|
@@ -501,6 +518,7 @@ split2: `checkIn: '2023-08-12'` `checkOut: '2023-08-15'`
|
|
|
501
518
|
| `isVr` | `boolean` | If true, then only vacation rentals are returned. If false, then vacation rentals are filtered out | `true` | Hotel |
|
|
502
519
|
|
|
503
520
|
##### Facilities
|
|
521
|
+
|
|
504
522
|
Some of the favourite facilities used for filtering:
|
|
505
523
|
|
|
506
524
|
| name | id |
|
|
@@ -516,6 +534,7 @@ Some of the favourite facilities used for filtering:
|
|
|
516
534
|
| `air_conditioned` | 21 |
|
|
517
535
|
|
|
518
536
|
##### Property types
|
|
537
|
+
|
|
519
538
|
Some of the property types used for filtering:
|
|
520
539
|
|
|
521
540
|
| name | id |
|
|
@@ -525,8 +544,8 @@ Some of the property types used for filtering:
|
|
|
525
544
|
| `hostel` | 5 |
|
|
526
545
|
| `motel` | 1 |
|
|
527
546
|
|
|
528
|
-
|
|
529
547
|
##### Amenities
|
|
548
|
+
|
|
530
549
|
<a id="filters-amenities"></a>
|
|
531
550
|
Supported amenities:
|
|
532
551
|
|
|
@@ -539,30 +558,30 @@ Supported amenities:
|
|
|
539
558
|
| `fullBoard` | "breakfast && lunch && dinner", or the hotel’s explicit use of the term "full-board" |
|
|
540
559
|
| `allInclusive` | "all meals && all drinks" or the hotel’s explicit use of the term "all-inclusive" |
|
|
541
560
|
|
|
542
|
-
|
|
543
561
|
### Callbacks
|
|
562
|
+
|
|
544
563
|
<a id="search-callbacks"></a>
|
|
545
564
|
|
|
546
565
|
Search method receives callbacks object as the second argument:
|
|
547
566
|
|
|
548
567
|
```js
|
|
549
|
-
const callbacks =
|
|
568
|
+
const callbacks = {
|
|
550
569
|
onStart: (response) => {
|
|
551
|
-
log(
|
|
570
|
+
log("Search started", response);
|
|
552
571
|
},
|
|
553
572
|
onAnchorReceived: (response) => {
|
|
554
|
-
log(
|
|
573
|
+
log("Anchor received", response);
|
|
555
574
|
},
|
|
556
575
|
onHotelsReceived: (response) => {
|
|
557
|
-
log(
|
|
576
|
+
log("Hotels received", response);
|
|
558
577
|
},
|
|
559
578
|
onOffersReceived: (response) => {
|
|
560
|
-
log(
|
|
579
|
+
log("Offers received", response);
|
|
561
580
|
},
|
|
562
581
|
onComplete: (response) => {
|
|
563
|
-
log(
|
|
564
|
-
}
|
|
565
|
-
}
|
|
582
|
+
log("Search completed", response);
|
|
583
|
+
},
|
|
584
|
+
};
|
|
566
585
|
```
|
|
567
586
|
|
|
568
587
|
Each callback returns the full search state available inside SAPI at the
|
|
@@ -614,6 +633,7 @@ the state can be repeated between different callbacks.
|
|
|
614
633
|
The offers response with the detailed description can be found in the [Offers Response](./docs/offers.md)
|
|
615
634
|
|
|
616
635
|
### Response
|
|
636
|
+
|
|
617
637
|
<a id="search-response"></a>
|
|
618
638
|
|
|
619
639
|
The complete SAPI search response is too big to be displayed on the page
|
|
@@ -631,19 +651,24 @@ so there is a simplified example:
|
|
|
631
651
|
"pageSize": 26,
|
|
632
652
|
"placeDisplayName": "Bedrijventerrein Sloterdijk, Amsterdam",
|
|
633
653
|
"priceBucketWidth": 19,
|
|
634
|
-
"_geoloc": {
|
|
654
|
+
"_geoloc": {
|
|
655
|
+
"lat": 52.388326,
|
|
656
|
+
"lon": 4.837264,
|
|
657
|
+
"precision": 5000,
|
|
658
|
+
"radius": 20000
|
|
659
|
+
}
|
|
635
660
|
},
|
|
636
661
|
"anchorHotelId": "1714808",
|
|
637
662
|
"anchorType": "hotel",
|
|
638
663
|
"facets": {
|
|
639
|
-
"facilities": {"1": 212, "2": 348, "3": 116},
|
|
640
|
-
"pricing.medianRateBkt": {"3": 4, "4": 12, "5": 19},
|
|
641
|
-
"pricing.medianRateMoFrBkt": {"3": 4, "4": 6, "5": 8, "6": 9},
|
|
642
|
-
"pricing.medianRateSaSuBkt": {"2": 2, "3": 4, "4": 6, "5": 10},
|
|
643
|
-
"pricing.minRateBkt": {"2": 22, "3": 38, "4": 46, "5": 98},
|
|
644
|
-
"propertyTypeId": {"0": 1030, "2": 6, "3": 601, "4": 86},
|
|
645
|
-
"starRating": {"1": 351, "2": 313, "3": 596, "4": 441, "5": 86},
|
|
646
|
-
"themeIds": {"1": 9, "2": 1373, "3": 143, "5": 1092, "8": 119}
|
|
664
|
+
"facilities": { "1": 212, "2": 348, "3": 116 },
|
|
665
|
+
"pricing.medianRateBkt": { "3": 4, "4": 12, "5": 19 },
|
|
666
|
+
"pricing.medianRateMoFrBkt": { "3": 4, "4": 6, "5": 8, "6": 9 },
|
|
667
|
+
"pricing.medianRateSaSuBkt": { "2": 2, "3": 4, "4": 6, "5": 10 },
|
|
668
|
+
"pricing.minRateBkt": { "2": 22, "3": 38, "4": 46, "5": 98 },
|
|
669
|
+
"propertyTypeId": { "0": 1030, "2": 6, "3": 601, "4": 86 },
|
|
670
|
+
"starRating": { "1": 351, "2": 313, "3": 596, "4": 441, "5": 86 },
|
|
671
|
+
"themeIds": { "1": 9, "2": 1373, "3": 143, "5": 1092, "8": 119 }
|
|
647
672
|
},
|
|
648
673
|
"hotelEntities": {
|
|
649
674
|
"1041597": {
|
|
@@ -653,16 +678,39 @@ so there is a simplified example:
|
|
|
653
678
|
"country": "NL",
|
|
654
679
|
"displayAddress": "Stationsplein 49, Burgwallen-Nieuwe Zijde, Amsterdam, The Netherlands",
|
|
655
680
|
"facilities": [1, 2, 5, 8, 9, 11],
|
|
656
|
-
"guestRating": {
|
|
657
|
-
|
|
681
|
+
"guestRating": {
|
|
682
|
+
"cleanliness": 7.94,
|
|
683
|
+
"dining": 7.51,
|
|
684
|
+
"facilities": 7.54,
|
|
685
|
+
"location": 8.09,
|
|
686
|
+
"overall": 7.83,
|
|
687
|
+
"service": 8.8
|
|
688
|
+
},
|
|
689
|
+
"guestType": {
|
|
690
|
+
"business": 793,
|
|
691
|
+
"couples": 2558,
|
|
692
|
+
"families": 1145,
|
|
693
|
+
"groups": 1276,
|
|
694
|
+
"solo": 398
|
|
695
|
+
},
|
|
658
696
|
"hotelName": "ibis Amsterdam Centre",
|
|
659
|
-
"imageURIs": [
|
|
697
|
+
"imageURIs": [
|
|
698
|
+
"https://i.travelapi.com/hotels/1000000/30000/25600/25525/c2387aed_w.jpg"
|
|
699
|
+
],
|
|
660
700
|
"isDeleted": false,
|
|
661
701
|
"lastBooked": 1658320362,
|
|
662
702
|
"objectID": "1041597",
|
|
663
703
|
"parentChainID": "10",
|
|
664
704
|
"placeDisplayName": "Burgwallen-Nieuwe Zijde, Amsterdam",
|
|
665
|
-
"pricing": {
|
|
705
|
+
"pricing": {
|
|
706
|
+
"medianRateBkt": 12,
|
|
707
|
+
"medianRateMoFrBkt": 13,
|
|
708
|
+
"medianRateSaSuBkt": 11,
|
|
709
|
+
"minRate": 116,
|
|
710
|
+
"minRateBkt": 75,
|
|
711
|
+
"minRateBkt": 5,
|
|
712
|
+
"priced": 1
|
|
713
|
+
},
|
|
666
714
|
"propertyTypeId": 0,
|
|
667
715
|
"regularPriceRange": [224, 243],
|
|
668
716
|
"reviewCount": 5766,
|
|
@@ -670,7 +718,7 @@ so there is a simplified example:
|
|
|
670
718
|
"starRating": 3,
|
|
671
719
|
"tags": ["b220918-1"],
|
|
672
720
|
"themeIds": [2, 5, 12],
|
|
673
|
-
"_geoloc": {"lat": 52.37947, "lon": 4.89699}
|
|
721
|
+
"_geoloc": { "lat": 52.37947, "lon": 4.89699 }
|
|
674
722
|
}
|
|
675
723
|
},
|
|
676
724
|
"hotelIds": ["1840170", "2766940", "3310443", "3035769"],
|
|
@@ -699,15 +747,11 @@ so there is a simplified example:
|
|
|
699
747
|
"intermediaryProvider": "BKS",
|
|
700
748
|
"roomName": "Standard Twin Room",
|
|
701
749
|
"package": {
|
|
702
|
-
"amenities": [
|
|
703
|
-
"breakfast"
|
|
704
|
-
],
|
|
750
|
+
"amenities": ["breakfast"],
|
|
705
751
|
"canPayLater": false
|
|
706
752
|
},
|
|
707
753
|
"cancellationPenalties": [],
|
|
708
|
-
"tags": [
|
|
709
|
-
"top_offer"
|
|
710
|
-
],
|
|
754
|
+
"tags": ["top_offer"],
|
|
711
755
|
"metadata": {
|
|
712
756
|
"feedID": ""
|
|
713
757
|
}
|
|
@@ -740,24 +784,30 @@ so there is a simplified example:
|
|
|
740
784
|
```
|
|
741
785
|
|
|
742
786
|
### Load more results and load more offers for a hotel
|
|
787
|
+
|
|
743
788
|
After the search is complete:
|
|
789
|
+
|
|
744
790
|
```js
|
|
745
|
-
const search = await sapiClient.search(searchParameters, callbacks)
|
|
791
|
+
const search = await sapiClient.search(searchParameters, callbacks);
|
|
746
792
|
```
|
|
793
|
+
|
|
747
794
|
it resolves in the `search` object which has 2 methods:
|
|
795
|
+
|
|
748
796
|
- `search.loadMore()` - SDK will return the next set of results ("next" page) for the given search. The same [callbacks](#search-callbacks) from original search will be used.
|
|
749
797
|
- `search.loadOffers(hotelId, {filters, offersSort})` - will load all offers (up to 23) for the provided `hotelId`. You can also override [offers' scope filters](#filters) and [offers' sort order](#sort-offers).
|
|
750
798
|
|
|
751
799
|
## `suggest()` method
|
|
800
|
+
|
|
752
801
|
<a id="suggest-method"></a>
|
|
753
802
|
|
|
754
803
|
Suggest provides autosuggestions for a given query
|
|
755
804
|
|
|
756
805
|
```js
|
|
757
|
-
const suggestions = await sapiClient.suggest(
|
|
806
|
+
const suggestions = await sapiClient.suggest("London", 6);
|
|
758
807
|
```
|
|
759
808
|
|
|
760
809
|
### Suggest parameters
|
|
810
|
+
|
|
761
811
|
<a id="suggest-parameters"></a>
|
|
762
812
|
|
|
763
813
|
| name | type | description | required | example |
|
|
@@ -766,11 +816,13 @@ const suggestions = await sapiClient.suggest('London', 6)
|
|
|
766
816
|
| `suggestsCount` | `number` | Desired number of suggestions (default 6) | no | `10` |
|
|
767
817
|
|
|
768
818
|
### Response
|
|
819
|
+
|
|
769
820
|
<a id="suggest-response"></a>
|
|
770
821
|
|
|
771
822
|
```js
|
|
772
|
-
const suggestions = await sapiClient.suggest(
|
|
823
|
+
const suggestions = await sapiClient.suggest("London", 2);
|
|
773
824
|
```
|
|
825
|
+
|
|
774
826
|
```json
|
|
775
827
|
[
|
|
776
828
|
{
|
|
@@ -791,9 +843,11 @@ const suggestions = await sapiClient.suggest('London', 2)
|
|
|
791
843
|
}
|
|
792
844
|
]
|
|
793
845
|
```
|
|
846
|
+
|
|
794
847
|
```js
|
|
795
|
-
const suggestions = await sapiClient.suggest(
|
|
848
|
+
const suggestions = await sapiClient.suggest("London hotel", 2);
|
|
796
849
|
```
|
|
850
|
+
|
|
797
851
|
```json
|
|
798
852
|
[
|
|
799
853
|
{
|
|
@@ -815,8 +869,8 @@ const suggestions = await sapiClient.suggest('London hotel', 2)
|
|
|
815
869
|
]
|
|
816
870
|
```
|
|
817
871
|
|
|
818
|
-
|
|
819
872
|
## `rooms()` method
|
|
873
|
+
|
|
820
874
|
<a id="rooms-method"></a>
|
|
821
875
|
|
|
822
876
|
Rooms is a method of **sapiClient** for retrieving rooms information and
|
|
@@ -824,18 +878,19 @@ offers for a particular itinerary:
|
|
|
824
878
|
|
|
825
879
|
```js
|
|
826
880
|
const rooms = await sapiClient.rooms({
|
|
827
|
-
hotelId:
|
|
828
|
-
checkIn:
|
|
829
|
-
checkOut:
|
|
830
|
-
rooms:
|
|
831
|
-
})
|
|
881
|
+
hotelId: "1714808",
|
|
882
|
+
checkIn: "2021-10-10",
|
|
883
|
+
checkOut: "2021-10-11",
|
|
884
|
+
rooms: "2",
|
|
885
|
+
});
|
|
832
886
|
```
|
|
833
887
|
|
|
834
888
|
### Rooms parameters
|
|
889
|
+
|
|
835
890
|
<a id="rooms-parameters"></a>
|
|
836
891
|
|
|
837
892
|
| name | type | description | required | example |
|
|
838
|
-
|
|
893
|
+
| ----------------------- | ------------------------ | ------------------------------------------------------------------------------ | -------- | ------------------------------------------------- |
|
|
839
894
|
| `hotelId` | `string` | Hotel Id to retrieve rooms | yes | `1714808` |
|
|
840
895
|
| `checkIn` | `string` | Check in date (`YYYY-MM-DD`) | yes | `2021-10-10` |
|
|
841
896
|
| `checkOut` | `string` | Check out date (`YYYY-MM-DD`) | yes | `2021-10-11` |
|
|
@@ -854,8 +909,10 @@ const rooms = await sapiClient.rooms({
|
|
|
854
909
|
| `deviceId` | `string` | Device ID (the IDFV of an iOS device or the GAID of an Android device) | no | |
|
|
855
910
|
| `searchId` | `string` | SearchId override (SDK generates a new one if no provided) | no | `08230dfcc5f0fb95caaa82ce559ea60c4a975d6f` |
|
|
856
911
|
| `metadata` | `Record<string, string>` | Additional data to be passed to API | no | `{vclid: '21d2d152-de19-4f39-b40a-d4bc3002c6e8'}` |
|
|
912
|
+
| `bundleId` | `string` | Bundle Id clicked on SRP. Used to fetch bundle data from cache | no | `13b5d152-de19-4f39-b40a-d4bc3002c3u9` |
|
|
857
913
|
|
|
858
914
|
### Response
|
|
915
|
+
|
|
859
916
|
<a id="rooms-response"></a>
|
|
860
917
|
|
|
861
918
|
```json
|
|
@@ -869,7 +926,7 @@ const rooms = await sapiClient.rooms({
|
|
|
869
926
|
"bedTypes": [],
|
|
870
927
|
"description": "20 sqm room Continental breakfast included Free WiFi LCD TV Spacious work desk Choice of pillows Coffee and tea facilities Large walk-in power shower",
|
|
871
928
|
"id": "K0LnAe-G9WI",
|
|
872
|
-
"images": [{"url": "http://images.getaroom-cdn.com/image/...."}],
|
|
929
|
+
"images": [{ "url": "http://images.getaroom-cdn.com/image/...." }],
|
|
873
930
|
"masterId": "9643931",
|
|
874
931
|
"name": "1 Double Standard",
|
|
875
932
|
"offers": [
|
|
@@ -879,17 +936,21 @@ const rooms = await sapiClient.rooms({
|
|
|
879
936
|
"cancellationPenalties": [],
|
|
880
937
|
"cug": ["signed_in"],
|
|
881
938
|
"id": "o0KDe_mFPN4k",
|
|
882
|
-
"links": [
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
939
|
+
"links": [
|
|
940
|
+
{
|
|
941
|
+
"href": "https://secure.findhotel.net/checkout/?hotelID=1714808...",
|
|
942
|
+
"method": "GET",
|
|
943
|
+
"type": "checkout"
|
|
944
|
+
}
|
|
945
|
+
],
|
|
946
|
+
"prices": [
|
|
947
|
+
{
|
|
948
|
+
"chargeable": { "base": "1352.77", "taxes": "59.94" },
|
|
949
|
+
"currencyCode": "EUR",
|
|
950
|
+
"hotelFees": { "breakdown": [], "total": "0" },
|
|
951
|
+
"type": "chargeable_currency"
|
|
952
|
+
}
|
|
953
|
+
],
|
|
893
954
|
"providerCode": "GAR",
|
|
894
955
|
"providerRateType": "public",
|
|
895
956
|
"services": ["breakfast"]
|
|
@@ -900,17 +961,18 @@ const rooms = await sapiClient.rooms({
|
|
|
900
961
|
}
|
|
901
962
|
```
|
|
902
963
|
|
|
903
|
-
|
|
904
964
|
## `hotel()` method
|
|
965
|
+
|
|
905
966
|
<a id="hotel-method"></a>
|
|
906
967
|
|
|
907
968
|
Hotel is a method of **sapiClient** for retrieving a single hotel by id
|
|
908
969
|
|
|
909
970
|
```js
|
|
910
|
-
const hotel = await sapiClient.hotel(
|
|
971
|
+
const hotel = await sapiClient.hotel("1196472");
|
|
911
972
|
```
|
|
912
973
|
|
|
913
974
|
### Hotel parameters
|
|
975
|
+
|
|
914
976
|
<a id="hotel-parameters"></a>
|
|
915
977
|
|
|
916
978
|
| name | type | description | required | example |
|
|
@@ -918,6 +980,7 @@ const hotel = await sapiClient.hotel('1196472')
|
|
|
918
980
|
| `hotelId` | `string` | Hotel Id | yes | `1196472` |
|
|
919
981
|
|
|
920
982
|
### Response
|
|
983
|
+
|
|
921
984
|
<a id="hotel-response"></a>
|
|
922
985
|
|
|
923
986
|
An example of the response for request with `hotelId` 1196472
|
|
@@ -961,7 +1024,8 @@ and \"pt-BR\" `language`
|
|
|
961
1024
|
"feesMnd": "<p>Você deverá pagar os seguintes encargos no estabelecimento:</p> <ul><li>Depósito: EUR 50 por noite</li><li>A cidade cobra um imposto de EUR 3.00 por pessoa, por noite até 21 noites. Esse imposto não se aplica a crianças de até 16 anos. </li><li>Será cobrado um imposto municipal/local de 6.422 %</li></ul> <p>Incluímos todas as cobranças que o estabelecimento nos forneceu. No entanto, as cobranças podem variar com base, por exemplo, na duração da estadia ou no tipo de quarto reservado. </p>",
|
|
962
1025
|
"reviewCountBkt": 9,
|
|
963
1026
|
"hotelName": "Movenpick Hotel Amsterdam City Centre",
|
|
964
|
-
"sentiments": [
|
|
1027
|
+
"sentiments": [
|
|
1028
|
+
{
|
|
965
1029
|
"value": "Gostou do bar",
|
|
966
1030
|
"id": 46
|
|
967
1031
|
},
|
|
@@ -970,7 +1034,8 @@ and \"pt-BR\" `language`
|
|
|
970
1034
|
"id": 180
|
|
971
1035
|
}
|
|
972
1036
|
],
|
|
973
|
-
"facilities": [
|
|
1037
|
+
"facilities": [
|
|
1038
|
+
{
|
|
974
1039
|
"categoryID": 4,
|
|
975
1040
|
"importance": 2,
|
|
976
1041
|
"value": "Centro de Negócios",
|
|
@@ -991,7 +1056,8 @@ and \"pt-BR\" `language`
|
|
|
991
1056
|
"groups": 1121,
|
|
992
1057
|
"solo": 206
|
|
993
1058
|
},
|
|
994
|
-
"themes": [
|
|
1059
|
+
"themes": [
|
|
1060
|
+
{
|
|
995
1061
|
"value": "Cidade",
|
|
996
1062
|
"id": 2
|
|
997
1063
|
},
|
|
@@ -1010,15 +1076,17 @@ and \"pt-BR\" `language`
|
|
|
1010
1076
|
```
|
|
1011
1077
|
|
|
1012
1078
|
## `hotels()` method
|
|
1079
|
+
|
|
1013
1080
|
<a id="hotels-method"></a>
|
|
1014
1081
|
|
|
1015
1082
|
Hotel is a method of **sapiClient** for retrieving multiple hotels by hotel ids
|
|
1016
1083
|
|
|
1017
1084
|
```js
|
|
1018
|
-
const hotels = await sapiClient.hotels([
|
|
1085
|
+
const hotels = await sapiClient.hotels(["1714808", "1380416", "1710829"]);
|
|
1019
1086
|
```
|
|
1020
1087
|
|
|
1021
1088
|
### Hotels parameters
|
|
1089
|
+
|
|
1022
1090
|
<a id="hotels-parameters"></a>
|
|
1023
1091
|
|
|
1024
1092
|
| name | type | description | required | example |
|
|
@@ -1026,6 +1094,7 @@ const hotels = await sapiClient.hotels(['1714808','1380416','1710829'])
|
|
|
1026
1094
|
| `hotelIds` | `string[]` | Hotel Ids | yes | `['1714808','1380416','1710829']` |
|
|
1027
1095
|
|
|
1028
1096
|
### Response
|
|
1097
|
+
|
|
1029
1098
|
<a id="hotel-response"></a>
|
|
1030
1099
|
|
|
1031
1100
|
An example of the response for request with `hotelId` 1196472
|
|
@@ -1070,7 +1139,8 @@ and \"pt-BR\" `language`
|
|
|
1070
1139
|
"feesMnd": "<p>Você deverá pagar os seguintes encargos no estabelecimento:</p> <ul><li>Depósito: EUR 50 por noite</li><li>A cidade cobra um imposto de EUR 3.00 por pessoa, por noite até 21 noites. Esse imposto não se aplica a crianças de até 16 anos. </li><li>Será cobrado um imposto municipal/local de 6.422 %</li></ul> <p>Incluímos todas as cobranças que o estabelecimento nos forneceu. No entanto, as cobranças podem variar com base, por exemplo, na duração da estadia ou no tipo de quarto reservado. </p>",
|
|
1071
1140
|
"reviewCountBkt": 9,
|
|
1072
1141
|
"hotelName": "Movenpick Hotel Amsterdam City Centre",
|
|
1073
|
-
"sentiments": [
|
|
1142
|
+
"sentiments": [
|
|
1143
|
+
{
|
|
1074
1144
|
"value": "Gostou do bar",
|
|
1075
1145
|
"id": 46
|
|
1076
1146
|
},
|
|
@@ -1079,7 +1149,8 @@ and \"pt-BR\" `language`
|
|
|
1079
1149
|
"id": 180
|
|
1080
1150
|
}
|
|
1081
1151
|
],
|
|
1082
|
-
"facilities": [
|
|
1152
|
+
"facilities": [
|
|
1153
|
+
{
|
|
1083
1154
|
"categoryID": 4,
|
|
1084
1155
|
"importance": 2,
|
|
1085
1156
|
"value": "Centro de Negócios",
|
|
@@ -1100,7 +1171,8 @@ and \"pt-BR\" `language`
|
|
|
1100
1171
|
"groups": 1121,
|
|
1101
1172
|
"solo": 206
|
|
1102
1173
|
},
|
|
1103
|
-
"themes": [
|
|
1174
|
+
"themes": [
|
|
1175
|
+
{
|
|
1104
1176
|
"value": "Cidade",
|
|
1105
1177
|
"id": 2
|
|
1106
1178
|
},
|
|
@@ -1120,34 +1192,36 @@ and \"pt-BR\" `language`
|
|
|
1120
1192
|
```
|
|
1121
1193
|
|
|
1122
1194
|
## `offers()` method
|
|
1195
|
+
|
|
1123
1196
|
<a id="offers-method"></a>
|
|
1124
1197
|
|
|
1125
1198
|
Retrieves offers for a single hotel by provided parameters
|
|
1126
1199
|
|
|
1127
1200
|
```js
|
|
1128
1201
|
const parameters = {
|
|
1129
|
-
hotelId:
|
|
1130
|
-
checkIn:
|
|
1131
|
-
checkOut:
|
|
1132
|
-
rooms:
|
|
1133
|
-
}
|
|
1202
|
+
hotelId: "1196472",
|
|
1203
|
+
checkIn: "2022-10-10",
|
|
1204
|
+
checkOut: "2022-10-11",
|
|
1205
|
+
rooms: "2",
|
|
1206
|
+
};
|
|
1134
1207
|
|
|
1135
1208
|
const callbacks = {
|
|
1136
|
-
|
|
1137
|
-
log(
|
|
1209
|
+
onStart: (response) => {
|
|
1210
|
+
log("Offers started", response);
|
|
1138
1211
|
},
|
|
1139
1212
|
onOffersReceived: (response) => {
|
|
1140
|
-
log(
|
|
1213
|
+
log("Offers received", response);
|
|
1141
1214
|
},
|
|
1142
1215
|
onComplete: (response) => {
|
|
1143
|
-
log(
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1216
|
+
log("Offers completed", response);
|
|
1217
|
+
},
|
|
1218
|
+
};
|
|
1146
1219
|
|
|
1147
|
-
const offers = await sapiClient.offers(parameters, callbacks)
|
|
1220
|
+
const offers = await sapiClient.offers(parameters, callbacks);
|
|
1148
1221
|
```
|
|
1149
1222
|
|
|
1150
1223
|
### Offers parameters
|
|
1224
|
+
|
|
1151
1225
|
<a id="offers-parameters"></a>
|
|
1152
1226
|
|
|
1153
1227
|
| name | type | description | required | example |
|
|
@@ -1175,6 +1249,7 @@ const offers = await sapiClient.offers(parameters, callbacks)
|
|
|
1175
1249
|
|
|
1176
1250
|
<a id="sort-offers"></a>
|
|
1177
1251
|
Offer sorting by one parameter for now. It is `price`, but there are different variants of sorting by price.:
|
|
1252
|
+
|
|
1178
1253
|
- **price:base_asc** - sort offers by base price ascending
|
|
1179
1254
|
- **price:total_asc** - sort offers by total rate breakdown ascending
|
|
1180
1255
|
- **price:with_tax_asc** - sort offers by base rate with tax ascending
|
|
@@ -1186,17 +1261,17 @@ It overwrites OSO sorting and sorting boost as well. If offersSort parameter is
|
|
|
1186
1261
|
Object with callbacks:
|
|
1187
1262
|
|
|
1188
1263
|
```js
|
|
1189
|
-
const callbacks =
|
|
1264
|
+
const callbacks = {
|
|
1190
1265
|
onStart: (response) => {
|
|
1191
|
-
log(
|
|
1266
|
+
log("Offers started", response);
|
|
1192
1267
|
},
|
|
1193
1268
|
onOffersReceived: (response) => {
|
|
1194
|
-
log(
|
|
1269
|
+
log("Offers received", response);
|
|
1195
1270
|
},
|
|
1196
1271
|
onComplete: (response) => {
|
|
1197
|
-
log(
|
|
1198
|
-
}
|
|
1199
|
-
}
|
|
1272
|
+
log("Offers completed", response);
|
|
1273
|
+
},
|
|
1274
|
+
};
|
|
1200
1275
|
```
|
|
1201
1276
|
|
|
1202
1277
|
1. ### onStart()
|
|
@@ -1215,52 +1290,54 @@ const callbacks = {
|
|
|
1215
1290
|
Returns hotel\'s offers (complete response).
|
|
1216
1291
|
|
|
1217
1292
|
### Response
|
|
1293
|
+
|
|
1218
1294
|
<a id="offers-response"></a>
|
|
1219
1295
|
|
|
1220
1296
|
An example of the response for request parameters:
|
|
1221
1297
|
|
|
1222
1298
|
```js
|
|
1223
1299
|
const parameters = {
|
|
1224
|
-
hotelId:
|
|
1225
|
-
checkIn:
|
|
1226
|
-
checkOut:
|
|
1227
|
-
rooms:
|
|
1228
|
-
}
|
|
1300
|
+
hotelId: "1926746",
|
|
1301
|
+
checkIn: "2022-07-10",
|
|
1302
|
+
checkOut: "2022-07-11",
|
|
1303
|
+
rooms: "2",
|
|
1304
|
+
};
|
|
1229
1305
|
```
|
|
1230
1306
|
|
|
1231
1307
|
The response with the detailed description can be found in the [Offers Response](./docs/offers.md)
|
|
1232
1308
|
|
|
1233
|
-
|
|
1234
1309
|
## `hotelAvailability()` method
|
|
1310
|
+
|
|
1235
1311
|
<a id="hotel-availability-method"></a>
|
|
1236
1312
|
|
|
1237
1313
|
Returns availability of the provided hotels for different dates (aka price calendar)
|
|
1238
1314
|
|
|
1239
1315
|
```js
|
|
1240
1316
|
const parameters = {
|
|
1241
|
-
hotelIds: [
|
|
1242
|
-
startDate:
|
|
1243
|
-
endDate:
|
|
1317
|
+
hotelIds: ["1380416", "1359951"],
|
|
1318
|
+
startDate: "2023-08-05",
|
|
1319
|
+
endDate: "2023-08-12",
|
|
1244
1320
|
nights: 2,
|
|
1245
|
-
rooms:
|
|
1246
|
-
}
|
|
1321
|
+
rooms: "2",
|
|
1322
|
+
};
|
|
1247
1323
|
|
|
1248
1324
|
const callbacks = {
|
|
1249
1325
|
onStart: (response) => {
|
|
1250
|
-
log(
|
|
1326
|
+
log("Availability request started", response);
|
|
1251
1327
|
},
|
|
1252
1328
|
onAvailabilityReceived: (response) => {
|
|
1253
|
-
log(
|
|
1329
|
+
log("Availability received", response);
|
|
1254
1330
|
},
|
|
1255
1331
|
onComplete: (response) => {
|
|
1256
|
-
log(
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1332
|
+
log("Availability completed", response);
|
|
1333
|
+
},
|
|
1334
|
+
};
|
|
1259
1335
|
|
|
1260
|
-
const response = await sapiClient.hotelAvailability(parameters, callbacks)
|
|
1336
|
+
const response = await sapiClient.hotelAvailability(parameters, callbacks);
|
|
1261
1337
|
```
|
|
1262
1338
|
|
|
1263
1339
|
### Hotel(s) availability search parameters
|
|
1340
|
+
|
|
1264
1341
|
<a id="availability-search-parameters"></a>
|
|
1265
1342
|
|
|
1266
1343
|
| name | type | description | required | example |
|
|
@@ -1275,22 +1352,23 @@ const response = await sapiClient.hotelAvailability(parameters, callbacks)
|
|
|
1275
1352
|
| `originId` | `string` | Identifier of origin where the request was originated | no | `'c3po6twr70'` |
|
|
1276
1353
|
|
|
1277
1354
|
### Callbacks
|
|
1355
|
+
|
|
1278
1356
|
<a id="availability-callbacks"></a>
|
|
1279
1357
|
|
|
1280
1358
|
Object with callbacks:
|
|
1281
1359
|
|
|
1282
1360
|
```js
|
|
1283
|
-
const callbacks =
|
|
1361
|
+
const callbacks = {
|
|
1284
1362
|
onStart: (response) => {
|
|
1285
|
-
log(
|
|
1363
|
+
log("Availability request started", response);
|
|
1286
1364
|
},
|
|
1287
1365
|
onAvailabilityReceived: (response) => {
|
|
1288
|
-
log(
|
|
1366
|
+
log("Availability received", response);
|
|
1289
1367
|
},
|
|
1290
1368
|
onComplete: (response) => {
|
|
1291
|
-
log(
|
|
1292
|
-
}
|
|
1293
|
-
}
|
|
1369
|
+
log("Availability completed", response);
|
|
1370
|
+
},
|
|
1371
|
+
};
|
|
1294
1372
|
```
|
|
1295
1373
|
|
|
1296
1374
|
1. ### onStart()
|
|
@@ -1309,6 +1387,7 @@ const callbacks = {
|
|
|
1309
1387
|
Returns availability with offers (complete response).
|
|
1310
1388
|
|
|
1311
1389
|
### Response
|
|
1390
|
+
|
|
1312
1391
|
<a id="availability-response"></a>
|
|
1313
1392
|
|
|
1314
1393
|
An example of the response:
|
|
@@ -1338,9 +1417,7 @@ An example of the response:
|
|
|
1338
1417
|
"providerCode": "WTM",
|
|
1339
1418
|
"intermediaryProvider": "FHT",
|
|
1340
1419
|
"package": {
|
|
1341
|
-
"amenities": [
|
|
1342
|
-
"breakfast"
|
|
1343
|
-
],
|
|
1420
|
+
"amenities": ["breakfast"],
|
|
1344
1421
|
"canPayLater": false
|
|
1345
1422
|
},
|
|
1346
1423
|
"cancellationPenalties": [
|
|
@@ -1351,16 +1428,13 @@ An example of the response:
|
|
|
1351
1428
|
"currency": "EUR"
|
|
1352
1429
|
}
|
|
1353
1430
|
],
|
|
1354
|
-
"tags": [
|
|
1355
|
-
"top_offer",
|
|
1356
|
-
"exclusive_cheapest_offer"
|
|
1357
|
-
],
|
|
1431
|
+
"tags": ["top_offer", "exclusive_cheapest_offer"],
|
|
1358
1432
|
"metadata": {
|
|
1359
1433
|
"providerRateType": "member",
|
|
1360
1434
|
"feedID": ""
|
|
1361
1435
|
},
|
|
1362
1436
|
"roomName": "STANDARD DOUBLE/TWIN"
|
|
1363
|
-
}
|
|
1437
|
+
}
|
|
1364
1438
|
]
|
|
1365
1439
|
},
|
|
1366
1440
|
"2023-08-06": {
|
|
@@ -1380,21 +1454,16 @@ An example of the response:
|
|
|
1380
1454
|
"base": 493.9438317757,
|
|
1381
1455
|
"taxes": 32.2961682243,
|
|
1382
1456
|
"hotelFees": 0
|
|
1383
|
-
|
|
1457
|
+
},
|
|
1384
1458
|
"accessTier": "sensitive",
|
|
1385
1459
|
"providerCode": "WTM",
|
|
1386
1460
|
"intermediaryProvider": "FHT",
|
|
1387
1461
|
"package": {
|
|
1388
|
-
"amenities": [
|
|
1389
|
-
"breakfast"
|
|
1390
|
-
],
|
|
1462
|
+
"amenities": ["breakfast"],
|
|
1391
1463
|
"canPayLater": false
|
|
1392
1464
|
},
|
|
1393
1465
|
"cancellationPenalties": [],
|
|
1394
|
-
"tags": [
|
|
1395
|
-
"top_offer",
|
|
1396
|
-
"exclusive_cheapest_offer"
|
|
1397
|
-
],
|
|
1466
|
+
"tags": ["top_offer", "exclusive_cheapest_offer"],
|
|
1398
1467
|
"metadata": {
|
|
1399
1468
|
"providerRateType": "member",
|
|
1400
1469
|
"feedID": ""
|
|
@@ -1408,8 +1477,10 @@ An example of the response:
|
|
|
1408
1477
|
```
|
|
1409
1478
|
|
|
1410
1479
|
## Rooms configuration
|
|
1480
|
+
|
|
1411
1481
|
<a id="rooms-configuration"></a>
|
|
1412
1482
|
`rooms` is a string that encodes the configuration of rooms requested by the user and follows the next rules:
|
|
1483
|
+
|
|
1413
1484
|
- Rooms are separated by pipe `|`
|
|
1414
1485
|
- Adults and children are separated by colon `:`
|
|
1415
1486
|
- Children ages are separated by comma `,`
|
|
@@ -1430,15 +1501,15 @@ SAPI SDK exposes a special method `generateSearchId` to generate `searchId` whic
|
|
|
1430
1501
|
#### Example
|
|
1431
1502
|
|
|
1432
1503
|
```js
|
|
1433
|
-
import {generateSearchId} from
|
|
1504
|
+
import { generateSearchId } from "@findhotel/sapi";
|
|
1434
1505
|
|
|
1435
|
-
const searchId = generateSearchId()
|
|
1506
|
+
const searchId = generateSearchId();
|
|
1436
1507
|
|
|
1437
1508
|
const rooms = await sapiClient.rooms({
|
|
1438
|
-
hotelId:
|
|
1439
|
-
checkIn:
|
|
1440
|
-
checkOut:
|
|
1441
|
-
rooms:
|
|
1442
|
-
searchId
|
|
1443
|
-
})
|
|
1509
|
+
hotelId: "47319",
|
|
1510
|
+
checkIn: "2023-10-10",
|
|
1511
|
+
checkOut: "2023-10-11",
|
|
1512
|
+
rooms: "2",
|
|
1513
|
+
searchId,
|
|
1514
|
+
});
|
|
1444
1515
|
```
|