
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
@findhotel/sapi
Advanced tools
search()
method:Method:
rooms()
method:Method:
SDK provides a high level TypeScript/JavaScript API for searching hotels, hotels' offers and rooms.
Glossary contains terms that are used throuout the documentation.
hotelId
, checkIn
, checkOut
First, install SAPI SDK via the npm package manager:
npm install @findhotel/sapi
Then, import SAPI into your project:
import sapi from '@findhotel/sapi'
Create SAPI client:
const profileKey = 'profile-key'
const options = {
anonymousId: 'fd9dbb5f-b337-4dd7-b640-1f177d1d3caa',
language: 'en',
currency: 'USD',
userCountry: 'US'
}
const sapiClient = await sapi(profileKey, options)
Now SAPI client is ready to be used in your application.
For full documentation and supported options check client api.
Search for the hotels and hotels' offers:
const searchParameters = {
placeId: '47319',
checkIn: '2021-10-10',
checkOut: '2021-10-11',
rooms: '2'
}
const callbacks = {
onStart: (response) => {
console.log('Search started', response)
},
onAnchorReceived: (response) => {
console.log('Anchor received', response)
},
onHotelsReceived: (response) => {
console.log('Hotels received', response)
},
onOffersReceived: (response) => {
console.log('Offers received', response)
},
onComplete: (response) => {
console.log('Search completed', response)
}
}
const search = await sapiClient.search(searchParameters, callbacks)
For full documentation, check search method api.
Get rooms and rooms' offers:
const rooms = await sapiClient.rooms({
hotelId: '47319',
checkIn: '2021-10-10',
checkOut: '2021-10-11',
rooms: '2'
})
For full documentation, check rooms method api.
Create SAPI client:
const profileKey = 'profile-key'
const options = {
anonymousId: 'fd9dbb5f-b337-4dd7-b640-1f177d1d3caa',
language: 'en',
currency: 'USD',
userCountry: 'US'
}
const sapiClient = await sapi(profileKey, options)
name | required | type | default | description | example |
---|---|---|---|---|---|
`anonymousId` | yes | `string` | Unique ID identifying users | `2d360284-577b-4a53-8b91-68f72b9227fa` | |
`language` | yes | `string` | `en` | 2-char language code | `en` |
`currency` | yes | `string` | `USD` | 3-char uppercased ISO currency code | `USD` |
`userCountry` | yes | `string` | `US` | 2-char uppercased ISO country code | `US` |
`deviceCategory` | yes | `string` | `desktop` or `mobile` | `desktop` | |
`includeLocalTaxes` | no | `boolean` | Include or not local taxes based in the displayed price | `false` | |
`includeTaxes` | no | `boolean` | Include or not taxes based in the displayed price | `false` | |
`pageSize` | no | `number` | `20` | Displayed page size | `20` |
`initWithProfile` | no | `Record` | External profile to override internal client profile | ||
`algoliaClientOptions` | no | `AlgoliaSearchOptions` | Algolia client options used for debugging and setting additional options like timeouts etc. |
search()
method :Method:Search is a method of sapiClient for searching hotels and offers for
provided searchParameters
:
const search = await sapiClient.search(searchParameters, callbacks)
name | required | type | description | example |
---|---|---|---|---|
`hotelId` | no | `string` | Hotel Id for hotel search | `1371626` |
`placeId` | no | `string` | Place Id for place search | `47319` |
`query` | no | `string` | Text query | `Amsterdam city` |
`geolocation` | no | `{lat: number, lon: number}` | Geolocation query | `{lat: 36.114303, lon: -115.178312}` |
`checkIn` | no | `string` | Check in date (`YYYY-MM-DD`) | `2021-10-10` |
`checkOut` | no | `string` | Check out date (`YYYY-MM-DD`) | `2021-10-11` |
`rooms` | no | `string` | Rooms configuration | `2` |
Search method receives callbacks object as the second argument:
const callbacks = {
onStart: (response) => {
console.log('Search started', response)
},
onAnchorReceived: (response) => {
console.log('Anchor received', response)
},
onHotelsReceived: (response) => {
console.log('Hotels received', response)
},
onOffersReceived: (response) => {
console.log('Offers received', response)
},
onComplete: (response) => {
console.log('Search completed', response)
}
}
onStart(response)
Runs at the beginning of the each new search
response
- in progress…
onAnchorReceived(response)
Runs when SAPI receives anchor (and?) anchor hotel
response
- in progress…
onHotelsReceived(response)
Runs when SAPI receives static search results
response
- in progress…
onOffersReceived(response)
Runs when SAPI receives a bunch of offers
response
- in progress…
onComplete(response)
Runs when current search is complete and all offers are retrieved
response
- in progress…
in progress…
rooms()
method :Method:Rooms is a method of sapiClient for retrieving rooms information and offers for a particular itinerary:
const rooms = sapiClient.rooms({
hotelId: '47319',
checkIn: '2021-10-10',
checkOut: '2021-10-11',
rooms: '2'
})
name | required | type | default | description | example |
---|---|---|---|---|---|
`hotelId` | yes | `string` | Hotel Id to retrieve rooms | `1371626` | |
`checkIn` | yes | `string` | Check in date (`YYYY-MM-DD`) | `2021-10-10` | |
`checkOut` | yes | `string` | Check out date (`YYYY-MM-DD`) | `2021-10-11` | |
`rooms` | yes | `string` | Rooms configuration | `2` |
in progress…
SAPI rooms()
method will have the similar response body as BoFH API
/rooms
endpoint. For now please refer to BoFH documentation.
FAQs
FindHotel Search API
The npm package @findhotel/sapi receives a total of 751 weekly downloads. As such, @findhotel/sapi popularity was classified as not popular.
We found that @findhotel/sapi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.