Python | Find Hotel Prices using Hotel price comparison API
Last Updated :
29 Oct, 2019
Makcorps hotel API
is used to get JSON data, to compare Hotel prices, ratings, and reviews from more than 200 websites including; Agoda.com, Hotels.com, Expedia and more. It is organized around GET Requests. One can use this API for free to get information for any hotel or any city regarding prices, ratings, reviews, historical prices and many other things.
To use this API, one must need the API key, which can be get form here
Note: User need to create an account on makcorps.com then only can use the APIs.
Modules Needed :
requests
pip install requests
Implementation
This API will search according to the city name. Let’s suppose if a city London is searched, then output JSON will be a price comparison of different hotels in that city from different vendors along with their name. According to the vendor’s price best price will also be shown.
Below is the implementation :
import requests, json
city = "london"
complete_url = base_url + city
headers = {
'Authorization' : 'JWT your_API_id' ,
}
response_ob = requests.get(complete_url, headers = headers)
result = response_ob.json()
if response_ob.status_code = = 200 :
print ( "price comparison data for a random date of city london is:" )
print (result)
else :
print ( "record is not found for given request" )
|
Output:
price comparison data for a random date of city london is:
{'comparison':
[
{
'vendor1-price': 'US$217',
'vendor3-price': 'US$246',
'vendor2-price': 'US$217',
'vendor3': 'travelup.com',
'vendor1': 'Travelocity',
'Hotel': 'Park Plaza Westminster Bridge London',
'Best-price': 'US$\xa0246US$\xa0215Booking.com',
'vendor2': 'Orbitz.com'
},
{
'vendor1-price': '',
'vendor3-price': '',
'vendor2-price': '',
'vendor3': 'Travelocity',
'vendor1': 'Expedia.com',
'Hotel': 'Travelodge London Covent Garden',
'Best-price': 'US$\xa074Travelodge',
'vendor2': 'Hotels.com'
},
{
'vendor1-price': 'US$167',
'vendor3-price': 'US$183',
'vendor2-price': 'US$171',
'vendor3': 'Nustay.com',
'vendor1': 'ParkGrandLondon',
'Hotel': 'Park Grand London Kensington',
'Best-price': 'US$\xa0170Booking.com',
'vendor2': 'Travelocity'
},
{
'vendor1-price': '',
'vendor3-price': '',
'vendor2-price': '',
'vendor3': 'Orbitz.com',
'vendor1': 'Expedia.com',
'Hotel': 'Travelodge London City hotel',
'Best-price': 'US$\xa056Travelodge',
'vendor2': 'Nustay.com'
},
{
'vendor1-price': 'US$205',
'vendor3-price': 'US$232',
'vendor2-price': 'US$185',
'vendor3': 'ZenHotels.com',
'vendor1': 'Booking.com',
'Hotel': 'The Tower Hotel',
'Best-price': 'US$\xa0206Orbitz.com',
'vendor2': 'Trip.com'
},
{
'vendor1-price': 'US$77',
'vendor3-price': 'US$94',
'vendor2-price': 'US$87',
'vendor3': 'Nustay.com',
'vendor1': 'Official Site',
'Hotel': 'Point A Hotel, London Kings Cross St Pancras',
'Best-price': 'US$\xa087Orbitz.com',
'vendor2': 'Booking.com'
},
{
'vendor1-price': 'US$224',
'vendor3-price': 'US$242',
'vendor2-price': 'US$217',
'vendor3': 'travelup.com',
'vendor1': 'Orbitz.com',
'Hotel': 'Strand Palace Hotel',
'Best-price': 'US$\xa0223Booking.com',
'vendor2': 'ZenHotels.com'
}
]
}
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...