Skip to main content

Airbnb scraper in Python

Project description

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

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

$ pip install pyairbnb

Examples

Example for Searching Listings

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

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 price

import pyairbnb
import json
room_url="https://www.airbnb.com/rooms/30931885"
check_in = "2025-04-10"
check_out = "2025-04-12"
proxy_url = ""  # Proxy URL (if needed)
data, price_input, cookies = pyairbnb.get_metadata_from_url(room_url, proxy_url)
product_id = price_input["product_id"]
api_key = price_input["api_key"]
currency = "USD"
data = pyairbnb.get_price(product_id, price_input["impression_id"], api_key, currency, cookies,
            check_in, check_out, proxy_url)

with open('price.json', 'w', encoding='utf-8') as f:
    f.write(json.dumps(data))

Getting listings from user id

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

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

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

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.

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.

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.

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyairbnb-0.0.9.tar.gz (17.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyairbnb-0.0.9-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

Details for the file pyairbnb-0.0.9.tar.gz.

File metadata

  • Download URL: pyairbnb-0.0.9.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for pyairbnb-0.0.9.tar.gz
Algorithm Hash digest
SHA256 b7b52d50526cab7a716fbe00be1e2b539105ef3010c3aae3243e065ff1f77a74
MD5 2dd98e20f434d38ff60742a0c8eab837
BLAKE2b-256 8257a52e47286dac30bbd9cd6f3ec7bc7cad0a1bf90b92573917b1fbedb77c9a

See more details on using hashes here.

File details

Details for the file pyairbnb-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: pyairbnb-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 22.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for pyairbnb-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 8dcfd1fb36d4f8dce0b1afcab0207878c90f2b7c0c7e70565a38e8ba6b65de0f
MD5 97d6f3d31bca309686a24e4b506e08f3
BLAKE2b-256 510db1a632a8bda186f32d56fbfbcfeca8c64734c8e1c69e8c7f3ce9d530dbee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page