@findhotel/sapi 1.12.0 → 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 +308 -239
- package/dist/index.js +1 -1
- package/package.json +1 -1
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,24 +354,25 @@ 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 |
|
|
364
|
-
|
|
375
|
+
| ---------------------- | -------- | ------------------------ | ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
|
|
365
376
|
| `anonymousId` | yes | `string` | | Unique ID identifying users | `2d360284-577b-4a53-8b91-68f72b9227fa` |
|
|
366
377
|
| `language` | no | `string` | `en` | 2-char language code | `en` |
|
|
367
378
|
| `currency` | no | `string` | `USD` | 3-char uppercased ISO currency code | `USD` |
|
|
@@ -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,22 +424,24 @@ 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
443
|
| name | type | description | example |
|
|
429
|
-
|
|
444
|
+
| --------------------- | ----------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- |
|
|
430
445
|
| `hotelId` | `string` | Hotel Id for hotel search | `1371626` |
|
|
431
446
|
| `placeId` | `string` | Place Id for place search | `47319` |
|
|
432
447
|
| `geolocation` | `{lat: number, lon: number, precision: string}` | Geolocation query | `{lat: 36.114303, lon: -115.178312}` |
|
|
@@ -456,6 +471,7 @@ All parameters are optional.
|
|
|
456
471
|
| `sbc` | `string` | [Split Booking Configuration](#splitbookingconfiguration). If present, searches for split booking offers | `sbc: '2~3'` |
|
|
457
472
|
|
|
458
473
|
#### Split Booking Configuration
|
|
474
|
+
|
|
459
475
|
<a id="splitbookingconfiguration"></a>
|
|
460
476
|
The format for the split booking configuration is as follows:
|
|
461
477
|
|
|
@@ -470,7 +486,7 @@ for example if we have these parameters:
|
|
|
470
486
|
|
|
471
487
|
`checkOut:'2023-08-15'`
|
|
472
488
|
|
|
473
|
-
`sbc:2~3`
|
|
489
|
+
`sbc:2~3`
|
|
474
490
|
|
|
475
491
|
The first part of the split booking will be 2 nights and the second part will be 3 nights.
|
|
476
492
|
So, SAPI searches for two stays:
|
|
@@ -479,13 +495,12 @@ split1: `checkIn: '2023-08-10'` `checkOut: '2023-08-12'`
|
|
|
479
495
|
|
|
480
496
|
split2: `checkIn: '2023-08-12'` `checkOut: '2023-08-15'`
|
|
481
497
|
|
|
482
|
-
|
|
483
|
-
|
|
484
498
|
#### Filters
|
|
499
|
+
|
|
485
500
|
<a id="search-filters"></a>
|
|
486
501
|
|
|
487
502
|
| name | type | description | example | filter scope |
|
|
488
|
-
|
|
503
|
+
| ------------------ | ---------- | -------------------------------------------------------------------------------------------------- | ------------------------------ | ------------ |
|
|
489
504
|
| `themeIds` | `number[]` | Facet filtering by theme ids | `[1, 2, 3]` | Hotel |
|
|
490
505
|
| `chainIds` | `number[]` | Hotels' chain ids | `[4, 5]` | Hotel |
|
|
491
506
|
| `facilities` | `string[]` | Facility ids used for facet filtering | `[299,7,6,21]` | Hotel |
|
|
@@ -503,10 +518,11 @@ split2: `checkIn: '2023-08-12'` `checkOut: '2023-08-15'`
|
|
|
503
518
|
| `isVr` | `boolean` | If true, then only vacation rentals are returned. If false, then vacation rentals are filtered out | `true` | Hotel |
|
|
504
519
|
|
|
505
520
|
##### Facilities
|
|
521
|
+
|
|
506
522
|
Some of the favourite facilities used for filtering:
|
|
507
523
|
|
|
508
524
|
| name | id |
|
|
509
|
-
|
|
525
|
+
| ----------------- | --- |
|
|
510
526
|
| `free_wifi` | 299 |
|
|
511
527
|
| `swimming_pool` | 7 |
|
|
512
528
|
| `restaurant` | 5 |
|
|
@@ -518,22 +534,23 @@ Some of the favourite facilities used for filtering:
|
|
|
518
534
|
| `air_conditioned` | 21 |
|
|
519
535
|
|
|
520
536
|
##### Property types
|
|
521
|
-
Some of the property types used for filtering:
|
|
522
537
|
|
|
523
|
-
|
|
524
|
-
|-------------|----|
|
|
525
|
-
| `hotel` | 0 |
|
|
526
|
-
| `apartment` | 9 |
|
|
527
|
-
| `hostel` | 5 |
|
|
528
|
-
| `motel` | 1 |
|
|
538
|
+
Some of the property types used for filtering:
|
|
529
539
|
|
|
540
|
+
| name | id |
|
|
541
|
+
| ----------- | --- |
|
|
542
|
+
| `hotel` | 0 |
|
|
543
|
+
| `apartment` | 9 |
|
|
544
|
+
| `hostel` | 5 |
|
|
545
|
+
| `motel` | 1 |
|
|
530
546
|
|
|
531
547
|
##### Amenities
|
|
548
|
+
|
|
532
549
|
<a id="filters-amenities"></a>
|
|
533
550
|
Supported amenities:
|
|
534
551
|
|
|
535
552
|
| name | description |
|
|
536
|
-
|
|
553
|
+
| -------------- | ------------------------------------------------------------------------------------ |
|
|
537
554
|
| `breakfast` | |
|
|
538
555
|
| `lunch` | |
|
|
539
556
|
| `dinner` | |
|
|
@@ -541,30 +558,30 @@ Supported amenities:
|
|
|
541
558
|
| `fullBoard` | "breakfast && lunch && dinner", or the hotel’s explicit use of the term "full-board" |
|
|
542
559
|
| `allInclusive` | "all meals && all drinks" or the hotel’s explicit use of the term "all-inclusive" |
|
|
543
560
|
|
|
544
|
-
|
|
545
561
|
### Callbacks
|
|
562
|
+
|
|
546
563
|
<a id="search-callbacks"></a>
|
|
547
564
|
|
|
548
565
|
Search method receives callbacks object as the second argument:
|
|
549
566
|
|
|
550
567
|
```js
|
|
551
|
-
const callbacks =
|
|
568
|
+
const callbacks = {
|
|
552
569
|
onStart: (response) => {
|
|
553
|
-
log(
|
|
570
|
+
log("Search started", response);
|
|
554
571
|
},
|
|
555
572
|
onAnchorReceived: (response) => {
|
|
556
|
-
log(
|
|
573
|
+
log("Anchor received", response);
|
|
557
574
|
},
|
|
558
575
|
onHotelsReceived: (response) => {
|
|
559
|
-
log(
|
|
576
|
+
log("Hotels received", response);
|
|
560
577
|
},
|
|
561
578
|
onOffersReceived: (response) => {
|
|
562
|
-
log(
|
|
579
|
+
log("Offers received", response);
|
|
563
580
|
},
|
|
564
581
|
onComplete: (response) => {
|
|
565
|
-
log(
|
|
566
|
-
}
|
|
567
|
-
}
|
|
582
|
+
log("Search completed", response);
|
|
583
|
+
},
|
|
584
|
+
};
|
|
568
585
|
```
|
|
569
586
|
|
|
570
587
|
Each callback returns the full search state available inside SAPI at the
|
|
@@ -616,6 +633,7 @@ the state can be repeated between different callbacks.
|
|
|
616
633
|
The offers response with the detailed description can be found in the [Offers Response](./docs/offers.md)
|
|
617
634
|
|
|
618
635
|
### Response
|
|
636
|
+
|
|
619
637
|
<a id="search-response"></a>
|
|
620
638
|
|
|
621
639
|
The complete SAPI search response is too big to be displayed on the page
|
|
@@ -633,19 +651,24 @@ so there is a simplified example:
|
|
|
633
651
|
"pageSize": 26,
|
|
634
652
|
"placeDisplayName": "Bedrijventerrein Sloterdijk, Amsterdam",
|
|
635
653
|
"priceBucketWidth": 19,
|
|
636
|
-
"_geoloc": {
|
|
654
|
+
"_geoloc": {
|
|
655
|
+
"lat": 52.388326,
|
|
656
|
+
"lon": 4.837264,
|
|
657
|
+
"precision": 5000,
|
|
658
|
+
"radius": 20000
|
|
659
|
+
}
|
|
637
660
|
},
|
|
638
661
|
"anchorHotelId": "1714808",
|
|
639
662
|
"anchorType": "hotel",
|
|
640
663
|
"facets": {
|
|
641
|
-
"facilities": {"1": 212, "2": 348, "3": 116},
|
|
642
|
-
"pricing.medianRateBkt": {"3": 4, "4": 12, "5": 19},
|
|
643
|
-
"pricing.medianRateMoFrBkt": {"3": 4, "4": 6, "5": 8, "6": 9},
|
|
644
|
-
"pricing.medianRateSaSuBkt": {"2": 2, "3": 4, "4": 6, "5": 10},
|
|
645
|
-
"pricing.minRateBkt": {"2": 22, "3": 38, "4": 46, "5": 98},
|
|
646
|
-
"propertyTypeId": {"0": 1030, "2": 6, "3": 601, "4": 86},
|
|
647
|
-
"starRating": {"1": 351, "2": 313, "3": 596, "4": 441, "5": 86},
|
|
648
|
-
"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 }
|
|
649
672
|
},
|
|
650
673
|
"hotelEntities": {
|
|
651
674
|
"1041597": {
|
|
@@ -655,16 +678,39 @@ so there is a simplified example:
|
|
|
655
678
|
"country": "NL",
|
|
656
679
|
"displayAddress": "Stationsplein 49, Burgwallen-Nieuwe Zijde, Amsterdam, The Netherlands",
|
|
657
680
|
"facilities": [1, 2, 5, 8, 9, 11],
|
|
658
|
-
"guestRating": {
|
|
659
|
-
|
|
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
|
+
},
|
|
660
696
|
"hotelName": "ibis Amsterdam Centre",
|
|
661
|
-
"imageURIs": [
|
|
697
|
+
"imageURIs": [
|
|
698
|
+
"https://i.travelapi.com/hotels/1000000/30000/25600/25525/c2387aed_w.jpg"
|
|
699
|
+
],
|
|
662
700
|
"isDeleted": false,
|
|
663
701
|
"lastBooked": 1658320362,
|
|
664
702
|
"objectID": "1041597",
|
|
665
703
|
"parentChainID": "10",
|
|
666
704
|
"placeDisplayName": "Burgwallen-Nieuwe Zijde, Amsterdam",
|
|
667
|
-
"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
|
+
},
|
|
668
714
|
"propertyTypeId": 0,
|
|
669
715
|
"regularPriceRange": [224, 243],
|
|
670
716
|
"reviewCount": 5766,
|
|
@@ -672,7 +718,7 @@ so there is a simplified example:
|
|
|
672
718
|
"starRating": 3,
|
|
673
719
|
"tags": ["b220918-1"],
|
|
674
720
|
"themeIds": [2, 5, 12],
|
|
675
|
-
"_geoloc": {"lat": 52.37947, "lon": 4.89699}
|
|
721
|
+
"_geoloc": { "lat": 52.37947, "lon": 4.89699 }
|
|
676
722
|
}
|
|
677
723
|
},
|
|
678
724
|
"hotelIds": ["1840170", "2766940", "3310443", "3035769"],
|
|
@@ -701,15 +747,11 @@ so there is a simplified example:
|
|
|
701
747
|
"intermediaryProvider": "BKS",
|
|
702
748
|
"roomName": "Standard Twin Room",
|
|
703
749
|
"package": {
|
|
704
|
-
"amenities": [
|
|
705
|
-
"breakfast"
|
|
706
|
-
],
|
|
750
|
+
"amenities": ["breakfast"],
|
|
707
751
|
"canPayLater": false
|
|
708
752
|
},
|
|
709
753
|
"cancellationPenalties": [],
|
|
710
|
-
"tags": [
|
|
711
|
-
"top_offer"
|
|
712
|
-
],
|
|
754
|
+
"tags": ["top_offer"],
|
|
713
755
|
"metadata": {
|
|
714
756
|
"feedID": ""
|
|
715
757
|
}
|
|
@@ -742,37 +784,45 @@ so there is a simplified example:
|
|
|
742
784
|
```
|
|
743
785
|
|
|
744
786
|
### Load more results and load more offers for a hotel
|
|
787
|
+
|
|
745
788
|
After the search is complete:
|
|
789
|
+
|
|
746
790
|
```js
|
|
747
|
-
const search = await sapiClient.search(searchParameters, callbacks)
|
|
791
|
+
const search = await sapiClient.search(searchParameters, callbacks);
|
|
748
792
|
```
|
|
793
|
+
|
|
749
794
|
it resolves in the `search` object which has 2 methods:
|
|
795
|
+
|
|
750
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.
|
|
751
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).
|
|
752
798
|
|
|
753
799
|
## `suggest()` method
|
|
800
|
+
|
|
754
801
|
<a id="suggest-method"></a>
|
|
755
802
|
|
|
756
803
|
Suggest provides autosuggestions for a given query
|
|
757
804
|
|
|
758
805
|
```js
|
|
759
|
-
const suggestions = await sapiClient.suggest(
|
|
806
|
+
const suggestions = await sapiClient.suggest("London", 6);
|
|
760
807
|
```
|
|
761
808
|
|
|
762
809
|
### Suggest parameters
|
|
810
|
+
|
|
763
811
|
<a id="suggest-parameters"></a>
|
|
764
812
|
|
|
765
813
|
| name | type | description | required | example |
|
|
766
|
-
|
|
814
|
+
| --------------- | -------- | ----------------------------------------- | -------- | -------- |
|
|
767
815
|
| `query` | `string` | Query string | yes | `London` |
|
|
768
816
|
| `suggestsCount` | `number` | Desired number of suggestions (default 6) | no | `10` |
|
|
769
817
|
|
|
770
818
|
### Response
|
|
819
|
+
|
|
771
820
|
<a id="suggest-response"></a>
|
|
772
821
|
|
|
773
822
|
```js
|
|
774
|
-
const suggestions = await sapiClient.suggest(
|
|
823
|
+
const suggestions = await sapiClient.suggest("London", 2);
|
|
775
824
|
```
|
|
825
|
+
|
|
776
826
|
```json
|
|
777
827
|
[
|
|
778
828
|
{
|
|
@@ -793,9 +843,11 @@ const suggestions = await sapiClient.suggest('London', 2)
|
|
|
793
843
|
}
|
|
794
844
|
]
|
|
795
845
|
```
|
|
846
|
+
|
|
796
847
|
```js
|
|
797
|
-
const suggestions = await sapiClient.suggest(
|
|
848
|
+
const suggestions = await sapiClient.suggest("London hotel", 2);
|
|
798
849
|
```
|
|
850
|
+
|
|
799
851
|
```json
|
|
800
852
|
[
|
|
801
853
|
{
|
|
@@ -817,8 +869,8 @@ const suggestions = await sapiClient.suggest('London hotel', 2)
|
|
|
817
869
|
]
|
|
818
870
|
```
|
|
819
871
|
|
|
820
|
-
|
|
821
872
|
## `rooms()` method
|
|
873
|
+
|
|
822
874
|
<a id="rooms-method"></a>
|
|
823
875
|
|
|
824
876
|
Rooms is a method of **sapiClient** for retrieving rooms information and
|
|
@@ -826,18 +878,19 @@ offers for a particular itinerary:
|
|
|
826
878
|
|
|
827
879
|
```js
|
|
828
880
|
const rooms = await sapiClient.rooms({
|
|
829
|
-
hotelId:
|
|
830
|
-
checkIn:
|
|
831
|
-
checkOut:
|
|
832
|
-
rooms:
|
|
833
|
-
})
|
|
881
|
+
hotelId: "1714808",
|
|
882
|
+
checkIn: "2021-10-10",
|
|
883
|
+
checkOut: "2021-10-11",
|
|
884
|
+
rooms: "2",
|
|
885
|
+
});
|
|
834
886
|
```
|
|
835
887
|
|
|
836
888
|
### Rooms parameters
|
|
889
|
+
|
|
837
890
|
<a id="rooms-parameters"></a>
|
|
838
891
|
|
|
839
892
|
| name | type | description | required | example |
|
|
840
|
-
|
|
893
|
+
| ----------------------- | ------------------------ | ------------------------------------------------------------------------------ | -------- | ------------------------------------------------- |
|
|
841
894
|
| `hotelId` | `string` | Hotel Id to retrieve rooms | yes | `1714808` |
|
|
842
895
|
| `checkIn` | `string` | Check in date (`YYYY-MM-DD`) | yes | `2021-10-10` |
|
|
843
896
|
| `checkOut` | `string` | Check out date (`YYYY-MM-DD`) | yes | `2021-10-11` |
|
|
@@ -856,8 +909,10 @@ const rooms = await sapiClient.rooms({
|
|
|
856
909
|
| `deviceId` | `string` | Device ID (the IDFV of an iOS device or the GAID of an Android device) | no | |
|
|
857
910
|
| `searchId` | `string` | SearchId override (SDK generates a new one if no provided) | no | `08230dfcc5f0fb95caaa82ce559ea60c4a975d6f` |
|
|
858
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` |
|
|
859
913
|
|
|
860
914
|
### Response
|
|
915
|
+
|
|
861
916
|
<a id="rooms-response"></a>
|
|
862
917
|
|
|
863
918
|
```json
|
|
@@ -871,7 +926,7 @@ const rooms = await sapiClient.rooms({
|
|
|
871
926
|
"bedTypes": [],
|
|
872
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",
|
|
873
928
|
"id": "K0LnAe-G9WI",
|
|
874
|
-
"images": [{"url": "http://images.getaroom-cdn.com/image/...."}],
|
|
929
|
+
"images": [{ "url": "http://images.getaroom-cdn.com/image/...." }],
|
|
875
930
|
"masterId": "9643931",
|
|
876
931
|
"name": "1 Double Standard",
|
|
877
932
|
"offers": [
|
|
@@ -881,17 +936,21 @@ const rooms = await sapiClient.rooms({
|
|
|
881
936
|
"cancellationPenalties": [],
|
|
882
937
|
"cug": ["signed_in"],
|
|
883
938
|
"id": "o0KDe_mFPN4k",
|
|
884
|
-
"links": [
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
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
|
+
],
|
|
895
954
|
"providerCode": "GAR",
|
|
896
955
|
"providerRateType": "public",
|
|
897
956
|
"services": ["breakfast"]
|
|
@@ -902,24 +961,26 @@ const rooms = await sapiClient.rooms({
|
|
|
902
961
|
}
|
|
903
962
|
```
|
|
904
963
|
|
|
905
|
-
|
|
906
964
|
## `hotel()` method
|
|
965
|
+
|
|
907
966
|
<a id="hotel-method"></a>
|
|
908
967
|
|
|
909
968
|
Hotel is a method of **sapiClient** for retrieving a single hotel by id
|
|
910
969
|
|
|
911
970
|
```js
|
|
912
|
-
const hotel = await sapiClient.hotel(
|
|
971
|
+
const hotel = await sapiClient.hotel("1196472");
|
|
913
972
|
```
|
|
914
973
|
|
|
915
974
|
### Hotel parameters
|
|
975
|
+
|
|
916
976
|
<a id="hotel-parameters"></a>
|
|
917
977
|
|
|
918
978
|
| name | type | description | required | example |
|
|
919
|
-
|
|
979
|
+
| --------- | -------- | ----------- | -------- | --------- |
|
|
920
980
|
| `hotelId` | `string` | Hotel Id | yes | `1196472` |
|
|
921
981
|
|
|
922
982
|
### Response
|
|
983
|
+
|
|
923
984
|
<a id="hotel-response"></a>
|
|
924
985
|
|
|
925
986
|
An example of the response for request with `hotelId` 1196472
|
|
@@ -963,7 +1024,8 @@ and \"pt-BR\" `language`
|
|
|
963
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>",
|
|
964
1025
|
"reviewCountBkt": 9,
|
|
965
1026
|
"hotelName": "Movenpick Hotel Amsterdam City Centre",
|
|
966
|
-
"sentiments": [
|
|
1027
|
+
"sentiments": [
|
|
1028
|
+
{
|
|
967
1029
|
"value": "Gostou do bar",
|
|
968
1030
|
"id": 46
|
|
969
1031
|
},
|
|
@@ -972,7 +1034,8 @@ and \"pt-BR\" `language`
|
|
|
972
1034
|
"id": 180
|
|
973
1035
|
}
|
|
974
1036
|
],
|
|
975
|
-
"facilities": [
|
|
1037
|
+
"facilities": [
|
|
1038
|
+
{
|
|
976
1039
|
"categoryID": 4,
|
|
977
1040
|
"importance": 2,
|
|
978
1041
|
"value": "Centro de Negócios",
|
|
@@ -993,7 +1056,8 @@ and \"pt-BR\" `language`
|
|
|
993
1056
|
"groups": 1121,
|
|
994
1057
|
"solo": 206
|
|
995
1058
|
},
|
|
996
|
-
"themes": [
|
|
1059
|
+
"themes": [
|
|
1060
|
+
{
|
|
997
1061
|
"value": "Cidade",
|
|
998
1062
|
"id": 2
|
|
999
1063
|
},
|
|
@@ -1012,22 +1076,25 @@ and \"pt-BR\" `language`
|
|
|
1012
1076
|
```
|
|
1013
1077
|
|
|
1014
1078
|
## `hotels()` method
|
|
1079
|
+
|
|
1015
1080
|
<a id="hotels-method"></a>
|
|
1016
1081
|
|
|
1017
1082
|
Hotel is a method of **sapiClient** for retrieving multiple hotels by hotel ids
|
|
1018
1083
|
|
|
1019
1084
|
```js
|
|
1020
|
-
const hotels = await sapiClient.hotels([
|
|
1085
|
+
const hotels = await sapiClient.hotels(["1714808", "1380416", "1710829"]);
|
|
1021
1086
|
```
|
|
1022
1087
|
|
|
1023
1088
|
### Hotels parameters
|
|
1089
|
+
|
|
1024
1090
|
<a id="hotels-parameters"></a>
|
|
1025
1091
|
|
|
1026
1092
|
| name | type | description | required | example |
|
|
1027
|
-
|
|
1093
|
+
| ---------- | ---------- | ----------- | -------- | --------------------------------- |
|
|
1028
1094
|
| `hotelIds` | `string[]` | Hotel Ids | yes | `['1714808','1380416','1710829']` |
|
|
1029
1095
|
|
|
1030
1096
|
### Response
|
|
1097
|
+
|
|
1031
1098
|
<a id="hotel-response"></a>
|
|
1032
1099
|
|
|
1033
1100
|
An example of the response for request with `hotelId` 1196472
|
|
@@ -1072,7 +1139,8 @@ and \"pt-BR\" `language`
|
|
|
1072
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>",
|
|
1073
1140
|
"reviewCountBkt": 9,
|
|
1074
1141
|
"hotelName": "Movenpick Hotel Amsterdam City Centre",
|
|
1075
|
-
"sentiments": [
|
|
1142
|
+
"sentiments": [
|
|
1143
|
+
{
|
|
1076
1144
|
"value": "Gostou do bar",
|
|
1077
1145
|
"id": 46
|
|
1078
1146
|
},
|
|
@@ -1081,7 +1149,8 @@ and \"pt-BR\" `language`
|
|
|
1081
1149
|
"id": 180
|
|
1082
1150
|
}
|
|
1083
1151
|
],
|
|
1084
|
-
"facilities": [
|
|
1152
|
+
"facilities": [
|
|
1153
|
+
{
|
|
1085
1154
|
"categoryID": 4,
|
|
1086
1155
|
"importance": 2,
|
|
1087
1156
|
"value": "Centro de Negócios",
|
|
@@ -1102,7 +1171,8 @@ and \"pt-BR\" `language`
|
|
|
1102
1171
|
"groups": 1121,
|
|
1103
1172
|
"solo": 206
|
|
1104
1173
|
},
|
|
1105
|
-
"themes": [
|
|
1174
|
+
"themes": [
|
|
1175
|
+
{
|
|
1106
1176
|
"value": "Cidade",
|
|
1107
1177
|
"id": 2
|
|
1108
1178
|
},
|
|
@@ -1122,38 +1192,40 @@ and \"pt-BR\" `language`
|
|
|
1122
1192
|
```
|
|
1123
1193
|
|
|
1124
1194
|
## `offers()` method
|
|
1195
|
+
|
|
1125
1196
|
<a id="offers-method"></a>
|
|
1126
1197
|
|
|
1127
1198
|
Retrieves offers for a single hotel by provided parameters
|
|
1128
1199
|
|
|
1129
1200
|
```js
|
|
1130
1201
|
const parameters = {
|
|
1131
|
-
hotelId:
|
|
1132
|
-
checkIn:
|
|
1133
|
-
checkOut:
|
|
1134
|
-
rooms:
|
|
1135
|
-
}
|
|
1202
|
+
hotelId: "1196472",
|
|
1203
|
+
checkIn: "2022-10-10",
|
|
1204
|
+
checkOut: "2022-10-11",
|
|
1205
|
+
rooms: "2",
|
|
1206
|
+
};
|
|
1136
1207
|
|
|
1137
1208
|
const callbacks = {
|
|
1138
|
-
|
|
1139
|
-
log(
|
|
1209
|
+
onStart: (response) => {
|
|
1210
|
+
log("Offers started", response);
|
|
1140
1211
|
},
|
|
1141
1212
|
onOffersReceived: (response) => {
|
|
1142
|
-
log(
|
|
1213
|
+
log("Offers received", response);
|
|
1143
1214
|
},
|
|
1144
1215
|
onComplete: (response) => {
|
|
1145
|
-
log(
|
|
1146
|
-
}
|
|
1147
|
-
}
|
|
1216
|
+
log("Offers completed", response);
|
|
1217
|
+
},
|
|
1218
|
+
};
|
|
1148
1219
|
|
|
1149
|
-
const offers = await sapiClient.offers(parameters, callbacks)
|
|
1220
|
+
const offers = await sapiClient.offers(parameters, callbacks);
|
|
1150
1221
|
```
|
|
1151
1222
|
|
|
1152
1223
|
### Offers parameters
|
|
1224
|
+
|
|
1153
1225
|
<a id="offers-parameters"></a>
|
|
1154
1226
|
|
|
1155
1227
|
| name | type | description | required | example |
|
|
1156
|
-
|
|
1228
|
+
| --------------------- | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------------------------ |
|
|
1157
1229
|
| `hotelId` | `string` | Hotel Id | yes | `1196472` |
|
|
1158
1230
|
| `checkIn` | `string` | Check in date (YYYY-MM-DD) (SDK generates default date if no provided) | no | `2022-10-10` |
|
|
1159
1231
|
| `checkOut` | `string` | Check out date (YYYY-MM-DD)) (SDK generates default date if no provided) | no | `2022-10-11` |
|
|
@@ -1177,6 +1249,7 @@ const offers = await sapiClient.offers(parameters, callbacks)
|
|
|
1177
1249
|
|
|
1178
1250
|
<a id="sort-offers"></a>
|
|
1179
1251
|
Offer sorting by one parameter for now. It is `price`, but there are different variants of sorting by price.:
|
|
1252
|
+
|
|
1180
1253
|
- **price:base_asc** - sort offers by base price ascending
|
|
1181
1254
|
- **price:total_asc** - sort offers by total rate breakdown ascending
|
|
1182
1255
|
- **price:with_tax_asc** - sort offers by base rate with tax ascending
|
|
@@ -1188,17 +1261,17 @@ It overwrites OSO sorting and sorting boost as well. If offersSort parameter is
|
|
|
1188
1261
|
Object with callbacks:
|
|
1189
1262
|
|
|
1190
1263
|
```js
|
|
1191
|
-
const callbacks =
|
|
1264
|
+
const callbacks = {
|
|
1192
1265
|
onStart: (response) => {
|
|
1193
|
-
log(
|
|
1266
|
+
log("Offers started", response);
|
|
1194
1267
|
},
|
|
1195
1268
|
onOffersReceived: (response) => {
|
|
1196
|
-
log(
|
|
1269
|
+
log("Offers received", response);
|
|
1197
1270
|
},
|
|
1198
1271
|
onComplete: (response) => {
|
|
1199
|
-
log(
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1272
|
+
log("Offers completed", response);
|
|
1273
|
+
},
|
|
1274
|
+
};
|
|
1202
1275
|
```
|
|
1203
1276
|
|
|
1204
1277
|
1. ### onStart()
|
|
@@ -1217,56 +1290,58 @@ const callbacks = {
|
|
|
1217
1290
|
Returns hotel\'s offers (complete response).
|
|
1218
1291
|
|
|
1219
1292
|
### Response
|
|
1293
|
+
|
|
1220
1294
|
<a id="offers-response"></a>
|
|
1221
1295
|
|
|
1222
1296
|
An example of the response for request parameters:
|
|
1223
1297
|
|
|
1224
1298
|
```js
|
|
1225
1299
|
const parameters = {
|
|
1226
|
-
hotelId:
|
|
1227
|
-
checkIn:
|
|
1228
|
-
checkOut:
|
|
1229
|
-
rooms:
|
|
1230
|
-
}
|
|
1300
|
+
hotelId: "1926746",
|
|
1301
|
+
checkIn: "2022-07-10",
|
|
1302
|
+
checkOut: "2022-07-11",
|
|
1303
|
+
rooms: "2",
|
|
1304
|
+
};
|
|
1231
1305
|
```
|
|
1232
1306
|
|
|
1233
1307
|
The response with the detailed description can be found in the [Offers Response](./docs/offers.md)
|
|
1234
1308
|
|
|
1235
|
-
|
|
1236
1309
|
## `hotelAvailability()` method
|
|
1310
|
+
|
|
1237
1311
|
<a id="hotel-availability-method"></a>
|
|
1238
1312
|
|
|
1239
1313
|
Returns availability of the provided hotels for different dates (aka price calendar)
|
|
1240
1314
|
|
|
1241
1315
|
```js
|
|
1242
1316
|
const parameters = {
|
|
1243
|
-
hotelIds: [
|
|
1244
|
-
startDate:
|
|
1245
|
-
endDate:
|
|
1317
|
+
hotelIds: ["1380416", "1359951"],
|
|
1318
|
+
startDate: "2023-08-05",
|
|
1319
|
+
endDate: "2023-08-12",
|
|
1246
1320
|
nights: 2,
|
|
1247
|
-
rooms:
|
|
1248
|
-
}
|
|
1321
|
+
rooms: "2",
|
|
1322
|
+
};
|
|
1249
1323
|
|
|
1250
1324
|
const callbacks = {
|
|
1251
1325
|
onStart: (response) => {
|
|
1252
|
-
log(
|
|
1326
|
+
log("Availability request started", response);
|
|
1253
1327
|
},
|
|
1254
1328
|
onAvailabilityReceived: (response) => {
|
|
1255
|
-
log(
|
|
1329
|
+
log("Availability received", response);
|
|
1256
1330
|
},
|
|
1257
1331
|
onComplete: (response) => {
|
|
1258
|
-
log(
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1332
|
+
log("Availability completed", response);
|
|
1333
|
+
},
|
|
1334
|
+
};
|
|
1261
1335
|
|
|
1262
|
-
const response = await sapiClient.hotelAvailability(parameters, callbacks)
|
|
1336
|
+
const response = await sapiClient.hotelAvailability(parameters, callbacks);
|
|
1263
1337
|
```
|
|
1264
1338
|
|
|
1265
1339
|
### Hotel(s) availability search parameters
|
|
1340
|
+
|
|
1266
1341
|
<a id="availability-search-parameters"></a>
|
|
1267
1342
|
|
|
1268
1343
|
| name | type | description | required | example |
|
|
1269
|
-
|
|
1344
|
+
| ----------- | ------------------ | -------------------------------------------------------------------------------------------- | -------- | -------------------------- |
|
|
1270
1345
|
| `hotelIds` | `string, string[]` | Hotel id(s) to retrieve offers for | yes | `['1380416','1359951']` |
|
|
1271
1346
|
| `startDate` | `string` | Date of first check in (YYYY-MM-DD) | yes | `'2023-10-10'` |
|
|
1272
1347
|
| `endDate` | `string` | Date of last check in (including). Can't be further than 61 days from StartDate (YYYY-MM-DD) | yes | `'2023-10-11'` |
|
|
@@ -1277,22 +1352,23 @@ const response = await sapiClient.hotelAvailability(parameters, callbacks)
|
|
|
1277
1352
|
| `originId` | `string` | Identifier of origin where the request was originated | no | `'c3po6twr70'` |
|
|
1278
1353
|
|
|
1279
1354
|
### Callbacks
|
|
1355
|
+
|
|
1280
1356
|
<a id="availability-callbacks"></a>
|
|
1281
1357
|
|
|
1282
1358
|
Object with callbacks:
|
|
1283
1359
|
|
|
1284
1360
|
```js
|
|
1285
|
-
const callbacks =
|
|
1361
|
+
const callbacks = {
|
|
1286
1362
|
onStart: (response) => {
|
|
1287
|
-
log(
|
|
1363
|
+
log("Availability request started", response);
|
|
1288
1364
|
},
|
|
1289
1365
|
onAvailabilityReceived: (response) => {
|
|
1290
|
-
log(
|
|
1366
|
+
log("Availability received", response);
|
|
1291
1367
|
},
|
|
1292
1368
|
onComplete: (response) => {
|
|
1293
|
-
log(
|
|
1294
|
-
}
|
|
1295
|
-
}
|
|
1369
|
+
log("Availability completed", response);
|
|
1370
|
+
},
|
|
1371
|
+
};
|
|
1296
1372
|
```
|
|
1297
1373
|
|
|
1298
1374
|
1. ### onStart()
|
|
@@ -1311,6 +1387,7 @@ const callbacks = {
|
|
|
1311
1387
|
Returns availability with offers (complete response).
|
|
1312
1388
|
|
|
1313
1389
|
### Response
|
|
1390
|
+
|
|
1314
1391
|
<a id="availability-response"></a>
|
|
1315
1392
|
|
|
1316
1393
|
An example of the response:
|
|
@@ -1340,9 +1417,7 @@ An example of the response:
|
|
|
1340
1417
|
"providerCode": "WTM",
|
|
1341
1418
|
"intermediaryProvider": "FHT",
|
|
1342
1419
|
"package": {
|
|
1343
|
-
"amenities": [
|
|
1344
|
-
"breakfast"
|
|
1345
|
-
],
|
|
1420
|
+
"amenities": ["breakfast"],
|
|
1346
1421
|
"canPayLater": false
|
|
1347
1422
|
},
|
|
1348
1423
|
"cancellationPenalties": [
|
|
@@ -1353,16 +1428,13 @@ An example of the response:
|
|
|
1353
1428
|
"currency": "EUR"
|
|
1354
1429
|
}
|
|
1355
1430
|
],
|
|
1356
|
-
"tags": [
|
|
1357
|
-
"top_offer",
|
|
1358
|
-
"exclusive_cheapest_offer"
|
|
1359
|
-
],
|
|
1431
|
+
"tags": ["top_offer", "exclusive_cheapest_offer"],
|
|
1360
1432
|
"metadata": {
|
|
1361
1433
|
"providerRateType": "member",
|
|
1362
1434
|
"feedID": ""
|
|
1363
1435
|
},
|
|
1364
1436
|
"roomName": "STANDARD DOUBLE/TWIN"
|
|
1365
|
-
}
|
|
1437
|
+
}
|
|
1366
1438
|
]
|
|
1367
1439
|
},
|
|
1368
1440
|
"2023-08-06": {
|
|
@@ -1382,21 +1454,16 @@ An example of the response:
|
|
|
1382
1454
|
"base": 493.9438317757,
|
|
1383
1455
|
"taxes": 32.2961682243,
|
|
1384
1456
|
"hotelFees": 0
|
|
1385
|
-
|
|
1457
|
+
},
|
|
1386
1458
|
"accessTier": "sensitive",
|
|
1387
1459
|
"providerCode": "WTM",
|
|
1388
1460
|
"intermediaryProvider": "FHT",
|
|
1389
1461
|
"package": {
|
|
1390
|
-
"amenities": [
|
|
1391
|
-
"breakfast"
|
|
1392
|
-
],
|
|
1462
|
+
"amenities": ["breakfast"],
|
|
1393
1463
|
"canPayLater": false
|
|
1394
1464
|
},
|
|
1395
1465
|
"cancellationPenalties": [],
|
|
1396
|
-
"tags": [
|
|
1397
|
-
"top_offer",
|
|
1398
|
-
"exclusive_cheapest_offer"
|
|
1399
|
-
],
|
|
1466
|
+
"tags": ["top_offer", "exclusive_cheapest_offer"],
|
|
1400
1467
|
"metadata": {
|
|
1401
1468
|
"providerRateType": "member",
|
|
1402
1469
|
"feedID": ""
|
|
@@ -1410,8 +1477,10 @@ An example of the response:
|
|
|
1410
1477
|
```
|
|
1411
1478
|
|
|
1412
1479
|
## Rooms configuration
|
|
1480
|
+
|
|
1413
1481
|
<a id="rooms-configuration"></a>
|
|
1414
1482
|
`rooms` is a string that encodes the configuration of rooms requested by the user and follows the next rules:
|
|
1483
|
+
|
|
1415
1484
|
- Rooms are separated by pipe `|`
|
|
1416
1485
|
- Adults and children are separated by colon `:`
|
|
1417
1486
|
- Children ages are separated by comma `,`
|
|
@@ -1432,15 +1501,15 @@ SAPI SDK exposes a special method `generateSearchId` to generate `searchId` whic
|
|
|
1432
1501
|
#### Example
|
|
1433
1502
|
|
|
1434
1503
|
```js
|
|
1435
|
-
import {generateSearchId} from
|
|
1504
|
+
import { generateSearchId } from "@findhotel/sapi";
|
|
1436
1505
|
|
|
1437
|
-
const searchId = generateSearchId()
|
|
1506
|
+
const searchId = generateSearchId();
|
|
1438
1507
|
|
|
1439
1508
|
const rooms = await sapiClient.rooms({
|
|
1440
|
-
hotelId:
|
|
1441
|
-
checkIn:
|
|
1442
|
-
checkOut:
|
|
1443
|
-
rooms:
|
|
1444
|
-
searchId
|
|
1445
|
-
})
|
|
1509
|
+
hotelId: "47319",
|
|
1510
|
+
checkIn: "2023-10-10",
|
|
1511
|
+
checkOut: "2023-10-11",
|
|
1512
|
+
rooms: "2",
|
|
1513
|
+
searchId,
|
|
1514
|
+
});
|
|
1446
1515
|
```
|