The official Wego SDK for JavaScript, available for browsers and mobile devices (if you are using JavaScript), or Node.js backends
$ bower install wego-sdk$ npm install wego-sdk/** Create `FlighSearchClient` */ const client = new WegoSdk.FlightSearchClient({ onTotalTripsChanged: function(trips) { // Do something with trips }, onTripsChanged: function(trips) { // Do something with trips }, onDisplayedFilterChanged: function(filter) { // Do something with filter }, onProgressChanged: function(progress) { // Do something with progress }, onCheapestTripChanged: function(trip) { // Do something with trip }, onFastestTripChanged: function(trip) { // Do something with trip }, onBestExperienceTripChanged: function(trip) { // Do something with trip }, onSearchCreated: function(newSearch) { // Do something with newSearch } }); /** Make a new search for trips */ client.searchTrips(search);-
Stops
stopCodes: [ 'DIRECT', 'ONE_STOP', 'MORE_THAN_ONE_STOP', ],
-
Price
priceRange: { 'legIndex': undefined, 'min': 1397, 'max': 10924, },
-
Fare Types
conditions: [ 'refundable', 'non_refundable', 'scheduled', 'chartered', ],
-
Flight Times
departureTimeMinutesRanges: [ { 'min': 171, 'max': 1241, 'legIndex': 0, }, { 'min': 360, 'max': 1296, 'legIndex': 1, } ];
arrivalTimeMinutesRanges: [ { 'min': 171, 'max': 1241, 'legIndex': 0, }, { 'min': 360, 'max': 1296, 'legIndex': 1, } ];
-
Airlines/Alliances
airlineCodes: [ 'AF', 'NH', ], allianceCodes: [ 'sky_team', 'star_alliance', 'oneworld', 'lcc', ], /** Complete trip on the same airline */ tripOptions: ['SAME_AIRLINE'],
-
Booking Options
providerTypes: [ 'instant', 'airline', ],
-
Origin/Destination
originAirportCodes: ['SIN'], destinationAirportCodes: ['IAD'],
-
Stopover Airports
stopoverAirportCodes: ['BRU', 'PEK'],
-
Duration
durationMinutesRanges: [ { 'min': 1553, 'max': 3113, 'legIndex': 0, }, { 'min': 1564, 'max': 3379, 'legIndex': 1, }, ], stopoverDurationMinutesRanges: [ { 'min': 190, 'max': 2275, 'legIndex': undefined, }, ],
-
Flight Experience
itineraryOptions: [ 'NOT_OVERNIGHT', 'SHORT_STOPOVER', ],
/** Create `HotelSearchClient` */ const client = new WegoSdk.HotelSearchClient({ onTotalHotelsChanged: function(hotels) { // Do something with hotels }, onHotelsChanged: function(hotels) { // Do something with hotels }, onDisplayedFilterChanged: function(filter) { // Do something with filter }, onProgressChanged: function(progress) { // Do something with progress }, onSearchCreated: function(newSearch) { // Do something with newSearch } }); /** * Make a new search by calling `searchHotels`. * * For more info about the `searchParams`, please visit * https://github.com/wego/wego-api-docs#create-new-hotels-search. */ const searchParams = { "search": { "id": "2d8805fd14337580", "siteCode": "SG", "locale": "en", "currencyCode": "SGD", "cityCode": "SIN", "countryCode": "SG", "roomsCount": 1, "guestsCount": 2, "checkIn": "2017-12-11", "checkOut": "2017-12-16", "deviceType": "DESKTOP", "appType": "WEB_APP", "userLoggedIn": true "hotelId": "12345", /** Optional */ "districtId": "12345" /** Optional */ }, "offset": 500, "selectedHotelIds": ['258101'], /** Optional */ similarHotels: { limit: 10 }, /** New, optional */ nearbyHotels: { limit: 10, radiusInKm: 2 }, /** New, optional */ } client.searchHotels(searchParams);/** Create `HotelDetailsClient` */ const client = new WegoSdk.HotelDetailsClient({ onHotelRatesChanged: function(rates) { // Do something with rates }, onProgressChanged: function(progress) { // Do something with progress }, onSearchCreated: function(newSearch) { // Do something with newSearch } }); /** Create new search */ client.searchHotelRates(hotelSearch, mainSearchId);$ npm run testThe final bundle will be output at dist directory named WegoSdk.js.
$ npm run buildISC