# Airbnb scraper in Python
## Overview
This project is an open-source tool developed in Python for extracting product information from Airbnb. It's designed to be easy to use, making it an ideal solution for developers looking for Airbnb product data.
## Features
- Extract prices, available dates, reviews, host details and others
- Full search support
- Extracts detailed product information from Airbnb
- Implemented in Python just because it's popular
- Easy to integrate with existing Python projects
## Legacy
- This was a project first implemented on:[https://github.com/johnbalvin/pybnb](https://github.com/johnbalvin/pybnb) but was moved to [https://github.com/johnbalvin/pyairbnb](https://github.com/johnbalvin/pyairbnb)
to match the name with pip name
## Important
- With the new airbnb changes, if you want to get the price from a room url you need to specify the date range
the date range should be on the format year-month-day, if you leave the date range empty, you will get the details but not the price
### Install
```bash
$ pip install pyairbnb
```
## Examples
### Example for Searching Listings
```python
import pyairbnb
import json
# Define search parameters
currency = "MXN" # Currency for the search
check_in = "2025-02-01" # Check-in date
check_out = "2025-02-04" # Check-out date
ne_lat = -1.03866277790021 # North-East latitude
ne_long = -77.53091734683608 # North-East longitude
sw_lat = -1.1225978433925647 # South-West latitude
sw_long = -77.59713412765507 # South-West longitude
zoom_value = 2 # Zoom level for the map
# Search listings within specified coordinates and date range
search_results = pyairbnb.search_all(check_in, check_out, ne_lat, ne_long, sw_lat, sw_long, zoom_value, currency, "")
# Save the search results as a JSON file
with open('search_results.json', 'w', encoding='utf-8') as f:
f.write(json.dumps(search_results)) # Convert results to JSON and write to file
```
### Retrieving Details for Listings
#### Retrieve Prices, Availability, Reviews, and Host Information
```python
import pyairbnb
import json
room_url="https://www.airbnb.com/rooms/30931885"
data = pyairbnb.get_reviews(room_url,"")
with open('reviews.json', 'w', encoding='utf-8') as f:
f.write(json.dumps(data["reviews"]))
```
### Getting listings from user id
```Python
import pyairbnb
import json
host_id = 0
api_key = pyairbnb.get_api_key("")
listings = pyairbnb.get_listings_from_user(host_id,api_key,"")
with open('listings.json', 'w', encoding='utf-8') as f:
f.write(json.dumps(listings))
```
### Getting experiences by just taking the first autocompletions that you would normally do manually on the website
```Python
import pyairbnb
import json
check_in = "2025-04-10"
check_out = "2025-04-12"
currency = "EUR"
user_input_text = "Estados Unidos"
locale = "es"
proxy_url = "" # Proxy URL (if needed)
api_key = pyairbnb.get_api_key("")
experiences = pyairbnb.experience_search(user_input_text, currency, locale, check_in, check_out, api_key, proxy_url)
with open('experiences.json', 'w', encoding='utf-8') as f:
f.write(json.dumps(experiences))
```
### Getting experiences by first getting the autocompletions
```Python
import pyairbnb
import json
check_in = "2025-03-06"
check_out = "2025-03-10"
currency = "USD"
user_input_text = "cuenca"
locale = "pt"
proxy_url = "" # Proxy URL (if needed)
api_key = pyairbnb.get_api_key("")
markets_data = pyairbnb.get_markets(currency,locale,api_key,proxy_url)
markets = pyairbnb.get_nested_value(markets_data,"user_markets", [])
if len(markets)==0:
raise Exception("markets are empty")
config_token = pyairbnb.get_nested_value(markets[0],"satori_parameters", "")
country_code = pyairbnb.get_nested_value(markets[0],"country_code", "")
if config_token=="" or country_code=="":
raise Exception("config_token or country_code are empty")
place_ids_results = pyairbnb.get_places_ids(country_code, user_input_text, currency, locale, config_token, api_key, proxy_url)
if len(place_ids_results)==0:
raise Exception("empty places ids")
place_id = pyairbnb.get_nested_value(place_ids_results[0],"location.google_place_id", "")
location_name = pyairbnb.get_nested_value(place_ids_results[0],"location.location_name", "")
if place_id=="" or location_name=="":
raise Exception("place_id or location_name are empty")
[result,cursor] = pyairbnb.experience_search_by_place_id("", place_id, location_name, currency, locale, check_in, check_out, api_key, proxy_url)
while cursor!="":
[result_tmp,cursor] = pyairbnb.experience_search_by_place_id(cursor, place_id, location_name, currency, locale, check_in, check_out, api_key, proxy_url)
if len(result_tmp)==0:
break
result = result + result_tmp
with open('experiences.json', 'w', encoding='utf-8') as f:
f.write(json.dumps(result))
```
### Getting available/unavailable homes along with metadata
```Python
import pyairbnb
import json
# Define listing URL and parameters
room_url = "https://www.airbnb.com/rooms/1029961446117217643" # Listing URL
currency = "USD" # Currency for the listing details
# Retrieve listing details without including the price information (no check-in/check-out dates)
data = pyairbnb.get_details(room_url=room_url, currency=currency)
# Save the retrieved details to a JSON file
with open('details_data.json', 'w', encoding='utf-8') as f:
f.write(json.dumps(data)) # Convert the data to JSON and save it
```
#### Retrieve Details Using Room ID with Proxy
You can also use `get_details` with a room ID and an optional proxy.
```python
import pyairbnb
from urllib.parse import urlparse
import json
# Define listing parameters
room_id = 18039593 # Listing room ID
currency = "MXN" # Currency for the listing details
proxy_url = "" # Proxy URL (if needed)
# Retrieve listing details by room ID with a proxy
data = pyairbnb.get_details(room_id=room_id, currency=currency, proxy_url=proxy_url)
# Save the retrieved details to a JSON file
with open('details_data.json', 'w', encoding='utf-8') as f:
f.write(json.dumps(data)) # Convert the data to JSON and save it
```
### Retrieve Reviews for a Listing
Use `get_reviews` to extract reviews and metadata for a specific listing.
```python
import pyairbnb
import json
# Define listing URL and proxy URL
room_url = "https://www.airbnb.com/rooms/30931885" # Listing URL
proxy_url = "" # Proxy URL (if needed)
# Retrieve reviews for the specified listing
reviews_data = pyairbnb.get_reviews(room_url, proxy_url)
# Save the reviews data to a JSON file
with open('reviews.json', 'w', encoding='utf-8') as f:
f.write(json.dumps(reviews_data["reviews"])) # Extract reviews and save them to a file
```
### Retrieve Availability for a Listing
The `get_calendar` function provides availability information for specified listings.
```python
import pyairbnb
import json
# Define listing parameters
room_id = "44590727" # Listing room ID
proxy_url = "" # Proxy URL (if needed)
# Retrieve availability for the specified listing
calendar_data = pyairbnb.get_calendar(room_id, "", proxy_url)
# Save the calendar data (availability) to a JSON file
with open('calendar.json', 'w', encoding='utf-8') as f:
f.write(json.dumps(calendar_data["calendar"])) # Extract calendar data and save it to a file
```
Raw data
{
"_id": null,
"home_page": "https://github.com/johnbalvin/pyairbnb",
"name": "pyairbnb",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "airbnb, scraper, crawler, bot, reviews",
"author": "John (John Balvin)",
"author_email": "John Balvin <johnchristian@hotmail.es>",
"download_url": "https://files.pythonhosted.org/packages/4a/79/7d93522314f05ba6d62f09ccc41b8faa7cb95030cc6aff954dbcb6bc8611/pyairbnb-0.0.5.tar.gz",
"platform": null,
"description": "# Airbnb scraper in Python\r\n\r\n## Overview\r\nThis project is an open-source tool developed in Python for extracting product information from Airbnb. It's designed to be easy to use, making it an ideal solution for developers looking for Airbnb product data.\r\n\r\n## Features\r\n- Extract prices, available dates, reviews, host details and others\r\n- Full search support\r\n- Extracts detailed product information from Airbnb\r\n- Implemented in Python just because it's popular\r\n- Easy to integrate with existing Python projects\r\n\r\n## Legacy\r\n- This was a project first implemented on:[https://github.com/johnbalvin/pybnb](https://github.com/johnbalvin/pybnb) but was moved to [https://github.com/johnbalvin/pyairbnb](https://github.com/johnbalvin/pyairbnb)\r\nto match the name with pip name\r\n\r\n## Important\r\n- With the new airbnb changes, if you want to get the price from a room url you need to specify the date range\r\nthe date range should be on the format year-month-day, if you leave the date range empty, you will get the details but not the price\r\n\r\n\r\n### Install\r\n\r\n```bash\r\n$ pip install pyairbnb\r\n```\r\n## Examples\r\n\r\n### Example for Searching Listings\r\n\r\n```python\r\nimport pyairbnb\r\nimport json\r\n\r\n# Define search parameters\r\ncurrency = \"MXN\" # Currency for the search\r\ncheck_in = \"2025-02-01\" # Check-in date\r\ncheck_out = \"2025-02-04\" # Check-out date\r\nne_lat = -1.03866277790021 # North-East latitude\r\nne_long = -77.53091734683608 # North-East longitude\r\nsw_lat = -1.1225978433925647 # South-West latitude\r\nsw_long = -77.59713412765507 # South-West longitude\r\nzoom_value = 2 # Zoom level for the map\r\n\r\n# Search listings within specified coordinates and date range\r\nsearch_results = pyairbnb.search_all(check_in, check_out, ne_lat, ne_long, sw_lat, sw_long, zoom_value, currency, \"\")\r\n\r\n# Save the search results as a JSON file\r\nwith open('search_results.json', 'w', encoding='utf-8') as f:\r\n f.write(json.dumps(search_results)) # Convert results to JSON and write to file\r\n```\r\n\r\n### Retrieving Details for Listings\r\n#### Retrieve Prices, Availability, Reviews, and Host Information\r\n\r\n```python\r\nimport pyairbnb\r\nimport json\r\nroom_url=\"https://www.airbnb.com/rooms/30931885\"\r\ndata = pyairbnb.get_reviews(room_url,\"\")\r\nwith open('reviews.json', 'w', encoding='utf-8') as f:\r\n f.write(json.dumps(data[\"reviews\"]))\r\n```\r\n\r\n### Getting listings from user id\r\n```Python\r\nimport pyairbnb\r\nimport json\r\nhost_id = 0\r\napi_key = pyairbnb.get_api_key(\"\")\r\nlistings = pyairbnb.get_listings_from_user(host_id,api_key,\"\")\r\nwith open('listings.json', 'w', encoding='utf-8') as f:\r\n f.write(json.dumps(listings))\r\n```\r\n\r\n### Getting experiences by just taking the first autocompletions that you would normally do manually on the website\r\n```Python\r\nimport pyairbnb\r\nimport json\r\ncheck_in = \"2025-04-10\"\r\ncheck_out = \"2025-04-12\"\r\ncurrency = \"EUR\"\r\nuser_input_text = \"Estados Unidos\"\r\nlocale = \"es\"\r\nproxy_url = \"\" # Proxy URL (if needed)\r\napi_key = pyairbnb.get_api_key(\"\")\r\nexperiences = pyairbnb.experience_search(user_input_text, currency, locale, check_in, check_out, api_key, proxy_url)\r\nwith open('experiences.json', 'w', encoding='utf-8') as f:\r\n f.write(json.dumps(experiences))\r\n```\r\n\r\n### Getting experiences by first getting the autocompletions\r\n```Python\r\nimport pyairbnb\r\nimport json\r\ncheck_in = \"2025-03-06\"\r\ncheck_out = \"2025-03-10\"\r\ncurrency = \"USD\"\r\nuser_input_text = \"cuenca\"\r\nlocale = \"pt\"\r\nproxy_url = \"\" # Proxy URL (if needed)\r\napi_key = pyairbnb.get_api_key(\"\")\r\nmarkets_data = pyairbnb.get_markets(currency,locale,api_key,proxy_url)\r\nmarkets = pyairbnb.get_nested_value(markets_data,\"user_markets\", [])\r\nif len(markets)==0:\r\n raise Exception(\"markets are empty\")\r\nconfig_token = pyairbnb.get_nested_value(markets[0],\"satori_parameters\", \"\")\r\ncountry_code = pyairbnb.get_nested_value(markets[0],\"country_code\", \"\")\r\nif config_token==\"\" or country_code==\"\":\r\n raise Exception(\"config_token or country_code are empty\")\r\nplace_ids_results = pyairbnb.get_places_ids(country_code, user_input_text, currency, locale, config_token, api_key, proxy_url)\r\nif len(place_ids_results)==0:\r\n raise Exception(\"empty places ids\")\r\nplace_id = pyairbnb.get_nested_value(place_ids_results[0],\"location.google_place_id\", \"\")\r\nlocation_name = pyairbnb.get_nested_value(place_ids_results[0],\"location.location_name\", \"\")\r\nif place_id==\"\" or location_name==\"\":\r\n raise Exception(\"place_id or location_name are empty\")\r\n[result,cursor] = pyairbnb.experience_search_by_place_id(\"\", place_id, location_name, currency, locale, check_in, check_out, api_key, proxy_url)\r\nwhile cursor!=\"\":\r\n [result_tmp,cursor] = pyairbnb.experience_search_by_place_id(cursor, place_id, location_name, currency, locale, check_in, check_out, api_key, proxy_url)\r\n if len(result_tmp)==0:\r\n break\r\n result = result + result_tmp\r\nwith open('experiences.json', 'w', encoding='utf-8') as f:\r\n f.write(json.dumps(result))\r\n```\r\n\r\n### Getting available/unavailable homes along with metadata\r\n```Python\r\nimport pyairbnb\r\nimport json\r\n\r\n# Define listing URL and parameters\r\nroom_url = \"https://www.airbnb.com/rooms/1029961446117217643\" # Listing URL\r\ncurrency = \"USD\" # Currency for the listing details\r\n\r\n# Retrieve listing details without including the price information (no check-in/check-out dates)\r\ndata = pyairbnb.get_details(room_url=room_url, currency=currency)\r\n\r\n# Save the retrieved details to a JSON file\r\nwith open('details_data.json', 'w', encoding='utf-8') as f:\r\n f.write(json.dumps(data)) # Convert the data to JSON and save it\r\n```\r\n\r\n#### Retrieve Details Using Room ID with Proxy\r\nYou can also use `get_details` with a room ID and an optional proxy.\r\n\r\n```python\r\nimport pyairbnb\r\nfrom urllib.parse import urlparse\r\nimport json\r\n\r\n# Define listing parameters\r\nroom_id = 18039593 # Listing room ID\r\ncurrency = \"MXN\" # Currency for the listing details\r\nproxy_url = \"\" # Proxy URL (if needed)\r\n\r\n# Retrieve listing details by room ID with a proxy\r\ndata = pyairbnb.get_details(room_id=room_id, currency=currency, proxy_url=proxy_url)\r\n\r\n# Save the retrieved details to a JSON file\r\nwith open('details_data.json', 'w', encoding='utf-8') as f:\r\n f.write(json.dumps(data)) # Convert the data to JSON and save it\r\n```\r\n\r\n### Retrieve Reviews for a Listing\r\nUse `get_reviews` to extract reviews and metadata for a specific listing.\r\n\r\n```python\r\nimport pyairbnb\r\nimport json\r\n\r\n# Define listing URL and proxy URL\r\nroom_url = \"https://www.airbnb.com/rooms/30931885\" # Listing URL\r\nproxy_url = \"\" # Proxy URL (if needed)\r\n\r\n# Retrieve reviews for the specified listing\r\nreviews_data = pyairbnb.get_reviews(room_url, proxy_url)\r\n\r\n# Save the reviews data to a JSON file\r\nwith open('reviews.json', 'w', encoding='utf-8') as f:\r\n f.write(json.dumps(reviews_data[\"reviews\"])) # Extract reviews and save them to a file\r\n```\r\n\r\n### Retrieve Availability for a Listing\r\nThe `get_calendar` function provides availability information for specified listings.\r\n\r\n```python\r\nimport pyairbnb\r\nimport json\r\n\r\n# Define listing parameters\r\nroom_id = \"44590727\" # Listing room ID\r\nproxy_url = \"\" # Proxy URL (if needed)\r\n\r\n# Retrieve availability for the specified listing\r\ncalendar_data = pyairbnb.get_calendar(room_id, \"\", proxy_url)\r\n\r\n# Save the calendar data (availability) to a JSON file\r\nwith open('calendar.json', 'w', encoding='utf-8') as f:\r\n f.write(json.dumps(calendar_data[\"calendar\"])) # Extract calendar data and save it to a file\r\n```\r\n",
"bugtrack_url": null,
"license": null,
"summary": "Airbnb scraper in Python",
"version": "0.0.5",
"project_urls": {
"Homepage": "https://github.com/johnbalvin/pyairbnb"
},
"split_keywords": [
"airbnb",
" scraper",
" crawler",
" bot",
" reviews"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7a1df0d1ddd0ed2e5e4dcc1e7e757a0a98dc299fb9dc28b19b130b12b551ee06",
"md5": "c64b85cb8461e574ef76f6a307575840",
"sha256": "4daec2bf7eee28c78f0b0ba1a87ecd5444c3656c029eaab705dabad908c7ca8c"
},
"downloads": -1,
"filename": "pyairbnb-0.0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c64b85cb8461e574ef76f6a307575840",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 22390,
"upload_time": "2025-01-19T04:18:12",
"upload_time_iso_8601": "2025-01-19T04:18:12.765369Z",
"url": "https://files.pythonhosted.org/packages/7a/1d/f0d1ddd0ed2e5e4dcc1e7e757a0a98dc299fb9dc28b19b130b12b551ee06/pyairbnb-0.0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4a797d93522314f05ba6d62f09ccc41b8faa7cb95030cc6aff954dbcb6bc8611",
"md5": "333b74c2d79646bcd14cfe9291e53481",
"sha256": "87b61c0ef6565e36aeba0915547009fa8691904bdcd305b287bb7cedf5999454"
},
"downloads": -1,
"filename": "pyairbnb-0.0.5.tar.gz",
"has_sig": false,
"md5_digest": "333b74c2d79646bcd14cfe9291e53481",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 17457,
"upload_time": "2025-01-19T04:18:14",
"upload_time_iso_8601": "2025-01-19T04:18:14.523632Z",
"url": "https://files.pythonhosted.org/packages/4a/79/7d93522314f05ba6d62f09ccc41b8faa7cb95030cc6aff954dbcb6bc8611/pyairbnb-0.0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-19 04:18:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "johnbalvin",
"github_project": "pyairbnb",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pyairbnb"
}