{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import os\n", "import requests" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import utils\n", "\n", "utils.load_env()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/langchain_core/_api/deprecation.py:141: LangChainDeprecationWarning: The class `GooglePlacesTool` was deprecated in LangChain 0.0.33 and will be removed in 0.3.0. An updated version of the class exists in the langchain-google-community package and should be used instead. To use it run `pip install -U langchain-google-community` and import as `from langchain_google_community import GooglePlacesTool`.\n", " warn_deprecated(\n", "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/langchain_core/_api/deprecation.py:141: LangChainDeprecationWarning: The class `GooglePlacesAPIWrapper` was deprecated in LangChain 0.0.33 and will be removed in 0.3.0. An updated version of the class exists in the langchain-google-community package and should be used instead. To use it run `pip install -U langchain-google-community` and import as `from langchain_google_community import GooglePlacesAPIWrapper`.\n", " warn_deprecated(\n" ] }, { "data": { "text/plain": [ "'1. Fashion Island\\nAddress: 587-589/7-9, Ram Inthra Rd, Khwaeng Khan Na Yao, Khet Khan Na Yao, Krung Thep Maha Nakhon 10230, Thailand\\nGoogle place ID: ChIJd57HEQRjHTERG_xSTcdQoYs\\nPhone: 02 947 5000\\nWebsite: http://www.fashionisland.co.th/\\n\\n\\n2. Food Island-Fashion Island\\nAddress: 5/5-6 หมู่ 5 Fashion Island, Ram Inthra Rd, Khwaeng Khan Na Yao, บางเขน Krung Thep Maha Nakhon 10220, Thailand\\nGoogle place ID: ChIJxVlvKA9jHTERAaDXThEk0sU\\nPhone: Unknown\\nWebsite: https://www.fashionisland.co.th/\\n\\n\\n3. Grand Station @ Fashion Island\\nAddress: Fashion Island Shopping Mall คันนายาว Khet Khan Na Yao, Krung Thep Maha Nakhon 10230, Thailand\\nGoogle place ID: ChIJgYJ0xNxjHTERqh7EMAXGflk\\nPhone: 02 947 5000\\nWebsite: https://www.fashionisland.co.th/about-us/grandstation/\\n\\n\\n4. NYLA Fashion Island\\nAddress: 587, 589, 589/7-9 Ram Inthra Rd, Khwaeng Khan Na Yao, Khet Khan Na Yao, Krung Thep Maha Nakhon 10230, Thailand\\nGoogle place ID: ChIJeUgI3A5jHTERdzu6oMzUSCk\\nPhone: 02 947 5938\\nWebsite: Unknown\\n\\n\\n5. Pomelo Fashion Island\\nAddress: Unit GSSH101, 1st Floor, Fashion Island Shopping Mall, 587-589, Ramindra Rd, แขวงคันนายาว เขตคันนายาว กรุงเทพมหานคร 10230, Thailand\\nGoogle place ID: ChIJaYz1YRFjHTERHcxGtqrypsk\\nPhone: 02 000 6811\\nWebsite: https://www.pomelofashion.com/\\n\\n\\n6. IF Store art & chara สาขา Fasion Island\\nAddress: KI B006-B007 โซนแกรนด์สเตชั่น ซอย 7 ศูนย์การค้าแฟชั่นไอส์แลนด์ ชั้น 2 587,589, 589 7 9 Ram Inthra Rd, Khwaeng Khan Na Yao, Khet Khan Na Yao, Krung Thep Maha Nakhon 10230, Thailand\\nGoogle place ID: ChIJx5zaF3RjHTER8ROSKii-tVQ\\nPhone: 063 232 6356\\nWebsite: https://shopee.co.th/ifstore_art\\n\\n\\n7. Haborland Fashion Island\\nAddress: ศูนย์การค้า แฟชั่นไอส์แลนด์ ชั้น3, Khwaeng Khan Na Yao, Khet Khan Na Yao, Krung Thep Maha Nakhon 10230, Thailand\\nGoogle place ID: ChIJ7wF25A5jHTERyBbgZ24hjGU\\nPhone: 065 848 1000\\nWebsite: https://harborlandgroup.com/\\n\\n\\n8. Fashion Island\\nAddress: 401 Newport Center Dr, Newport Beach, CA 92660, USA\\nGoogle place ID: ChIJUetYrofg3IARvxarZNginsY\\nPhone: (949) 721-2000\\nWebsite: https://www.fashionisland.com/?utm_source=soci&utm_medium=organic&utm_campaign=gmb_soci_listing\\n\\n\\n9. Panya Ramintra\\nAddress: Khan Na Yao, Bangkok 10230, Thailand\\nGoogle place ID: ChIJ9e97xwhjHTERR-MWDuKtUYY\\nPhone: Unknown\\nWebsite: Unknown\\n\\n\\n10. Manfair @Fashion Island, 2nd FL, Street 23, Grand Station, Unit MSE025\\nAddress: Manfair Store-Grand Station @Fashion Island Khwaeng Khan Na Yao, Khet Khan Na Yao, Krung Thep Maha Nakhon 10230, Thailand\\nGoogle place ID: ChIJod6zSApjHTERkZ8GxIKx-AY\\nPhone: 085 166 5561\\nWebsite: https://manfair.co.th/\\n\\n\\n11. ร้านชุดชั้นใน GIRLY SECRET @Fasion Island\\nAddress: GIRLY SECRET แฟชั่นไอส์แลนด์ ชั้น2 โซนแกรนด์เสตชั่น สตรีท 11 Lat Phrao Road Khwaeng Khan Na Yao, คันนายาว Krung Thep Maha Nakhon 10230, Thailand\\nGoogle place ID: ChIJMRAHkpKd4jARZBQhL3tzF28\\nPhone: 092 697 9698\\nWebsite: Unknown\\n\\n\\n12. OkurimonoJapan! (Fashion Island)\\nAddress: Level 2, Ram Inthra Rd, Khwaeng Khan Na Yao, Khet Khan Na Yao, Krung Thep Maha Nakhon 10230, Thailand\\nGoogle place ID: ChIJUTgHRlBjHTERw3I3e-uH7hI\\nPhone: 080 594 4644\\nWebsite: Unknown\\n\\n\\n13. Opposite Fashion Island\\nAddress: Khan Na Yao, Bangkok 10230, Thailand\\nGoogle place ID: ChIJV8YMrwhjHTERTd8eEupPwZY\\nPhone: Unknown\\nWebsite: Unknown\\n\\n'" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from langchain_community.tools import GooglePlacesTool\n", "\n", "places = GooglePlacesTool()\n", "places.run(\"fasion islands\")" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "#find places id\n", "#near by search" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'candidates': [{'formatted_address': '45 1 ตำบล วังกระแจะ เมือง ตราด 23000 ไทย', 'geometry': {'location': {'lat': 15.870032, 'lng': 100.992541}, 'viewport': {'northeast': {'lat': 15.8707744, 'lng': 100.9936482298927}, 'southwest': {'lat': 15.86780479999999, 'lng': 100.9909485701073}}}, 'name': 'โรงแรมสุทธิวารี', 'opening_hours': {'open_now': True}, 'rating': 5}], 'status': 'OK'}\n" ] } ], "source": [ "def find_place_from_text(input_text, location=None, radius=2000):\n", " # Retrieve the API key from environment variables\n", " api_key = os.getenv('GPLACES_API_KEY')\n", "\n", " if not api_key:\n", " raise ValueError(\"API key not found. Please set the GOOGLE_MAPS_API_KEY environment variable.\")\n", "\n", " # Define the endpoint URL\n", " url = \"https://maps.googleapis.com/maps/api/place/findplacefromtext/json\"\n", "\n", " # Define the parameters for the request\n", " params = {\n", " 'fields': 'formatted_address,name,rating,opening_hours,geometry',\n", " 'input': input_text,\n", " 'inputtype': 'textquery',\n", " 'key': api_key\n", " }\n", " \n", " params['locationbias'] = f'circle:{radius}@{location}' if location is not None and radius is not None else None\n", "\n", " # Make the request to the Google Maps API\n", " response = requests.get(url, params=params)\n", "\n", " # Check if the request was successful\n", " if response.status_code == 200:\n", " return response.json() # Return the JSON response\n", " else:\n", " response.raise_for_status() # Raise an exception for HTTP errors\n", "\n", "# Example usage:\n", "location = \"15.87,100.9925\" # Latitude and Longitude\n", "input_text = \"hotel\"\n", "result = find_place_from_text(input_text, location)\n", "\n", "print(result)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Coordinates: 13.744677,100.5295593\n" ] } ], "source": [ "def find_location(input_text:str, location:str=None, radius=10000):\n", " # Call the find_place_from_text function to get the location data\n", " data = find_place_from_text(input_text, location, radius)\n", "\n", " # Extract the latitude and longitude from the response\n", " candidates = data.get('candidates', [])\n", " if len(candidates)==0:\n", " raise ValueError(\"No location found.\")\n", "\n", " # Assuming we're taking the first candidate\n", " geometry = candidates[0].get('geometry', {})\n", " location = geometry.get('location', {})\n", "\n", " latitude = location.get('lat')\n", " longitude = location.get('lng')\n", "\n", " if latitude is None or longitude is None:\n", " raise ValueError(\"Latitude or Longitude not found in the response.\")\n", "\n", " # Return the latitude and longitude as a formatted string\n", " return f\"{latitude},{longitude}\"\n", "\n", "\n", "location = \"15.87,100.9925\" # Latitude and Longitude\n", "input_text = \"มาบุญครอง\"\n", "coordinates = find_location(input_text, location)\n", "print(f\"Coordinates: {coordinates}\")" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[{'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7455309, 'lng': 100.5198334},\n", " 'viewport': {'northeast': {'lat': 13.74692812989272,\n", " 'lng': 100.5214657798927},\n", " 'southwest': {'lat': 13.74422847010728, 'lng': 100.5187661201073}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'The Twin Towers Hotel',\n", " 'opening_hours': {'open_now': True},\n", " 'photos': [{'height': 1335,\n", " 'html_attributions': ['A Google User'],\n", " 'photo_reference': 'AXCi2Q5REfgaHadtFNqXOFpuxkVdoFf0rM5zy9Piw_WeOcuTwSKMqU2CgFnQoN6BRclj7SQ4s_eccxIdMd-Ul1pvz0EOjBikoWSlxvqLoZIauLg-YzlVvqfpd2bU0OfVKNarBaHYWn2hPMC0n2wShcIaz4I1hc89Bab018M4-BFexDp_gMFc',\n", " 'width': 2000}],\n", " 'place_id': 'ChIJ_zP3fy-Z4jARWYaBArPXGAg',\n", " 'plus_code': {'compound_code': 'PGW9+6W Bangkok',\n", " 'global_code': '7P52PGW9+6W'},\n", " 'rating': 4,\n", " 'reference': 'ChIJ_zP3fy-Z4jARWYaBArPXGAg',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 3326,\n", " 'vicinity': '88 ถ.พระราม 6 ตัดใหม่ Rong Muang, Pathum Wan'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7467728, 'lng': 100.5294726},\n", " 'viewport': {'northeast': {'lat': 13.74811892989272,\n", " 'lng': 100.5308482298927},\n", " 'southwest': {'lat': 13.74541927010728, 'lng': 100.5281485701073}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'Muangphol Mansion',\n", " 'opening_hours': {'open_now': False},\n", " 'photos': [{'height': 3000,\n", " 'html_attributions': ['Hassan Ahmadian'],\n", " 'photo_reference': 'AXCi2Q4AS3FJWETxFu9WbBFhhNhmjsSQZiKqiIGEVmqYgaPqhsgy9g7bWpjLp5WDzQQTnZPkrpAVnXTIQDxN3y_JF36mBoF0LVqgsrWVumTiokIETibGLIY7pL7ujSc7sqvOkr-WcX6pC9N8AyASE-vszjVYdso6gUCl8DtdalINk-bXBa8r',\n", " 'width': 4000}],\n", " 'place_id': 'ChIJZzgIrTKZ4jARJYzilmi9T74',\n", " 'plus_code': {'compound_code': 'PGWH+PQ Bangkok',\n", " 'global_code': '7P52PGWH+PQ'},\n", " 'rating': 3.3,\n", " 'reference': 'ChIJZzgIrTKZ4jARJYzilmi9T74',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 113,\n", " 'vicinity': '8, 931 Rama I Rd, Wang Mai, Pathum Wan'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7468712, 'lng': 100.52869},\n", " 'viewport': {'northeast': {'lat': 13.74810307989272,\n", " 'lng': 100.5300171798927},\n", " 'southwest': {'lat': 13.74540342010728, 'lng': 100.5273175201073}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'Lub d Bangkok Siam',\n", " 'opening_hours': {'open_now': False},\n", " 'photos': [{'height': 4000,\n", " 'html_attributions': ['Lub d Bangkok - Siam Square'],\n", " 'photo_reference': 'AXCi2Q6jzkjlHJJaGkIjVVevWBny8MMkNw90qEwgUEaQWAgPbdj4R12eZrVTpoUGawjhwWrDFuWSdEncNcPSncrVFNc2XcbEgE9dpjiGGKSWjUuwO9wFJBKBzEuNq16ey7eVMC8MPQRgqeE0rYKeY1o4IwNEKCEHmKigl3xvnURQ3HMTcPfQ',\n", " 'width': 6000}],\n", " 'place_id': 'ChIJc33lpDKZ4jARil4bO37UbIs',\n", " 'plus_code': {'compound_code': 'PGWH+PF Bangkok',\n", " 'global_code': '7P52PGWH+PF'},\n", " 'rating': 4.3,\n", " 'reference': 'ChIJc33lpDKZ4jARil4bO37UbIs',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 938,\n", " 'vicinity': '925, 9 Rama I Rd, Wang Mai, Pathum Wan'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7627061, 'lng': 100.5381273},\n", " 'viewport': {'northeast': {'lat': 13.76412432989272,\n", " 'lng': 100.5396005798927},\n", " 'southwest': {'lat': 13.76142467010728, 'lng': 100.5369009201073}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'The Victory View',\n", " 'opening_hours': {'open_now': True},\n", " 'photos': [{'height': 4000,\n", " 'html_attributions': ['A Google User'],\n", " 'photo_reference': 'AXCi2Q5sc9dLfaqO79qSoPvgA6E9rcouVekbl-jKloKDhM5ZVhnKmqEE2k9-jeg4kDUtFt-gE-f5P4YbOU2vdIjGaYg7GJyrzDrT7xLpT_UbIH2Km19g_H-JgQd1D3afrBvjtRklWFwDoCw7TnZtPqyF7GGia6yp4qPp7OLspmGR04BV0oAn',\n", " 'width': 6000}],\n", " 'place_id': 'ChIJ23PzgMme4jARFOY5eyKACAA',\n", " 'plus_code': {'compound_code': 'QG7Q+37 Bangkok',\n", " 'global_code': '7P52QG7Q+37'},\n", " 'rating': 4,\n", " 'reference': 'ChIJ23PzgMme4jARFOY5eyKACAA',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 125,\n", " 'vicinity': '34/2-3 Soi Ratchawithi 9, Thanon Phaya Thai, Ratchathewi'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7291738, 'lng': 100.5348174},\n", " 'viewport': {'northeast': {'lat': 13.73046032989272,\n", " 'lng': 100.5361918298927},\n", " 'southwest': {'lat': 13.72776067010728, 'lng': 100.5334921701073}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'Pula Silom',\n", " 'photos': [{'height': 2736,\n", " 'html_attributions': ['伊藤弘昭'],\n", " 'photo_reference': 'AXCi2Q7Jx_Q-bmUQXHf21Up5jca5HIbehddLbxXNbliIJzRtirLIoDxEZBB29hDcPKa4l5xVKWDbHobbvvrO_L2DFMonrHr5s36M3_0dLea9j_KPOhtmXMp1T_0ZMfyX7-fwwN7xivn2o1fJ9k8XduGbbGLAlllgBa0TmT4jEZYN4qcNHRpi',\n", " 'width': 3648}],\n", " 'place_id': 'ChIJbbU8_yuf4jARUTtSdD5kt7s',\n", " 'plus_code': {'compound_code': 'PGHM+MW Bangkok',\n", " 'global_code': '7P52PGHM+MW'},\n", " 'rating': 4.1,\n", " 'reference': 'ChIJbbU8_yuf4jARUTtSdD5kt7s',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 408,\n", " 'vicinity': '60/12-15 Si Lom Rd, Silom, Bang Rak'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7446989, 'lng': 100.5430063},\n", " 'viewport': {'northeast': {'lat': 13.74605242989272,\n", " 'lng': 100.5443317298927},\n", " 'southwest': {'lat': 13.74335277010728, 'lng': 100.5416320701073}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'Golden House',\n", " 'opening_hours': {'open_now': True},\n", " 'photos': [{'height': 2017,\n", " 'html_attributions': ['Golden House'],\n", " 'photo_reference': 'AXCi2Q7SNGkVzsificYOCpcJLixqVPAvgsnlvH8BqnoPmI5dKRJDzd5v5TOYHyQoZKkGVHoPzjr1Z964FihrKk-k_1PZw_J1ME_nsux1Q_xbozq6iekPVS7n6RvmuH6ueYSp0XTpo0FeawGHoJuy_5DPlHC9nJHYkzsl2mMcF2sb7-jqG1gZ',\n", " 'width': 3162}],\n", " 'place_id': 'ChIJIcSl3Nqe4jARnLh2qK_RMRo',\n", " 'plus_code': {'compound_code': 'PGVV+V5 Bangkok',\n", " 'global_code': '7P52PGVV+V5'},\n", " 'rating': 3.7,\n", " 'reference': 'ChIJIcSl3Nqe4jARnLh2qK_RMRo',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 203,\n", " 'vicinity': '1025/5-9 Ploenchit Road, Lumpinee, Pathum Wan'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7559816, 'lng': 100.5363536},\n", " 'viewport': {'northeast': {'lat': 13.75731082989272,\n", " 'lng': 100.5377502298927},\n", " 'southwest': {'lat': 13.75461117010728, 'lng': 100.5350505701073}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'Top High Airport Link Hotel',\n", " 'opening_hours': {'open_now': True},\n", " 'photos': [{'height': 2832,\n", " 'html_attributions': ['A Google User'],\n", " 'photo_reference': 'AXCi2Q4dmmfllqiiSF6ET2O85klRu0znHLiv413DFjpor2RQow_l7XzHA-SqwKwO2z1_52DLfGzanhokS0pZscaSKNfS6jPcKC9mCwMllD5ZyOAP8GxyQiyslP5Y5RjAiBkXy8ViRv4aOSthNUehBdks-7yQmII9BxLx-Elpm4InCk46UlmZ',\n", " 'width': 4256}],\n", " 'place_id': 'ChIJcefUlMme4jARJGbWS6DCn9c',\n", " 'plus_code': {'compound_code': 'QG4P+9G Bangkok',\n", " 'global_code': '7P52QG4P+9G'},\n", " 'rating': 3.9,\n", " 'reference': 'ChIJcefUlMme4jARJGbWS6DCn9c',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 1119,\n", " 'vicinity': '33 Soi Phetchaburi 11, Thanon Phaya Thai, Ratchathewi'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7614685, 'lng': 100.5376939},\n", " 'viewport': {'northeast': {'lat': 13.76284452989272,\n", " 'lng': 100.5389958798927},\n", " 'southwest': {'lat': 13.76014487010728, 'lng': 100.5362962201073}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'Rose Apple Hotel',\n", " 'photos': [{'height': 3024,\n", " 'html_attributions': ['Fred'],\n", " 'photo_reference': 'AXCi2Q6zjoNtQ1zTKlHiyZ7PRXL2tageAblx1DpY1sYVYImvQw9DRkx86IKGJWiDbUiunBtN2wmFSlO2SYhFDND5Wm7fRBI0ll_8tOv0bFf-iIV-vpeEf_3vx-ABaqgeK7N4vuUnK_21XznpBAu19j5MptYAFiKOPmDYZ6_SJ7aIbsZNkQqu',\n", " 'width': 4032}],\n", " 'place_id': 'ChIJXTStwbCe4jARXRRo179r6nk',\n", " 'plus_code': {'compound_code': 'QG6Q+H3 Bangkok',\n", " 'global_code': '7P52QG6Q+H3'},\n", " 'rating': 4.4,\n", " 'reference': 'ChIJXTStwbCe4jARXRRo179r6nk',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 139,\n", " 'vicinity': '29/1 Soi Loet Punya, Thanon Phaya Thai, Ratchathewi'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.751193, 'lng': 100.5355507},\n", " 'viewport': {'northeast': {'lat': 13.75254982989272,\n", " 'lng': 100.5368565298927},\n", " 'southwest': {'lat': 13.74985017010728, 'lng': 100.5341568701073}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'The Residence Ratchathewi',\n", " 'opening_hours': {'open_now': True},\n", " 'photos': [{'height': 1068,\n", " 'html_attributions': ['The Residence Rajtaevee'],\n", " 'photo_reference': 'AXCi2Q5SM-DKx1XwfyUEK-5LuAzlFJMjmEgByT5v-0Q5iulo2CiIqOaPotdKbRBCObOYwsMfbasqecewPpWrqWQ_Iz6e7sAeSUVDlAfzwszEEb8WZBPG3IiPEUybhxfLmaG_Ubi5vX16bJYjDTjBVN493Tx_7zzkClVJiwVhhpZiDSIVwekh',\n", " 'width': 1600}],\n", " 'place_id': 'ChIJx0cHr86e4jAReGZBl579QlY',\n", " 'plus_code': {'compound_code': 'QG2P+F7 Bangkok',\n", " 'global_code': '7P52QG2P+F7'},\n", " 'rating': 3.8,\n", " 'reference': 'ChIJx0cHr86e4jAReGZBl579QlY',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 442,\n", " 'vicinity': '588/1 Phetchaburi Rd, Khwaeng Thanon Phetchaburi, Ratchathewi'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7431972, 'lng': 100.5301387},\n", " 'viewport': {'northeast': {'lat': 13.74441047989272,\n", " 'lng': 100.5314606298927},\n", " 'southwest': {'lat': 13.74171082010728, 'lng': 100.5287609701073}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'Pathumwan Princess Hotel',\n", " 'opening_hours': {'open_now': True},\n", " 'photos': [{'height': 2000,\n", " 'html_attributions': ['A Google User'],\n", " 'photo_reference': 'AXCi2Q5vfp2-YyDznWo7BzJjpWdDG46oBD_E361wRvxqbPuTWQXeqw6ZJKLs4ApM57kGqfBWFCM8X4Ge1eMcr1CYyL2G2g2D5xaSjH0aZhOVby1DTuhoaQIutT1dD_bvhLC1L1yOh6_VEagO8MONFPbsVglCBG-5KdYWP8sz5Pb0msg92dLP',\n", " 'width': 3000}],\n", " 'place_id': 'ChIJFaLTtdKe4jARdKflx49LvdA',\n", " 'plus_code': {'compound_code': 'PGVJ+73 Bangkok',\n", " 'global_code': '7P52PGVJ+73'},\n", " 'rating': 4.5,\n", " 'reference': 'ChIJFaLTtdKe4jARdKflx49LvdA',\n", " 'scope': 'GOOGLE',\n", " 'types': ['shopping_mall',\n", " 'tourist_attraction',\n", " 'restaurant',\n", " 'food',\n", " 'lodging',\n", " 'point_of_interest',\n", " 'establishment'],\n", " 'user_ratings_total': 7827,\n", " 'vicinity': '444 Phaya Thai Rd, Wang Mai, Pathum Wan'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7419343, 'lng': 100.5246099},\n", " 'viewport': {'northeast': {'lat': 13.74333472989272,\n", " 'lng': 100.5259674798927},\n", " 'southwest': {'lat': 13.74063507010728, 'lng': 100.5232678201073}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'HOUSE OF PAPA BANGKOK SIAM',\n", " 'opening_hours': {'open_now': True},\n", " 'photos': [{'height': 1044,\n", " 'html_attributions': ['A Google User'],\n", " 'photo_reference': 'AXCi2Q7jN3KUm4mIFgLRlbT3_UYH3VfSHoCBZX_9ovZXRxxVFG2RyJqj6iOeWGYDnZ0f4NG4cHNrbwNynR4hstsMUDDhafMc5thD8K1iBF-31OivN6fPwA0pqRt9HLNErtmiSxJugmpFqHV2u7q7Y1OCbFOyVfX_c3oLD24mzhkv5T960Ugf',\n", " 'width': 1568}],\n", " 'place_id': 'ChIJQVtmplSZ4jARsWxKD388HB0',\n", " 'plus_code': {'compound_code': 'PGRF+QR Bangkok',\n", " 'global_code': '7P52PGRF+QR'},\n", " 'rating': 4.2,\n", " 'reference': 'ChIJQVtmplSZ4jARsWxKD388HB0',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 165,\n", " 'vicinity': '188/44, Soi Chula 16, Wang Mai, Pathum Wan'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7471052, 'lng': 100.5289501},\n", " 'viewport': {'northeast': {'lat': 13.74819247989272,\n", " 'lng': 100.5302628798927},\n", " 'southwest': {'lat': 13.74549282010728, 'lng': 100.5275632201073}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'ไอบิส กรุงเทพ สยาม',\n", " 'photos': [{'height': 1920,\n", " 'html_attributions': ['Hotel ibis Bangkok Siam'],\n", " 'photo_reference': 'AXCi2Q5xaKlLVvq7ppUkSrD2tnTn34qtSlCFgfmE6xsnlhr1DA8wQ22pDGhzknJ1BKfmWax-GKW57vntFfXOVmTzM6fud-hatURpuFzGVmMPmu1716oqhBBk6mRvwRQN5bxsX5Wr_-yV_IOTrcjtTBG5-eCB8yETQeym9mDEVMIzogyoqA45',\n", " 'width': 2880}],\n", " 'place_id': 'ChIJaUcw7c2e4jAR0sfKCxcl2aM',\n", " 'plus_code': {'compound_code': 'PGWH+RH Bangkok',\n", " 'global_code': '7P52PGWH+RH'},\n", " 'rating': 4.4,\n", " 'reference': 'ChIJaUcw7c2e4jAR0sfKCxcl2aM',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 2873,\n", " 'vicinity': '927 Rama I Rd, Wangmai, Pathum Wan'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7364607, 'lng': 100.5485186},\n", " 'viewport': {'northeast': {'lat': 13.73779277989272,\n", " 'lng': 100.5499788798927},\n", " 'southwest': {'lat': 13.73509312010728, 'lng': 100.5472792201073}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'The Quart Ruamrudee by UHG',\n", " 'photos': [{'height': 1108,\n", " 'html_attributions': ['A Google User'],\n", " 'photo_reference': 'AXCi2Q6b1PqeLgJRnsC_1ElB0ibnqOOYWLhi7YE8J8RXFjeThrX1q51n0lP9LMzOvlSGxgpzzkbbu1ZPuAFfJ_GZswMXlZClrcN7iSDuMtfMXdL_knJHUBWe-1Eescu0Mnx09aL6gnivm4cDvinyBeBWxG9bDk-d6vcpNoICJ0fiO2MmZd2q',\n", " 'width': 1477}],\n", " 'place_id': 'ChIJS5Dv_n-f4jARd6xZQlSXjlM',\n", " 'plus_code': {'compound_code': 'PGPX+HC Bangkok',\n", " 'global_code': '7P52PGPX+HC'},\n", " 'rating': 3.9,\n", " 'reference': 'ChIJS5Dv_n-f4jARd6xZQlSXjlM',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 538,\n", " 'vicinity': '38/3 Soi Ruamrudee Community, Lumphini, Pathum Wan'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7322506, 'lng': 100.5271641},\n", " 'viewport': {'northeast': {'lat': 13.73356032989272,\n", " 'lng': 100.5285219298927},\n", " 'southwest': {'lat': 13.73086067010728, 'lng': 100.5258222701073}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'Sam Yan Serene Hotel',\n", " 'photos': [{'height': 2268,\n", " 'html_attributions': ['塩谷, 一'],\n", " 'photo_reference': 'AXCi2Q7n1pLt2iSHnPmh_q5Mf2g99zD3kKVTJnJfciX6R3SUcQWZ9xw2wC4xDlLgOWwwlwFwyqkc1EB-YBTEXg4RmDbTc5ynGR-ujCNJWJh8GAia999zgcok_-UWt0sta4E_wO4dCV6H_EMdu-iu6qSxxTt-uexcCbW8AHVpKEiwzsaRS5bQ',\n", " 'width': 4032}],\n", " 'place_id': 'ChIJq_Saj9aY4jAREUtIU3WA4Gk',\n", " 'plus_code': {'compound_code': 'PGJG+WV Bangkok',\n", " 'global_code': '7P52PGJG+WV'},\n", " 'rating': 4,\n", " 'reference': 'ChIJq_Saj9aY4jAREUtIU3WA4Gk',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 285,\n", " 'vicinity': '38 Si Phraya Rd, Bangkok'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7372782, 'lng': 100.5170473},\n", " 'viewport': {'northeast': {'lat': 13.73869057989272,\n", " 'lng': 100.5184239798927},\n", " 'southwest': {'lat': 13.73599092010728, 'lng': 100.5157243201073}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'Metro Hotel',\n", " 'opening_hours': {'open_now': True},\n", " 'photos': [{'height': 5067,\n", " 'html_attributions': ['A Google User'],\n", " 'photo_reference': 'AXCi2Q7cr19LNUMipfJeB7TnqQw6nXsB26EadyXaYKXWhY4D-_dLCE45b14GtGoHkowfV10UsE4N6EmR3w_CsLSOEpeyGkRIU-rnP3-8lf-xyVl6om-Rc6RvpSI2QCx8OrbOJZIl1BBc0icvbAMD-ctah05qNmdiJwR0Kdh8HlAO_8H_zk9Q',\n", " 'width': 3378}],\n", " 'place_id': 'ChIJIeFfV9aZ4jARpd4v7wFD6BQ',\n", " 'plus_code': {'compound_code': 'PGP8+VR Bangkok',\n", " 'global_code': '7P52PGP8+VR'},\n", " 'rating': 4.8,\n", " 'reference': 'ChIJIeFfV9aZ4jARpd4v7wFD6BQ',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 654,\n", " 'vicinity': '326, 20-22 Rama IV Rd, Mahapreuttaram, Bang Rak'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7465184, 'lng': 100.5408834},\n", " 'viewport': {'northeast': {'lat': 13.74800027989272,\n", " 'lng': 100.5420810298927},\n", " 'southwest': {'lat': 13.74530062010728, 'lng': 100.5393813701073}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'Arnoma Grand Bangkok',\n", " 'opening_hours': {'open_now': False},\n", " 'photos': [{'height': 2268,\n", " 'html_attributions': ['Joshua Elmer Dungca'],\n", " 'photo_reference': 'AXCi2Q5MfTeLf7FACorI5XTlxWwS4AypfcTJ4kFFRZk922b6MMVawZdZndQg92tWUMIdysVxM9TudMI0BtJWYm7nuDsAHDY9h4YLGS8MNdy3ov3FvOKsFJkRMGNwfk3DoAPVAeseLxMh_P8Uz65WdULELRQFlXNZEKeSiYhX4Ctenb_6Ez05',\n", " 'width': 4032}],\n", " 'place_id': 'ChIJF8c59s-e4jARoz5R8nHRj2Y',\n", " 'plus_code': {'compound_code': 'PGWR+J9 Bangkok',\n", " 'global_code': '7P52PGWR+J9'},\n", " 'rating': 4,\n", " 'reference': 'ChIJF8c59s-e4jARoz5R8nHRj2Y',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 2601,\n", " 'vicinity': '99 Ratchadamri Rd, Lumphini, Pathum Wan'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7339076, 'lng': 100.5265974},\n", " 'viewport': {'northeast': {'lat': 13.73522732989272,\n", " 'lng': 100.5279341798927},\n", " 'southwest': {'lat': 13.73252767010728, 'lng': 100.5252345201073}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'Chatel Bkk',\n", " 'opening_hours': {'open_now': True},\n", " 'photos': [{'height': 3719,\n", " 'html_attributions': ['A Google User'],\n", " 'photo_reference': 'AXCi2Q5XT1UqDzekBotIXdVzCAsxMvwZ34SlJF-d4-vKKbJlYK6AuYmJqNzErrTV0J-6P30JduNShr_gSZ_RKlRAVTcP2dsHvKyg7U5o5dxzGwOthzZXKGPQEsb4JPtyrxyC99H71rhIP_fiypmLgQBvUms1GrsHlNq4CqfcTDngO7MO93x7',\n", " 'width': 2479}],\n", " 'place_id': 'ChIJFdaF_GSZ4jARuvbTqZTXVDw',\n", " 'plus_code': {'compound_code': 'PGMG+HJ Bangkok',\n", " 'global_code': '7P52PGMG+HJ'},\n", " 'rating': 4.4,\n", " 'reference': 'ChIJFdaF_GSZ4jARuvbTqZTXVDw',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 51,\n", " 'vicinity': '1523 Rama IV Rd, Wang Mai, Pathum Wan'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7571273, 'lng': 100.5219133},\n", " 'viewport': {'northeast': {'lat': 13.75845417989272,\n", " 'lng': 100.5233274798927},\n", " 'southwest': {'lat': 13.75575452010728, 'lng': 100.5206278201073}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'Bangkok City Suite Hotel',\n", " 'opening_hours': {'open_now': True},\n", " 'photos': [{'height': 3024,\n", " 'html_attributions': ['A Google User'],\n", " 'photo_reference': 'AXCi2Q5UyAkBzi6Mfc9I5YPy7GkFHc6n6x0zOixA7U8iDsmS-vVCFLjTbv6fITGoTHqh2YrsVpm-2fmt6_mwHpjqYPn1We7okIhQRf6Lt3eQNRxOydhhk0Qrf5oT9mvx6WEuSUgOP6tPHPCTxY53z-W9zPZmnLCAWc6WO2mnLkVzL0EG2yny',\n", " 'width': 4032}],\n", " 'place_id': 'ChIJVZaxPHBvHTERUmo7I6b5kt0',\n", " 'plus_code': {'compound_code': 'QG4C+VQ Bangkok',\n", " 'global_code': '7P52QG4C+VQ'},\n", " 'rating': 3.9,\n", " 'reference': 'ChIJVZaxPHBvHTERUmo7I6b5kt0',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 1306,\n", " 'vicinity': '1 Petchburi Road Khwaeng Thung Phaya Thai, Ratchathewi'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7469059, 'lng': 100.5488508},\n", " 'viewport': {'northeast': {'lat': 13.74826502989272,\n", " 'lng': 100.5502038798927},\n", " 'southwest': {'lat': 13.74556537010728, 'lng': 100.5475042201073}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'Nantra Ploenchit hotel',\n", " 'photos': [{'height': 4032,\n", " 'html_attributions': ['112882529924094151036'],\n", " 'photo_reference': 'AXCi2Q7GqZhH0esGR-zcPCShb-NTd6lBBLoasdckPbr-FKmo-dFkuY3Zpyh464c4Q5vHz80hqRsc0KGrZrFh0ujJwprqjvF4vY3I7FvLAOoh_cPWoU_a87IRZxhilZ8_6NmtUhIjP8bzsdEQgw66eo19rl77YmxA8cJEcQc2fsbNfboauPDu',\n", " 'width': 3024}],\n", " 'place_id': 'ChIJEV_8Viqf4jARu_t2Fy_JV1Q',\n", " 'plus_code': {'compound_code': 'PGWX+PG Bangkok',\n", " 'global_code': '7P52PGWX+PG'},\n", " 'rating': 3,\n", " 'reference': 'ChIJEV_8Viqf4jARu_t2Fy_JV1Q',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 202,\n", " 'vicinity': '27/12 Soi Nai Loet, Lumphini, Pathum Wan'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7300383, 'lng': 100.5311334},\n", " 'viewport': {'northeast': {'lat': 13.73128477989272,\n", " 'lng': 100.5325170298927},\n", " 'southwest': {'lat': 13.72858512010728, 'lng': 100.5298173701073}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': '56 Surawong Hotel Bangkok',\n", " 'opening_hours': {'open_now': True},\n", " 'photos': [{'height': 1067,\n", " 'html_attributions': ['A Google User'],\n", " 'photo_reference': 'AXCi2Q4GgGfJLURqRbHSfZ5MAc1dCZf_NUFv9aJ9yhRd5t7XvuXiUQRLPkXuUYRL3M7GCmx_YbvhRCUDLYwFcMEap9trlMS8W10K6ToaY0HjQFfqgy7g6rJfUYU6-_9nDt_oS9XdS9Pp0nK2x9W0wZ2tpZ5zib1JbOp_h9Zdf4ri4Z-wgfla',\n", " 'width': 1600}],\n", " 'place_id': 'ChIJOw15HtOY4jARCqQ2iTDgqYc',\n", " 'plus_code': {'compound_code': 'PGJJ+2F Bangkok',\n", " 'global_code': '7P52PGJJ+2F'},\n", " 'rating': 3.9,\n", " 'reference': 'ChIJOw15HtOY4jARCqQ2iTDgqYc',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 228,\n", " 'vicinity': '56 Surawong Rd, Silom, Bang Rak'},\n", " []]" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "def nearby_search(keyword:str, location:str, radius=2000, place_type=None):\n", " # Retrieve the API key from environment variables\n", " api_key = os.getenv('GPLACES_API_KEY')\n", "\n", " if not api_key:\n", " raise ValueError(\"API key not found. Please set the GOOGLE_MAPS_API_KEY environment variable.\")\n", "\n", " # Define the endpoint URL\n", " url = \"https://maps.googleapis.com/maps/api/place/nearbysearch/json\"\n", "\n", " # Set up the parameters for the request\n", " params = {\n", " 'keyword': keyword,\n", " 'location': location,\n", " 'radius': radius,\n", " 'type': place_type,\n", " 'key': api_key,\n", " \"rankPreference\": \"DISTANCE\"\n", " }\n", "\n", " # Send the GET request to the Google Maps API\n", " response = requests.get(url, params=params)\n", "\n", " # Check if the request was successful\n", " if response.status_code != 200:\n", " raise Exception(f\"Error with request: {response.status_code}, {response.text}\")\n", "\n", " # Parse the JSON response\n", " data = response.json()\n", " results = data['results']\n", "\n", " # search into next page\n", " while data.get('next_page_token', False):\n", " params = {'next_page_token': data['next_page_token']}\n", " response = requests.get(url, params=params)\n", " \n", " if response.status_code != 200:\n", " raise Exception(f\"Error with request: {response.status_code}, {response.text}\")\n", " \n", " data = response.json()\n", " \n", " results.append(data['results'])\n", " \n", "\n", " # Return the response data\n", " return results\n", "\n", "\n", "# Example usage\n", "location = \"13.744677,100.5295593\" # Latitude and Longitude\n", "keyword = \"hotel\"\n", "search_results = nearby_search(keyword, location)\n", "search_results" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[{'geometry': {'location': {'lat': 13.7563309, 'lng': 100.5017651},\n", " 'viewport': {'northeast': {'lat': 13.9551109646008,\n", " 'lng': 100.9384080394661},\n", " 'southwest': {'lat': 13.4940880622837, 'lng': 100.3278135588086}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/geocode-71.png',\n", " 'icon_background_color': '#7B9EB0',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/generic_pinlet',\n", " 'name': 'Bangkok',\n", " 'photos': [{'height': 934,\n", " 'html_attributions': ['Harshvardhan Mali'],\n", " 'photo_reference': 'AXCi2Q7YQKg0xaKoM2A3vnYzyOIQDC5TrsQxNtbyot19fPkxmovfe5guH88XxTEr5R8FCOErr4FCh0o6j1HixapR7hf4vxt-BqYE7pt_5ALwZaeCvO8b7CAtTX6gTmH7euXg0NbxdLQhUE7h_LB2OaUgr4mBnTVHr2d0pnLYOBoPmuSQbIXP',\n", " 'width': 756}],\n", " 'place_id': 'ChIJ82ENKDJgHTERIEjiXbIAAQE',\n", " 'reference': 'ChIJ82ENKDJgHTERIEjiXbIAAQE',\n", " 'scope': 'GOOGLE',\n", " 'types': ['locality', 'political'],\n", " 'vicinity': 'Bangkok'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7431972, 'lng': 100.5301387},\n", " 'viewport': {'northeast': {'lat': 13.7444096302915,\n", " 'lng': 100.5314597802915},\n", " 'southwest': {'lat': 13.7417116697085, 'lng': 100.5287618197085}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'Pathumwan Princess Hotel',\n", " 'opening_hours': {'open_now': True},\n", " 'photos': [{'height': 2000,\n", " 'html_attributions': ['Pathumwan Princess Hotel'],\n", " 'photo_reference': 'AXCi2Q5LkQj0Ts-4Sp_GZYboiNY7C5G7Mq6jPeLjvphMxG5T5C-HKDqOHURuvjxIF52_-5BzLu_9QJk0__pY-cizYAN6GoUEpV_busoOGPt67wmF9d-0Xg8ma_61xPbXC1s2oPvqVLTAMO9586thNfnNZZYRsspucrS0xL4m45-0XjknvQPU',\n", " 'width': 3000}],\n", " 'place_id': 'ChIJFaLTtdKe4jARdKflx49LvdA',\n", " 'plus_code': {'compound_code': 'PGVJ+73 Bangkok, Thailand',\n", " 'global_code': '7P52PGVJ+73'},\n", " 'rating': 4.5,\n", " 'reference': 'ChIJFaLTtdKe4jARdKflx49LvdA',\n", " 'scope': 'GOOGLE',\n", " 'types': ['shopping_mall',\n", " 'lodging',\n", " 'tourist_attraction',\n", " 'restaurant',\n", " 'food',\n", " 'point_of_interest',\n", " 'establishment'],\n", " 'user_ratings_total': 7827,\n", " 'vicinity': '444 Phaya Thai Road, Khwaeng Wang Mai, Pathum Wan'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7484011, 'lng': 100.5348436},\n", " 'viewport': {'northeast': {'lat': 13.7497612802915,\n", " 'lng': 100.5361483302915},\n", " 'southwest': {'lat': 13.7470633197085, 'lng': 100.5334503697085}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'Siam Kempinski Hotel Bangkok',\n", " 'photos': [{'height': 1080,\n", " 'html_attributions': ['Siam Kempinski Hotel Bangkok'],\n", " 'photo_reference': 'AXCi2Q7EgE9SGO-SvlsR16qRVmWU6cn3DnYXS9Vc3ee9OegYK0RR9nW3eUEZA03XPAxqb9TurWDybQmlbnzf21ccieSRCGxyPhQjRQG8zySzjWmYA8I-KuTnr1Gnl_LOpmv3d1Q4aHI7SqybBee6mCwiDp4yFlCNzxAgkmn8TmMjEulv4U-_',\n", " 'width': 1920}],\n", " 'place_id': 'ChIJrfU90s2e4jARs0XZP2DZ4jM',\n", " 'plus_code': {'compound_code': 'PGXM+9W Bangkok, Thailand',\n", " 'global_code': '7P52PGXM+9W'},\n", " 'rating': 4.7,\n", " 'reference': 'ChIJrfU90s2e4jARs0XZP2DZ4jM',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 5171,\n", " 'vicinity': '991, 9 Rama I Road, Khwaeng Pathum Wan, Pathum Wan'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7477183, 'lng': 100.5387477},\n", " 'viewport': {'northeast': {'lat': 13.7491090802915,\n", " 'lng': 100.5398112302915},\n", " 'southwest': {'lat': 13.7464111197085, 'lng': 100.5371132697085}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'Centara Grand & Bangkok Convention Centre at centralwOrld',\n", " 'opening_hours': {'open_now': True},\n", " 'photos': [{'height': 2832,\n", " 'html_attributions': ['Centara Grand & Bangkok Convention Centre at centralwOrld'],\n", " 'photo_reference': 'AXCi2Q7Ta6rxawyYVXTRXdSg2x9t-a80ym0BUeS2ypzi8H0zQzUiQh_JpBu_rx2PfIjnMvCEIDbTbJcm-3ra4G9_HbJrTD7wp5y5HWr7Cd2wnedaBck-VuSdEOHwP5NAYJU0qh_2uAUPGXaOME5WepAUjZr5czm5KPHI3U9Q8oMc5Aodw_QW',\n", " 'width': 4148}],\n", " 'place_id': 'ChIJf1YJeC-Z4jARNNLn8M9QwMw',\n", " 'plus_code': {'compound_code': 'PGXQ+3F Bangkok, Thailand',\n", " 'global_code': '7P52PGXQ+3F'},\n", " 'rating': 4.6,\n", " 'reference': 'ChIJf1YJeC-Z4jARNNLn8M9QwMw',\n", " 'scope': 'GOOGLE',\n", " 'types': ['bar',\n", " 'lodging',\n", " 'spa',\n", " 'restaurant',\n", " 'food',\n", " 'point_of_interest',\n", " 'establishment'],\n", " 'user_ratings_total': 6175,\n", " 'vicinity': '999, 99 Rama I Road, Khwaeng Pathum Wan, Pathum Wan'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.750779, 'lng': 100.5306845},\n", " 'viewport': {'northeast': {'lat': 13.7521981302915,\n", " 'lng': 100.5321781302915},\n", " 'southwest': {'lat': 13.7495001697085, 'lng': 100.5294801697085}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'Evergreen Place Siam by UHG',\n", " 'opening_hours': {'open_now': True},\n", " 'photos': [{'height': 4752,\n", " 'html_attributions': ['Evergreen Place Bangkok'],\n", " 'photo_reference': 'AXCi2Q4muyWoLyCdS-OALMacN_R7o7xCPoGgvlERfZ_NhHG2HH7J_YieoOxuxELqy974nkWvto5G5y0baqoaIeKnIKjjFD95ztA0XRQNG3-3j6EA435MOmiyHifAZpC5Y-o0Hy4QL7DXWZQ_WMu4ZaL4LjlrdWo75XcO_qnMVPCIK1nghWtU',\n", " 'width': 3168}],\n", " 'place_id': 'ChIJH2h86IGe4jARE5sKrclMXL8',\n", " 'plus_code': {'compound_code': 'QG2J+87 Bangkok, Thailand',\n", " 'global_code': '7P52QG2J+87'},\n", " 'rating': 4.1,\n", " 'reference': 'ChIJH2h86IGe4jARE5sKrclMXL8',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 2228,\n", " 'vicinity': '318 Phaya Thai Road, Khwaeng Thanon Phetchaburi, Khet Ratchathewi'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7511798, 'lng': 100.5356322},\n", " 'viewport': {'northeast': {'lat': 13.7525489802915,\n", " 'lng': 100.5368556802915},\n", " 'southwest': {'lat': 13.7498510197085, 'lng': 100.5341577197085}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'The Residence Ratchathewi',\n", " 'opening_hours': {'open_now': True},\n", " 'photos': [{'height': 1068,\n", " 'html_attributions': ['The Residence Ratchathewi'],\n", " 'photo_reference': 'AXCi2Q40k5jMnJW1S1uGhuZSW94oIfZF8wHpo3Bj6TJC3E4sdysozDQh2lqjxEvpmvAQtGy4Eg6PcTx2HrUUvOIP9Y15DkZFmGn-lMQh8pA5OLCt0GYm06OhU0yQfdXimxI4sf51LoVmCPQe8fmDUslDwGIvofrR_x3JCEP0VCOG0nIkoZwS',\n", " 'width': 1600}],\n", " 'place_id': 'ChIJx0cHr86e4jAReGZBl579QlY',\n", " 'plus_code': {'compound_code': 'QG2P+F7 Bangkok, Thailand',\n", " 'global_code': '7P52QG2P+F7'},\n", " 'rating': 3.8,\n", " 'reference': 'ChIJx0cHr86e4jAReGZBl579QlY',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 442,\n", " 'vicinity': '588/1 Phetchaburi Road, Khet Ratchathewi'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7513459, 'lng': 100.5310997},\n", " 'viewport': {'northeast': {'lat': 13.7528344302915,\n", " 'lng': 100.5325368302915},\n", " 'southwest': {'lat': 13.7501364697085, 'lng': 100.5298388697085}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'Asia Hotel Bangkok',\n", " 'opening_hours': {'open_now': True},\n", " 'photos': [{'height': 427,\n", " 'html_attributions': ['Asia Hotel Bangkok'],\n", " 'photo_reference': 'AXCi2Q7nMLxEeLXVxZNstAsZ4vDIIYT7CHmklnHs1AAJGRKHwwjF8Blo6GhibN3c1kYltnfCdETbxjybjxNlUCDwOPjUbnsuWWn00LLOxHmr1RxmFgte3N_5yD7NrL7vz3sx_nHorDWjsvlaWS9Hnp1DFUghMBmpOetKLYppCei033sqH4h-',\n", " 'width': 640}],\n", " 'place_id': 'ChIJH2h86IGe4jARyjZ6wppSlkQ',\n", " 'plus_code': {'compound_code': 'QG2J+GC Bangkok, Thailand',\n", " 'global_code': '7P52QG2J+GC'},\n", " 'rating': 4,\n", " 'reference': 'ChIJH2h86IGe4jARyjZ6wppSlkQ',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 5468,\n", " 'vicinity': '296 Phaya Thai Road'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7497353, 'lng': 100.5403252},\n", " 'viewport': {'northeast': {'lat': 13.7510947302915,\n", " 'lng': 100.5419947802915},\n", " 'southwest': {'lat': 13.7483967697085, 'lng': 100.5392968197085}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'Novotel Bangkok Platinum Pratunam',\n", " 'photos': [{'height': 4024,\n", " 'html_attributions': ['Novotel Bangkok Platinum Pratunam'],\n", " 'photo_reference': 'AXCi2Q6qBZ56Y6UPn9TtOCZxNBKny35eINZpxu6Ll7MarDESm49gmVQxgfnXD8ry7DYY501I4bmEyaocd0DT1oVse5HR4fe5tLL_xfNR5lIvJ1-2MPnjBvFRJaVJ-0URC0xxL808OuQvPtRVGi6oUuMCZ5aG6KAfMUpukCZ7PZFW_Z7zx67e',\n", " 'width': 6048}],\n", " 'place_id': 'ChIJN6o_Yc-e4jARBCxlg57zM4s',\n", " 'plus_code': {'compound_code': 'PGXR+V4 Bangkok, Thailand',\n", " 'global_code': '7P52PGXR+V4'},\n", " 'rating': 4.4,\n", " 'reference': 'ChIJN6o_Yc-e4jARBCxlg57zM4s',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 4798,\n", " 'vicinity': '220 Phetchaburi Road'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7467415, 'lng': 100.5287877},\n", " 'viewport': {'northeast': {'lat': 13.7480168802915,\n", " 'lng': 100.5301780802915},\n", " 'southwest': {'lat': 13.7453189197085, 'lng': 100.5274801197085}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'MERCURE BANGKOK SIAM',\n", " 'photos': [{'height': 768,\n", " 'html_attributions': ['MERCURE BANGKOK SIAM'],\n", " 'photo_reference': 'AXCi2Q4h4s74XCGAsTARx1UNg18HQj3Zq8H1K-V6fC7bSuPDnIvDt3KCNUokAsMNcYe51GuFfrI6HzgnOMTbsS2H8R2vNdV2ux_A2VJQiNT2L7Np-M_gTDIUbYlD_uvyJDZQ-Pd3PknEz4x64mInT25nsq_R6YTq1ZvcrHiy0XZCl1lqX6Al',\n", " 'width': 1024}],\n", " 'place_id': 'ChIJKS_DaA6Z4jARDH_5sbrMXfI',\n", " 'plus_code': {'compound_code': 'PGWH+MG Bangkok, Thailand',\n", " 'global_code': '7P52PGWH+MG'},\n", " 'rating': 4.4,\n", " 'reference': 'ChIJKS_DaA6Z4jARDH_5sbrMXfI',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 2243,\n", " 'vicinity': '927 Rama I Road, Wangmai'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.748779, 'lng': 100.530772},\n", " 'viewport': {'northeast': {'lat': 13.7499488302915,\n", " 'lng': 100.5321700302915},\n", " 'southwest': {'lat': 13.7472508697085, 'lng': 100.5294720697085}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'Hua Chang Heritage Hotel',\n", " 'photos': [{'height': 2912,\n", " 'html_attributions': ['มิสสยาม โรงแรมหัวช้าง เฮอริเทจ'],\n", " 'photo_reference': 'AXCi2Q6Sbu_BgfBc6TSf5sOYIsTgC8JzttjJIuMgMwsTHAOhwCq-d1QOPKbtwbBNLLS0dfVXu4XHqkYBLYab0AEBtTa59con0Gw2L4F3MgQfjw_Y0mF9R9XgKFHdXMn0XZgyqlEpby-wswex8VgXV-dn9k_eequgTZuuZfGyDGhYsT1C3sYl',\n", " 'width': 4271}],\n", " 'place_id': 'ChIJUUD5KBOZ4jAR0QLGy07t3BQ',\n", " 'plus_code': {'compound_code': 'PGXJ+G8 Bangkok, Thailand',\n", " 'global_code': '7P52PGXJ+G8'},\n", " 'rating': 4.3,\n", " 'reference': 'ChIJUUD5KBOZ4jAR0QLGy07t3BQ',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 1056,\n", " 'vicinity': '400 Phaya Thai Road, Khwaeng Wang Mai, Pathum Wan'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7417243, 'lng': 100.5410489},\n", " 'viewport': {'northeast': {'lat': 13.7429306802915,\n", " 'lng': 100.5424668802915},\n", " 'southwest': {'lat': 13.7402327197085, 'lng': 100.5397689197085}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'Grande Centre Point Ratchadamri',\n", " 'opening_hours': {'open_now': True},\n", " 'photos': [{'height': 1999,\n", " 'html_attributions': ['Grande Centre Point Ratchadamri'],\n", " 'photo_reference': 'AXCi2Q53dAR1e3p0YCUsrw--FQNC6neK_zSj7XU5g_tc21UVLf8VbQjX9rPnjq-gdyQa-kzRV9RD-X3Eg9uzoiTU8VAjQ0NioZH_MPqfSwAF2elwNdMZZH24hWmkkf5GnZmx0bZLRjKQjF-dITj_EnIYP9Extu-HmFIOlDENhXuD4t1o89JA',\n", " 'width': 3214}],\n", " 'place_id': 'ChIJMckScdqe4jARnCUZdPKRjF8',\n", " 'plus_code': {'compound_code': 'PGRR+MC Bangkok, Thailand',\n", " 'global_code': '7P52PGRR+MC'},\n", " 'rating': 4.5,\n", " 'reference': 'ChIJMckScdqe4jARnCUZdPKRjF8',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 3963,\n", " 'vicinity': '153, 2 Thanon Ratchadamri, Khwaeng Lumphini, Pathum Wan'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7468712, 'lng': 100.52869},\n", " 'viewport': {'northeast': {'lat': 13.7481022302915,\n", " 'lng': 100.5300163302915},\n", " 'southwest': {'lat': 13.7454042697085, 'lng': 100.5273183697085}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'Lub d Bangkok Siam',\n", " 'opening_hours': {'open_now': False},\n", " 'photos': [{'height': 4000,\n", " 'html_attributions': ['Lub d Bangkok Siam'],\n", " 'photo_reference': 'AXCi2Q7qVqiYRLZVt_dOCtImxbBVKNRmBCSzQ2v--5_YEibb3-6bO79iKRmn_LlFv1AvQ1K2hl5j24-PQYHJD5KC48NeZ-lFx5yvpYlQ41WJqpHoNc2TFIC-NGH61WnCnofVXvKh4xG1v-1N1dGqXG0ote0-VaxF3VJB5EqX8c4ePn4GdozI',\n", " 'width': 6000}],\n", " 'place_id': 'ChIJc33lpDKZ4jARil4bO37UbIs',\n", " 'plus_code': {'compound_code': 'PGWH+PF Bangkok, Thailand',\n", " 'global_code': '7P52PGWH+PF'},\n", " 'rating': 4.3,\n", " 'reference': 'ChIJc33lpDKZ4jARil4bO37UbIs',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 938,\n", " 'vicinity': '925, 9 Rama I Road, Khwaeng Wang Mai, Pathum Wan'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7505658, 'lng': 100.5320207},\n", " 'viewport': {'northeast': {'lat': 13.75196523029151,\n", " 'lng': 100.5333065302915},\n", " 'southwest': {'lat': 13.7492672697085, 'lng': 100.5306085697085}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'VIE Hotel Bangkok - MGallery',\n", " 'photos': [{'height': 4016,\n", " 'html_attributions': ['VIE Hotel Bangkok - MGallery'],\n", " 'photo_reference': 'AXCi2Q7TveQ9nEBfcLD4-zSxR0YKeU9Dds7U8lV-Uq6Dqn_lE-cEGoRo4f8EU_W8AMOqKB3Sd2Q67lWjdRhwXG0EhZ1SCwJlzv6ScLyvCjB_p1fhFL3CZP8BiwFzBO6pwMKp3FDXGjxv4MxuJNuCf6Dhy1q9Evyn8L4jbGIM5drEAcX0Uo5E',\n", " 'width': 6016}],\n", " 'place_id': 'ChIJQwHqwrWe4jAR8yoMrZmtzaU',\n", " 'plus_code': {'compound_code': 'QG2J+6R Bangkok, Thailand',\n", " 'global_code': '7P52QG2J+6R'},\n", " 'rating': 4.5,\n", " 'reference': 'ChIJQwHqwrWe4jAR8yoMrZmtzaU',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 2352,\n", " 'vicinity': '117 39, 40 Phaya Thai Road'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7400527, 'lng': 100.5399569},\n", " 'viewport': {'northeast': {'lat': 13.74149933029151,\n", " 'lng': 100.5412330302915},\n", " 'southwest': {'lat': 13.7388013697085, 'lng': 100.5385350697085}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'The St. Regis Bangkok',\n", " 'photos': [{'height': 320,\n", " 'html_attributions': ['The St. Regis Bangkok'],\n", " 'photo_reference': 'AXCi2Q5MpeB0BkgSi1uUIdWT8oWziRVQEpZPeqwJw3RnzXL5wTAGgaAHsu8pfR1o1S9FvfSopFMe6HpmGOi7YCkazz5svGa4JhciyaT2T6eojpXkrKBYD_z1RLgn8bp7-TH4ewCyf8oWioRrKLfoPh3iNQGWi7QG3GrmLoCP_5cIIyfDCLaE',\n", " 'width': 480}],\n", " 'place_id': 'ChIJZ-0rstCe4jARS_6948lrmZU',\n", " 'plus_code': {'compound_code': 'PGRQ+2X Bangkok, Thailand',\n", " 'global_code': '7P52PGRQ+2X'},\n", " 'price_level': 3,\n", " 'rating': 4.6,\n", " 'reference': 'ChIJZ-0rstCe4jARS_6948lrmZU',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 3163,\n", " 'vicinity': '159 Thanon Ratchadamri, Khwaeng Lumphini, Pathum Wan'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7540569, 'lng': 100.5287023},\n", " 'viewport': {'northeast': {'lat': 13.7554363802915,\n", " 'lng': 100.5301208302915},\n", " 'southwest': {'lat': 13.7527384197085, 'lng': 100.5274228697085}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'Bangkok City Hotel',\n", " 'photos': [{'height': 4032,\n", " 'html_attributions': ['Aisyah Hassan'],\n", " 'photo_reference': 'AXCi2Q4sZM83sIM9mOC6Idg-_kdWyCGM1YUHs2DaEeVeKDj5lteFPpbTIFAA60Y90LUX3iu75-bhCiCzUNg5-c9jlQiQJ6aSH3KIJasgs0UUh6NZU0wf0ho07k-FUoj-DrnK5kHmfF_H1IU3HKTzJCZJ4hxEMIYXAGeyYdezcGHRwwtb5j-R',\n", " 'width': 3024}],\n", " 'place_id': 'ChIJuyczxTSZ4jAR2rnUC9KTw6o',\n", " 'plus_code': {'compound_code': 'QG3H+JF Bangkok, Thailand',\n", " 'global_code': '7P52QG3H+JF'},\n", " 'rating': 4,\n", " 'reference': 'ChIJuyczxTSZ4jAR2rnUC9KTw6o',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 2112,\n", " 'vicinity': '268 Phetchaburi Road, Khwaeng Thanon Phetchaburi, Khet Ratchathewi'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7455309, 'lng': 100.5198334},\n", " 'viewport': {'northeast': {'lat': 13.7469272802915,\n", " 'lng': 100.5214649302915},\n", " 'southwest': {'lat': 13.7442293197085, 'lng': 100.5187669697085}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'The Twin Towers Hotel',\n", " 'opening_hours': {'open_now': True},\n", " 'photos': [{'height': 1335,\n", " 'html_attributions': ['The Twin Towers Hotel'],\n", " 'photo_reference': 'AXCi2Q5zHHC0HBwk7iR-m5-0F2QtmYVNs16ziY8g9zRKH_ViPHjqvPvE-n5JvuJT-Kjnh3_YoghMyn-SoriXMXxPpNySIw3sP1TjZ5BI8lRC2OVN_b6h3HPUYba9CWzJXn_-320Oho3XGZ-yr54y1t7G4j84SpmWzbwItgY-XmbnlWO36J2m',\n", " 'width': 2000}],\n", " 'place_id': 'ChIJ_zP3fy-Z4jARWYaBArPXGAg',\n", " 'plus_code': {'compound_code': 'PGW9+6W Bangkok, Thailand',\n", " 'global_code': '7P52PGW9+6W'},\n", " 'rating': 4,\n", " 'reference': 'ChIJ_zP3fy-Z4jARWYaBArPXGAg',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 3326,\n", " 'vicinity': '88 ถ.พระราม 6 ตัดใหม่, Khwaeng Rong Muang, Pathum Wan'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7408604, 'lng': 100.5399556},\n", " 'viewport': {'northeast': {'lat': 13.74230515, 'lng': 100.5413903802915},\n", " 'southwest': {'lat': 13.73950815, 'lng': 100.5386924197085}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'Anantara Siam Bangkok Hotel',\n", " 'opening_hours': {'open_now': True},\n", " 'photos': [{'height': 1037,\n", " 'html_attributions': ['Anantara Siam Bangkok Hotel'],\n", " 'photo_reference': 'AXCi2Q6Rc9MGEhM1NGsPvYYoZ7dAi-hedtt97CrRjslZnsfwqbiEE0UkewPBEkVeY7l7QR4-WRlViax1KeVavFPnY7fa4TW6j0ccEY4fHqxifBSHlhDyA-rKK7uDoxsiUqSOfDJfMtxdUSN6jSRmArsILOdOxX6zz_50G5PAjuJA_nFbYocP',\n", " 'width': 1920}],\n", " 'place_id': 'ChIJVwz7GcWe4jARatGDB6rxqcE',\n", " 'plus_code': {'compound_code': 'PGRQ+8X Bangkok, Thailand',\n", " 'global_code': '7P52PGRQ+8X'},\n", " 'rating': 4.6,\n", " 'reference': 'ChIJVwz7GcWe4jARatGDB6rxqcE',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging',\n", " 'spa',\n", " 'restaurant',\n", " 'food',\n", " 'point_of_interest',\n", " 'establishment'],\n", " 'user_ratings_total': 5380,\n", " 'vicinity': '155 Rajadamri Road, Khwaeng Lumphini, Pathum Wan'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7468291, 'lng': 100.5313447},\n", " 'viewport': {'northeast': {'lat': 13.7480164802915,\n", " 'lng': 100.5327981302915},\n", " 'southwest': {'lat': 13.7453185197085, 'lng': 100.5301001697085}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/shopping-71.png',\n", " 'icon_background_color': '#4B96F3',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/shopping_pinlet',\n", " 'name': 'Siam Discovery',\n", " 'opening_hours': {'open_now': False},\n", " 'photos': [{'height': 2340,\n", " 'html_attributions': ['S. Ibrahim Nst.'],\n", " 'photo_reference': 'AXCi2Q5Nr0zE2yKY2Pkr89GsijyiE6eQyJ-A5-5AD7JGZhVrzp0_8QjBXaQjQFPCpnEZPL_9EK_fwCiIG6IBmlOjWAQqKcfL81Czkc3b1BDhi9rV-x7_SIuThzhLYsC6utnrTtIqJ6aepwquDJ05BtMjuhe8th8h2GJE8RKPGjjF0LrMtR-I',\n", " 'width': 4160}],\n", " 'place_id': 'ChIJgUSJZM2e4jAREnHS1rSuWRk',\n", " 'plus_code': {'compound_code': 'PGWJ+PG Bangkok, Thailand',\n", " 'global_code': '7P52PGWJ+PG'},\n", " 'rating': 4.4,\n", " 'reference': 'ChIJgUSJZM2e4jAREnHS1rSuWRk',\n", " 'scope': 'GOOGLE',\n", " 'types': ['shopping_mall', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 18880,\n", " 'vicinity': '194 Phaya Thai Road, Khwaeng Pathum Wan, Pathum Wan'},\n", " {'business_status': 'OPERATIONAL',\n", " 'geometry': {'location': {'lat': 13.7481275, 'lng': 100.5414289},\n", " 'viewport': {'northeast': {'lat': 13.7494722302915,\n", " 'lng': 100.5427770802915},\n", " 'southwest': {'lat': 13.7467742697085, 'lng': 100.5400791197085}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/lodging-71.png',\n", " 'icon_background_color': '#909CE1',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/hotel_pinlet',\n", " 'name': 'Aphrodite Inn Bangkok',\n", " 'opening_hours': {'open_now': True},\n", " 'photos': [{'height': 1280,\n", " 'html_attributions': ['Aphrodite Inn Bangkok'],\n", " 'photo_reference': 'AXCi2Q6EEQ1eZIsi5DslFbjDTEOZApqtYIjZv48JZwNnHCbKRK8cPFGbQod8Iavt8Vb6jt7UCAgUyjLOID96NsRtVMN77VFFmvmL5gR7FxV2Sq7jZfRQacYxeKKDh1gLikbVZ76Qe0r5rbxHP734MmhfpULIWTCXc8Z68JUz1yTBUCoy57wL',\n", " 'width': 1280}],\n", " 'place_id': 'ChIJJ-xLecWe4jARimHRYcEPNS8',\n", " 'plus_code': {'compound_code': 'PGXR+7H Bangkok, Thailand',\n", " 'global_code': '7P52PGXR+7H'},\n", " 'rating': 4.3,\n", " 'reference': 'ChIJJ-xLecWe4jARimHRYcEPNS8',\n", " 'scope': 'GOOGLE',\n", " 'types': ['lodging', 'point_of_interest', 'establishment'],\n", " 'user_ratings_total': 204,\n", " 'vicinity': '61-65 Thanon Ratchadamri, ลุมพินี, Pathum Wan'},\n", " {'geometry': {'location': {'lat': 13.746183, 'lng': 100.5307787},\n", " 'viewport': {'northeast': {'lat': 13.75307941101843,\n", " 'lng': 100.5529221455833},\n", " 'southwest': {'lat': 13.72275417223182, 'lng': 100.5156772173436}}},\n", " 'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/geocode-71.png',\n", " 'icon_background_color': '#7B9EB0',\n", " 'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/generic_pinlet',\n", " 'name': 'Pathum Wan',\n", " 'photos': [{'height': 1800,\n", " 'html_attributions': ['Nakorn Chong'],\n", " 'photo_reference': 'AXCi2Q6nWG-gVdJIY_3aZwHHeEunCwUQasXaWepe4x_Iy8OvLh53nKVv_RCoDR6QsnDvAqI94qcMrrcFS8ysjH_LktZ54BVkISzB7-qPUkQeW_OWsLDMFvbm59cAV8nKDhSRIhuP0e9X1cClvOdXpAowEPNUMnwVvnrao82p637ynK2OCmFS',\n", " 'width': 4000}],\n", " 'place_id': 'ChIJ9dY-MdSe4jAR8E3iXbIAAQM',\n", " 'reference': 'ChIJ9dY-MdSe4jAR8E3iXbIAAQM',\n", " 'scope': 'GOOGLE',\n", " 'types': ['sublocality_level_1', 'sublocality', 'political'],\n", " 'vicinity': 'Pathum Wan'}]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "def nearby_dense_community(location:str, radius:int=2000):\n", " # Retrieve the API key from environment variables\n", " api_key = os.getenv('GPLACES_API_KEY')\n", "\n", " if not api_key:\n", " raise ValueError(\"API key not found. Please set the GOOGLE_MAPS_API_KEY environment variable.\")\n", "\n", " # Define the endpoint URL\n", " url = \"https://maps.googleapis.com/maps/api/place/nearbysearch/json\"\n", "\n", " # Set up the parameters for the request\n", " params = {\n", " \"includedTypes\": [\"hotel\", \"mall\", \"school\", \"apartment\"],\n", " 'location': location,\n", " 'radius': radius,\n", " 'key': api_key,\n", " \"rankPreference\": \"DISTANCE\"\n", " }\n", "\n", " # Send the GET request to the Google Maps API\n", " response = requests.get(url, params=params)\n", "\n", " # Check if the request was successful\n", " if response.status_code != 200:\n", " raise Exception(f\"Error with request: {response.status_code}, {response.text}\")\n", "\n", " # Parse the JSON response\n", " data = response.json()\n", " results = data['results']\n", "\n", " # Return the response data\n", " return results\n", "\n", "\n", "location = \"13.744677,100.5295593\" # Latitude and Longitude\n", "search_results = nearby_dense_community(location)\n", "search_results" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.9" } }, "nbformat": 4, "nbformat_minor": 2 }