nderkach / airbnb-python

A Python wrapper around the Airbnb API (unofficial)
Do What The F*ck You Want To Public License
186 stars 66 forks source link

I can't get more than 300 listings. #15

Open malong204-dev opened 4 years ago

malong204-dev commented 4 years ago

When I search for listings using the get_homes() method, I can't get more than 300 listings. Even though there are more listings and I increase the page number, it doesn't return after 300th listing. Is there any way to get all listings?

AtelierCartographique commented 4 years ago

I actually have a similar problem but with only 50 listings. Has anyone found the reason why?

malong204-dev commented 4 years ago

50 is the maximum number for one page. to get more listings, you have to set items_offset parameter.

malong204-dev commented 4 years ago

But though I set items_offset to 300, it doesn't return 301th~350th listings.

AtelierCartographique commented 4 years ago

Even with "api.get_homes('toronto, ontario', items_per_grid = 50, offset = 51)", I can't seem to get more results...

seanpdwyer7 commented 4 years ago

@malong204-dev You will have to iterate through each page utilizing a for loop. I would suggest utilizing a function to help get all of the listing within a single market. i.e.

def get_listing(market_name, page)
              city=[]
              for i in range(page):
                   city.append(get_api_function_name(market_name, i)
                   print(i)
             df = pd.concat(city)
             return df
tcardim commented 3 years ago

So, I just ran with offset from 0 to 400 with increments of 50. Offsets 300, 350, and 400 all gave the same data. As explained in the readme, the maximum number of listings you can get for a particular city using get_homes() method is 306. I understood items_per_grid as items per page, but in reality the items per page is 50. You cannot get more listings than 306 no matter if you loop or adjust the offset.

Does anyone have a solution around this? My goal (as likely everyone else's) is to get all the listings for a particular city.

Thank you in advance if anyone has the answer and is kind enough to share!

klane commented 3 years ago

@tcardim My workaround was to run more localized queries using different neighborhoods within the city. If you look at the JSON output, you will find a couple neighborhood fields you can use to build up a set of distinct neighborhoods that the API might recognize (some produced no results for me). Using this strategy, I was able to find a few thousand unique listings. However, I was searching within a major US city and I cannot say if this will work elsewhere.