Change language

Python | Finding Hotel Prices Using the Hotel Price Comparison API

To use this API you need an API key, which you can get here

Note. The user needs to create an account on makcorps.com, after which they can only use the API.

Required modules:

Requests

 pip install requests 

Implementation

This API will search based on city name. Suppose that if you search for the city of London, the output JSON will compare the prices of different hotels in that city from different suppliers along with their name. The best price will also be shown for the seller price.

Below is the implementation:

# Python program to find prices for live hotels
# Python program to find prices for live hotels
# status using Makcorps Hotel API

 
# import required modules

import requests, json

 
# base_url variable for storing URL

base_url = " https://api.makcorps.com/ free / "

  
# enter city name here

city = "london"

 
# complete_url variable for
# save full URL

complete_url = base_url + city

 
# Declaration of headings is required

headers = {

’Authorization’ : ’ JWT your_API_id’ ,

}

 
# get the request module method
# return response object

response_ob = requests.get (complete_url, headers = headers)

 
# json method to convert the response object
# json format data to python data

result = response_ob .json ()

 
# Now check that the status_code value is
# up to & quot; 200 & quot; or not, if equal, it means that the entry
# found otherwise the entry was not found

if response_ob.status_code = = 200 :

 

# name retrieved from

# result variable data

print ( "price comparison data for a random date of city london is:" )

print (result)

else :

  print ( "record is not found for a given request " )

Exit :

 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 Lo ndon 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’}]} 

Shop

Gifts for programmers

Best laptop for Excel

$
Gifts for programmers

Best laptop for Solidworks

$399+
Gifts for programmers

Best laptop for Roblox

$399+
Gifts for programmers

Best laptop for development

$499+
Gifts for programmers

Best laptop for Cricut Maker

$299+
Gifts for programmers

Best laptop for hacking

$890
Gifts for programmers

Best laptop for Machine Learning

$699+
Gifts for programmers

Raspberry Pi robot kit

$150

Latest questions

PythonStackOverflow

Common xlabel/ylabel for matplotlib subplots

1947 answers

PythonStackOverflow

Check if one list is a subset of another in Python

1173 answers

PythonStackOverflow

How to specify multiple return types using type-hints

1002 answers

PythonStackOverflow

Printing words vertically in Python

909 answers

PythonStackOverflow

Python Extract words from a given string

798 answers

PythonStackOverflow

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

606 answers

PythonStackOverflow

Python os.path.join () method

384 answers

PythonStackOverflow

Flake8: Ignore specific warning for entire file

360 answers

News


Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

How to specify multiple return types using type-hints

Printing words vertically in Python

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

Python add suffix / add prefix to strings in a list

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically