Wego Hotels API

Follow

The Wego Hotels API allows developers to interact with the Hotels product of Wego.com programmatically via HTTP requests. All API methods are HTTP requests and responses are in JSON format unless otherwise stated.

Core Concepts

What can you do with the API?

There're 4 main components that you'll most likely care about:

  1. Locations
    Use this to map user location queries to Wego location IDs. E.g. you will probably provide your users with a text field for entering the location when searching for hotels. The Locations API allows you to lookup text queries like "sydney" to get a list of matching locations and their IDs.

  2. Search
    Allows you to start a hotel search and retrieve results. 

  3. Hotel Details
    Get details of a hotel, like its address, amenities, photos.

  4. Booking a room with our partners
    Taking users to continue the booking process for a room at one of our partners' sites.

The typical use case of a user searching for hotels would involve:

  1. A user, let's call her Konata, is looking for hotels in Sydney. She types in "sydney" into a text field on your search form.

  2. You send a Locations API /hotels/api/locations/search request to lookup the location ID of "Sydney":

    GET http://api.wego.com/hotels/api/locations/search?q=sydney
    

    The API responds (in JSON format) with:

                {
                    "count": 3,
                    "locations": [{
                        "name": "Sydney, NSW, Australia - 795 hotels",
                        "country_name": "Australia",
                        "country_code": "AU",
                        "state_name": "New South Wales",
                        "id": 7046,
                        "state_code": "NSW"
                    },
                    {
                        "name": "Sydney, Canada - 53 hotels",
                        "country_name": "Canada",
                        "country_code": "CA",
                        "state_name": null,
                        "id": 8564,
                        "state_code": null
                    },
                    {
                        "name": "North Sydney, SK, Canada - 2 hotels",
                        "country_name": "Canada",
                        "country_code": "CA",
                        "state_name": "Saskatchewan",
                        "id": 18410,
                        "state_code": "SK"
                    }],
                    "query": "sydney"
                }
              

    This means there are 3 locations that match "sydney", id 7046 in Australia, id 8564 in Canada and id 18410 in Saskatchewan, Canada. You'll have to either present Konata with the 3 locations and ask her to pick the one she meant, or pick one for her (not recommended).

    On Wego.com, we use an autosuggest widget to present users with matching locations.

  3. Konata picks Sydney in Australia - she had no idea there was a Sydney in Canada!
  4. You can now perform a search. A live search will perform a real-time search on Wego's partners' sites for rates in a given location and date range. 

    When doing a live search, you send a Search API /hotels/api/search/new request to start a search for hotels in Sydney (location ID 7046), including your user's IP address, together with your API key and ts_code in the query:

    GET http://api.wego.com/hotels/api/search/new?location_id=7046&check_in=2011-08-15&check_out=2011-08-18&user_ip=direct&ts_code=abc01&key=abcdefghijk123

    (Your ts_code is a unique identifier that we issue to you when you register for API access. We use it to attribute searches and referral clicks to your account.)

    The API responds with:

    {
      "search_id": 4819451
    }

    You can use the search_id to fetch search results with the /hotels/api/search/search_id API method.

  5. Konata is shown a page where results from the /hotels/api/search/search_id method are displayed.

    It's best to wait at least 10 seconds after starting the search, (it's good practice to keep the user distracted by telling her that her search is in progress), and then requesting and showing her the set of all results from the /hotels/api/search/search_id API method:

    GET http://api.wego.com/hotels/api/search/4819451
  6. Konata sees a hotel (The Westin Sydney, hotel_id 272921) that she likes and clicks to see more details of the hotel.

  7. You send a Hotel Details API /hotels/api/search/show/search_id?hotel_id=hotel_id request to retrieve the details of The Westin Sydney:

    GET http://api.wego.com/hotels/api/search/show/4819451?hotel_id=272921

    The API responds with the hotel details which you can use to construct the hotel details page.

  8. Konata looks at the list of rates from different partners, and decides to pick the cheapest rate from cheapest-partner.com.

  9. You lookup the id for the rate (12) and use the /hotels/api/search/redirect/search_id API method to redirect the user to cheapest-partner.com's site (including your API key and ts_code in the query):

    GET http://api.wego.com/hotels/api/search/redirect/4819451?hotel_id=272921&room_rate_id=12&key=12345abcdef&ts_code=abc01

    Konata will now be redirected to the partner's site so that she can continue her booking directly with them.

