Skip to content

Instantly share code, notes, and snippets.

@joshreini1
Created August 30, 2022 19:36
Show Gist options
  • Save joshreini1/c8d84a0a5ceffa4dd6626b35f8e9dc10 to your computer and use it in GitHub Desktop.
Save joshreini1/c8d84a0a5ceffa4dd6626b35f8e9dc10 to your computer and use it in GitHub Desktop.
Get AirBnb Data
import requests
import pandas as pd
def get_airbnb_data(city):
#input city with + instead of spaces, e.g. "San+Francisco"
#note: open data soft caps requests at 10,000
url = "https://public.opendatasoft.com/api/records/1.0/search/?dataset=airbnb-listings&q=&rows=10000&refine.city=" + city
resp = requests.get(url)
print(resp.status_code)
data = resp.json()
abnb_df = pd.DataFrame([flatten_json(x,exclude='datasetid') for x in data['records']])
return abnb_df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment