This project contains the API for generating links that redirect you to the search results of Kayak.co.in website based on the date and destination of your choice. This helps you to create HyperLinks in your website or bots based on user choice of destination, check-in and check-out dates.
- First step is make sure you have proper version of python
Check your python version:
python --version
- Clone the repository to your local Machine
Cloning Repository
git clone https://github.com/FAHADPN/Hotel-search-API.git
- Now install all the packages using following command:
pip install -r requirements.txt
- Now you make migrations and also migrate:
python manage.py makemigrations
python manage.py migrate
- Now that you have successfully migrated now you are ready to localhost the api. Use following command to run server:
python manage.py runserver
- Now the API will be running in the port 8000:
'http://127.0.0.1:8000/api/hotel_url/'
'http://localhost:8000/api/hotel_url/'
- The example json format of API request:
data = {
'destination': 'New York', # Replace with your destination
'check_in_date': '2023-09-15', # Replace with your check-in date
'check_out_date': '2023-09-20', # Replace with your check-out date
}
- You can check if the API is properly working by using the following python code
import requests
import json
# Replace with your API endpoint URL
api_url = 'http://127.0.0.1:8000/api/hotel_url/'
# Define the input data as a dictionary
data = {
'destination': 'New York', # Replace with your destination
'check_in_date': '2023-09-15', # Replace with your check-in date
'check_out_date': '2023-09-20', # Replace with your check-out date
}
# Make a POST request to the API
response = requests.post(api_url, data=json.dumps(data), headers={'Content-Type': 'application/json'})
# Check the response
if response.status_code == 200:
result = response.json()
kayak_url = result.get('url')
print(f'Generated Kayak URL: {kayak_url}')
else:
print(f'Error: {response.status_code} - {response.text}')
This project will help you as a starting point to building APIs using Django. Also helps you generate links for hotels in a particular area.
contact :
LinkedIn: Fahad P N
mail: fahadpuzhakkaraillath@gmail.com