Authentication

In order to make requests to api.wego.com, your application must first obtain an API key and a ts_code. Normally you should add your key and ts_code into query parameters.

GET http://api.wego.com/hotels/api/search/new?key=12345abcdef&ts_code=abc01&location_id=6667

Please use your key and ts_code into all requests you make to api.wego.com and do not share them to anyone.

Affiliate team is supporting API key and ts_code, you can read more by the following link.

Language

The current Hotels API supports several languages. Add query parameter locale (or for some methods lang) to get the response in different locale rather than en.

http://api.wego.com/hotels/api/locations/search?q=sydney&lang=ru

Supported locales are en, ar, bn, de, es-419, es, fa, fr, gu, hi, id, it, ja, kn, ko, ml, mr, ms, my, nl, or, pa, pl, pt-br, pt, ru, sv, ta, te, th, tl, tr, ur, vi, zh-cn, zh-hk, zh-tw.

Status Codes

The API returns appropriate HTTP status codes. In addition, the API also includes error information in the response body. Error responses have a single error property that is a string describing the error, e.g.:

{ "error": "forbidden" }

An additional details property is sometimes available for further diagnostics.

Possible status codes are:

  • Missing, expired, or invalid key - Your API key is always required
  • Missing or invalid ts_code - Your TS code is always required
  • Missing or invalid user_ip - When performing a new search (/search/new), you must supply a user_ip
  • location-not-found-error - Unrecognized location
  • ARG-required - The HTTP argument ARG is required for this request, e.g. check_in-required or ts_code-required
  • network-error - A network error has occurred
  • unknown-error - An exceptional error that we didn't expect has occurred (we're human too). If you encounter this error, please let us know at api@wego.com

Hotel Reviews

Although the Wego API provides basic hotel review information (such as a number of reviews and a review score), you might need more detailed hotel review data.

We recommend using TrustYou Review API, the world's first and biggest structured review data API.

TrustYou will match your hotel database to TrustYou’s database of 400,000+ hotels via the TrustYou Matching API. You will then receive an API key so that you can access the TrustYou review database via html calls or JSON calls.

Contact TrustYou

API Methods

All API methods are HTTP GET requests and require API key-based authentication. The response data format is in JSON.

GET http://api.wego.com/hotels/api/locations/search

Example Request

http://api.wego.com/hotels/api/locations/search?q=sydney&key=XXX&ts_code=YYY

Request Parameters

  • q - required - The query (URL encoded).
    • Note that you have to replace all characters (e.g. . , / \ - ) being pass to our API into _ (underscore).
      You can use the following JS code to make a replacement:
      .replace(/[\/\\\-\|:;\[\],\.\s\'"]+/g, '').replace(/(^|_$)/, '').toLowerCase()
  • lang - Language of results
  • page - Page of results to return. Use this together with per_page
  • per_page - Number of results to return per page. Use this together with page. Defaults to 10
  • callback - JSON-P callback function name

Example Response

{
          "count": 3,
          "query": "sydney",
          "locations": [{
              "id": 7046,
              "name": "Sydney, NSW, Australia - 795 hotels",
              "country_name": "Australia",
              "country_code": "AU",
              "state_name": "New South Wales",
              "state_code": "NSW"
          },
          { ... },
          {
              "id": 18410,
              "name": "North Sydney, SK, Canada - 2 hotels",
              "country_name": "Canada",
              "country_code": "CA",
              "state_name": "Saskatchewan",
              "state_code": "SK"
          }]
      }

Response Attributes

The response is a hash with the following key-values:

  • query - The query used
  • count - Number of locations in locations (see below)
  • locations - Array of locations, sorted from most relevant to least relevant:
    • id - ID of the location
    • name - A more descriptive name of the location that includes its country and state (if applicable) and the number of hotels
    • country_name - Full country name
    • country_code - Two-letter country code (see ISO 3166-1 alpha-2 codes)
    • state_name - The location's state
    • state_code - Three-letter state code
 

/hotels/api/search/new - Start a new hotel search

GET http://api.wego.com/hotels/api/search/new

Example Request

http://api.wego.com/hotels/api/search/new?location_id=7046&check_in=2014-08-15&check_out=2014-08-18&user_ip=direct&key=XXX&ts_code=YYY&country_code_for_site=AU

Request Parameters

  • location_id (required) - The location ID of the location to search for. See /locations/search for details on getting the location ID
  • check_in (required) - Check-in date in YYYYMMDD format
  • check_out (required) - Check-out date in YYYYMMDD format
  • user_ip (required) - The IP address of the end user who is performing the search (not your backend server). We require this to display room rates that are valid for the user's country.
    Note: If you're calling our API directly from the end user's browser/device (e.g. from a pure client-side JS frontend), and therefore cannot easily determine user's IP address, then you should specify user_ip=direct in your call. We will then use the caller's IP address as detected by our server.
  • country_code_for_site - Country code of the user. We require this to display room rates that are valid for the user's country.
  • rooms - Number of hotel rooms required. Defaults to 1
  • guests - Number of guests staying. Defaults to 2
  • callback - JSON-P callback function name

Example Response

The response is a search_id that is a unique ID for the search. E.g.:

{
  "search_id": "21862386"
}

Use the search_id in the /hotels/api/search/search_id API method to get the results of the search.

 

/hotels/api/search/search_id - Get results of a search

To get the full results you should do at least a 10 seconds delay between a NEW SEARCH and pulling the search results, because we need to connect to our partners to get the results and sometimes partners can be slow to respond.

GET http://api.wego.com/hotels/api/search/search_id

Example Request

http://api.wego.com/hotels/api/search/21862386?key=XXX&ts_code=YYY

Request Parameters

  • search_id (required) - ID of search for retrieving "live" prices together with the hotel
  • refresh - Whether to refresh the results with any new results since the last request. This is useful when retrieving results page by page to prevent new results from changing the order of results by keeping the result set fixed. Possible values: true, false. Defaults to false
  • currency_code - Currency to display prices in - use ISO 4217 3-letter currency codes. Defaults to USD
  • sort - Determines how the results are sorted. Possible values: popularity (Wego popularity rank), name (hotel name), price, satisfaction (Wego satisfaction rank), stars (hotel star rating). Defaults to popularity
  • order - Sort order. Possible values: asc (ascending), desc (descending). Defaults to asc (this means the default sort order if neither sort nor order are provided is from most popular to least popular)
  • popular_with – Determines the country for order by popularity. For example, popular_with=SG - popular with Singaporeans. Defaults to XX (all countries)
  • page - Page of results to return. Use this together with per_page. Defaults to 1
  • per_page - Number of results to return per page. Use this together with page. Defaults to 20
  • lang - Language of results. Defaults to en
  • callback - JSON-P callback function name

Additional Parameters for Filtering the Result Set

  • text_filter - Filters results to only hotels with hotel name or address matching the given string.
    E.g. http://api.wego.com/hotels/api/search/21862386?text_filter=raffles
  • stars[] - Filters results to only hotels with the given star rating(s). Note that this is an array of integers from 1 to 5.
    E.g. http://api.wego.com/hotels/api/search/21862386?stars[]=4&stars[]=5
  • property_types[] - Filters results to only hotels of the given property type(s). Note that this is an array of integers representing property types. Possible values: 1 (hotel), 2 (hostel), 3 (bed and breakfast), 4 (apartment), 5 (resort), 6 (villa), 7 (motel).
    E.g. to get only hostels and resorts: http://api.wego.com/hotels/api/search/21862386?property_types[]=2&property_types[]=5
  • amenities[] - Filters results to only hotels of the given key amenity ID(s). Note that this is an array of integers representing amenities. Possible values: 1 (Internet access), 2 (pool), 3 (parking), 4 (restaurant), 5 (fitness center/spa).
    E.g. http://api.wego.com/hotels/api/search/21862386?amenities[]=1&amenities[]=2
  • satisfaction_min - Filters results to only hotels with a satisfaction score greater than or equal to the given score. Note that satisfaction is a float value from 0 to 100.
    E.g. http://api.wego.com/hotels/api/search/21862386?satisfaction_min=84
  • districts[] - Filters results to only hotels that are in the given district IDs.
    E.g. http://api.wego.com/hotels/api/search/21862386?districts[]=123&districts[]=17
  • price_min - Filters results to only hotels with at least 1 rate that's greater than or equal to the given price. The currency used is the currency that the results are in.
    E.g. http://api.wego.com/hotels/api/search/21862386?price_min=100
  • price_max - Filters results to only hotels with at least 1 rate that's less than or equal to the given price. The currency used is the currency that the results are in.
    E.g. http://api.wego.com/hotels/api/search/21862386?price_max=200
  • providers[] - Filters results to only return hotels with the specified providers. Note that this is an array of provider codes. You can retrieve the provider codes using the Providers API: http://api.wego.com/hotels/api/providers
    E.g. http://api.wego.com/hotels/api/search/21862386?providers[]=agoda.com&providers[]=booking.com&providers[]=hrs.com
  • ex_providers[] - Filters results to not return hotels with the specified providers. Note that this is an array of provider codes. You can retrieve the provider codes using the Providers API: http://api.wego.com/hotels/api/providers
    E.g. http://api.wego.com/hotels/api/search/21862386?ex_providers[]=agoda.com&ex_providers[]=booking.com&ex_providers[]=hrs.com

Example Response

{
   "location": "Sydney",
   "location_coordinates": [
      -33.8696,
      151.207
   ],
   "total_count": 379,
   "count": 20,
   "filtered_count": 369,
   "current_page": 1,
   "per_page": 20,
   "rates": null,
   "districts": [
      {
         "id": 60,
         "name": "City Centre"
      },
      { … },
      {
         "id": 8588,
         "name": "Milsons Point"
      }
   ],
   "hotels": [
      {
         "id": 273451,
         "name": "InterContinental Sydney",
         "address": "117 Macquarie St, cnr of Bridge and Phillip",
         "districts": [
            51,
            60
         ],
         "latitude": -33.863056,
         "longitude": 151.21222,
         "property_type": 1,
         "brand_id": 134,
         "searched": null,
         "desc": "Overlooking the worlds most stunning harbour, this Sydney hotel is a true expression of luxury. Guests can enjoy picturesque views from contemporary suites or the heated indoor swimming pool on the 31st floor. Experience one of the finest restaurants in Sydney at Cafe Opera, serving European and Australian cuisine made from fresh local produce. Near the hotel, explore the The Rocks, stroll through the Royal Botanic Gardens or browse the designer boutiques at the Queen Victoria Building.",
         "stars": 5,
         "map": true,
         "room_rates": [
            {
               "id": "320-1",
               "price_str": "282",
               "currency_code": "USD",
               "currency_sym": "US$",
               "provider_name": "Elvoline",
               "provider_code": "elvoline.com",
               "ex_tax": false,
               "is_direct": false
            },
            { … },
            {
               "id": "324-1",
               "price_str": "342",
               "currency_code": "USD",
               "currency_sym": "US$",
               "provider_name": "HotelPronto",
               "provider_code": "hotelpronto.com",
               "ex_tax": false,
               "is_direct": false
            }
         ],
         "summary_room_rates": { ... },	
         "room_rates_count": 7,
         "room_rate_min": {
            "id": "320-1",
            "price_str": "282",
            "currency_code": "USD",
            "currency_sym": "US$",
            "provider_name": "Elvoline",
            "provider_code": "elvoline.com",
            "ex_tax": false,
            "is_direct": false
         },
         "total_reviews": 1802,
         "rooms_count": 470,
         "rank": 1,
         "satisfaction": 84,
         "satisfaction_description": Excellent,
         "url": "/hotels/australia/sydney/intercontinental-sydney-273451",
         "offer": {
            "id": 1273,
            "title": "IHG Special - up to 25% off",
            "ga_offer_type": "percent off room rate",
            "marketing_message_50": "Book now and save up to 25%!"
         },
         "image": "http://cdn.wego.com/gazo/23/aa89ddc7446bba86a5980603b6db32d6c95c36e9/1359400_B.jpg"
      },
      { … }
   ]
}

Response Attributes

The response is a hash with the following key-values:

    • location - The location of the hotel
    • location_coordinates - The coordinates of the location
    • total_count - Total number of hotels seen so far in this search
    • count - Number of hotels in hotels (see below)
    • filtered_count - This count represents the total number of hotels that satisfy any filters. For example, if a filter for "5-star hotels only" is applied, filtered_count would return the number of 5-star hotels
    • current_page - The page this search is returning
    • per_page - The total number of hotels returned per page
    • distrcits - Array of districts in the location
    • hotels - Array of hotel results, sorted according to sort parameter:
      • id - The hotel id
      • name - The full hotel name
      • address - Address of the hotel
      • districts - Array of districts located close to the hotel
      • latitude - Latitude of the hotel
      • longitude - Longitude of the hotel
      • property_type - Type of property (e.g. is this a "hotel" or a "resort"?). Possible values:
        • 1 - Hotel
        • 2 - Hostel
        • 3 - Bed and Breakfast
        • 4 - Serviced Apartment
        • 5 - Resort
        • 6 - Villa
        • 7 - Motel
      • brand_id - ID of the brand of the hotel
      • searched - Indicates whether this was the hotel that was searched
      • desc - Description of the hotel
      • stars - Star rating of the hotel. This is a number from 0 to 5
      • map - Whether this hotel has longitude and latitude attributes
      • rank - Hotel's rank (by popularity). The most popular hotel has a rank of 1
      • room_rates - Array of room rates:
        • id - Room rate ID
        • price_str - Price per room, per night
        • currency_code - Currency code
        • currency_sym - Currency symbol
        • provider_name - Provider name. Example: Ratestogo
        • provider_code - Provider code. Example: ratestogo.com
        • ex-tax - Whether the rate excluding taxes
        • is_direct - Wether the rate provided by direct provider (e.g. hotel (not a travel agency))
      • summary_room_rates - Summarizes the minimum room rate for each provider. All summary_room_rates attributes are the same with ones in room_rates
      • room_rates_count - Total number of the room rates
      • room_rate_min - Returns the minimum rate rate from the result set. All room_rate_min attributes are the same with ones in room_rates
      • total_reviews - The total number of TrustYou reviews (also check Hotel Reviews)
      • satisfaction - TrustScore. This is a number from 0 to 100
      • satisfaction_description - TrustScore labels "excellent", "very good" etc.
Note that you have to provide an attribution to TrustYou, state "Verified Reviews by TrustYou", and include TrustYou logo (small, medium or large) wherever materials sourced by TrustYou (total_reviews, satisfaction or satisfaction_description) are displayed on your website/application.
    • rooms_count - Total number of rooms in the hotel
    • url - The permalink of the hotel
    • offer - Any offers currently available in the hotel.
      • id - The offer ID
      • title - The title
      • marketing_message_50 - Marketing message
    • image - An image url of the hotel
 

/hotels/api/search/show/search_id - Get details of a hotel (live search)

GET http://api.wego.com/hotels/api/search/show/search_id?hotel_id=hotel_id

Example Request

http://api.wego.com/hotels/api/search/show/22104666?hotel_id=273451&key=XXX&ts_code=YYY

Request Parameters

  • search_id (required) – ID of search for retrieving "live" prices together with the hotel.
  • hotel_id (required) - ID of the hotel.
  • currency_code - Currency to display prices in - use ISO 4217 3-letter currency codes. Defaults to USD.
  • lang - Language of results. Defaults to en.
  • callback - JSON-P callback function name.

Example Response

{
   "total_count": 283,
   "location": "Sydney",
   "location_id": 7046,
   "hotel": {
      "id": 273451,
      "name": "InterContinental Sydney",
      "address": "117 Macquarie St, cnr of Bridge and Phillip",
      "searched": null,
      "desc": "Overlooking the worlds most stunning harbour, this Sydney hotel is a true expression of luxury. Guests can enjoy picturesque views from contemporary suites or the heated indoor swimming pool on the 31st floor. Experience one of the finest restaurants in Sydney at Cafe Opera, serving European and Australian cuisine made from fresh local produce. Near the hotel, explore the The Rocks, stroll through the Royal Botanic Gardens or browse the designer boutiques at the Queen Victoria Building.",
      "stars": 5,
      "map": true,
      "room_rates": [
         {
            "id": "320-3",
            "price_str": "289",
            "currency_code": "USD",
            "currency_sym": "US$",
            "provider_name": "Elvoline",
            "provider_code": "elvoline.com",
            "ex_tax": false,
            "is_direct": false,
            "description": "Double Room, Self catering, WiFi available, no booking fee!",
            "phones": null
         },
         { … }
      ],
      "summary_room_rates": [
         {
            "id": "320-3",
            "price_str": "289",
            "currency_code": "USD",
            "currency_sym": "US$",
            "provider_name": "Elvoline",
            "provider_code": "elvoline.com",
            "ex_tax": false,
            "is_direct": false,
            "description": "Double Room, Self catering, WiFi available, no booking fee!",
            "phones": null
         },
         { … }
      ],
      "room_rates_count": 87,
      "room_rate_min": {
         "id": "320-3",
         "price_str": "289",
         "currency_code": "USD",
         "currency_sym": "US$",
         "provider_name": "Elvoline",
         "provider_code": "elvoline.com",
         "ex_tax": false,
         "is_direct": false,
         "description": "Double Room, Self catering, WiFi available, no booking fee!",
         "phones": null
      },
      "total_reviews": 4004,
      "rooms_count": 509,
      "rank": 1,
      "satisfaction": 89,
      "satisfaction_description": "Excellent",
      "url": "/hotels/australia/sydney/intercontinental-sydney-273451",
      "offer": {
         "id": 1273,
         "title": "IHG Special - up to 25% off",
         "ga_offer_type": "percent off room rate",
         "marketing_message_50": "Book now and save up to 25%!"
      },
      "image": "http://cdn.wego.com/gazo/23/aa89ddc7446bba86a5980603b6db32d6c95c36e9/1359400_B.jpg",
      "cancellation_policy": {
         "en": "Cancellation policies vary by hotel. Since a hotel can set a cancellation policy up to 30 days prior to arrival, please review rate rules prior to booking to avoid possible charges."
      },
      "check_in": "15:00:00",
      "check_out": "11:00:00",
      "reservation_phone": "1800221828",
      "fax": "61292401204",
      "longitude": 151.21211,
      "latitude": -33.86311,
      "postal_code": "2000",
      "property_amenities": [
         "High speed internet access",
         "Swimming pool",
         … ,
         "Wakeup service"
      ],
      "room_amenities": [
         "Accessible room",
         "Non-smoking"
      ],
      "images": [
         {
            "url": "http://cdn.wego.com/gazo/23/aa89ddc7446bba86a5980603b6db32d6c95c36e9/1359400_J.jpg",
            "description": {
               "en": "Area Attractions"
            }
         },
         { … },
         {
            "url": "http://cdn.wego.com/gazo/homage/2945556/ac6beea7bda12a24a55d5562eac34bb20300125c/2945556_J.jpg",
            "description": {}
         }
      ],
      "videos": []
   }
}

Response Attributes

It has all the attributes of the hotel hash in the hotel results response and these additional attributes:

  • longitude - Longitude location value of the hotel
  • latitude - Latitude location value of the hotel
  • postal_code - Postal code of the hotel
  • fax - Fax number of the hotel
  • reservation_phone - Reservation phone of the hotel
  • cancellation_policy -Cancellation policy of the hotel
  • videos - An array of video urls
  • images - An array of images of the hotel.
    • url - url of the image
    • description - description of the image
  • property_amenities - An array of the hotels' property-level amenities. Each item in the array is the name of an amenity
  • room_amenities - An array of the hotels' room-level amenities. Each item in the array is the name of an amenity
 

/hotels/api/search/redirect - Redirect to partners' sites from a live rate

GET http://api.wego.com/hotels/api/search/redirect/search_id?hotel_id=hotel_id&room_rate_id=room_rate_id

Example Request

http://api.wego.com/hotels/api/search/redirect/21862386?hotel_id=8012&room_rate_id=1&key=XXX&ts_code=YYY

Request Parameters

  • search_id (required) - ID of search for retrieving "live" prices together with the hotel.
  • hotel_id (required) - The ID of the hotel in the search results
  • room_rate_id (required) - The room rate id in the search results
  • locale - Locale (language) to display the booking page in, in lowercase. This currently requires that the user's IP (user_ip) resolve to a country that the booking partner offers the language in (e.g. a partner may offer French (fr) in France but not in any other country). If the requested language isn't available in our system, the page will default to English. We provide this option on a best-effort basis, as the range of offered languages varies significantly between partners.
  • currency_code - Unless set within this request, the currency will be set default to USD dollars in the providers' page. 

The response is an HTML page that redirects to one of our partners' sites, not JSON.

Have more questions? Submit a request

Comments