Giter VIP home page Giter VIP logo

airbnb-python's Introduction

airbnb-python

Airbnb Python API

Disclaimer

This is a unofficial python API wrapper for airbnb.com

Using this software might contradict airbnb.com terms of service

Requirements

  • requests

Usage:

pip install airbnb

Initialize API

import airbnb
api = airbnb.Api()

Now, you'd be able to access most of the API endpoints (which don't require authentication).

Use random client identification

import airbnb
api = airbnb.Api(randomize=True)

This will allow you to randomize device UDID, advertisement UUID and user agent.

Initialize API with your airbnb.com username and password:

You need to login to access certain endpoints requiring authentication:

api = airbnb.Api(login, password)

Once you logged in, please reuse your access token, to avoid getting your account locked

api = airbnb.Api(access_token=`<ACCESS_TOKEN_OBTAINED_ON_LOGIN>`)

Get your user profile

(requires auth)

api.get_profile()

Get listing availability

api.get_calendar(listing_id)

Optional parameters:

  • starting_month: first month of the calendar (can't be in the past)
  • starting_year: first year of the calendar (can't be in the past)
  • calendar_months: how many months ahead you want to get the calendar for

Example:

api.get_calendar(975964, starting_month=9, starting_year=2017, calendar_months=1)

Get listing reviews

api.get_reviews(listing_id)

Optional parameters:

  • offset: paging offset
  • limit: number of results per page

Example:

api.get_reviews(975964, offset=20, limit=20)

Get a list of available homes in a <City> with a query or at a given location

api.get_homes(`<City>`)
api.get_homes(gps_lat=`Latitude`, gps_lng=`Longitude`)

Optional parameters:

  • offset: paging offset
  • items_per_grid: amount of listings to fetch for a given offset
  • checkin: checkin date (e.g. 2019-04-20)
  • checkout: checkout date (e.g. 2019-04-20)

Example:

Get first 8 listings for Lisbon, Portugal

api.get_homes("Lisbon, Portugal")

Example:

Get first listings at a given location (by GPS coordinates)

api.get_homes(gps_lat=55.6123352, gps_lng=37.7117917)

Note: at the moment items_per_grid limit appears to be 306 listings

๐ŸŒฟ VerificationError (420)

This exception occurs when you send too many login requests (i.e. call Api() with your credentials). Once you are logged in with your credentials you can just use your access token (Api(access_token="<TOKEN>")) As a workaround, try to login manually though the website or mobile app and complete Airbnb's verification process. You can also try to use a VPN or a proxy.

Testing

The package has some doctests to test authentication process, to run the tests first export the following env variables:

export AIRBNB_LOGIN=`<YOUR_LOGIN>`
export AIRBNB_PASSWORD=`<YOUR_PASSWORD>`
export AIRBNB_ACCESS_TOKEN=`<ACCESS_TOKEN_OBTAINED_ON_LOGIN>`

Then, setup Python environment as follows:

pipenv shell
pipenv install --dev

Finally, run the doctests using nose:

nosetests --with-doctest

Build Status

airbnb-python's People

Contributors

jaksmid avatar johanek avatar meichthys avatar nderkach avatar soerenmartius avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

airbnb-python's Issues

possible to set other filters when searching? like date range, apartment type, etc

just trying out your unofficial API and got it to work pretty easily. It would be so much more useful if it was possible to programatically set all the filters that you can set via the UI. Is there a way to do this, or is this a difficult feature to add?

A built-in way of paginating and cycling through returned listings would be a most welcome addition as well!

Thanks for your contribution! Looking forward to future updates!

Set location and then get listings for that Latitude and Longitude

Hey!

Thanks for the really awesome package. I've a minor doubt regarding the usage, we want to set the location and then get listings for that particular location. As far as I understand, the package sends user_id to fetch the listings presently. Could you please suggest a way which I can get listings for any given set of Lat-Long, instead of sending user_id which will only get listings for the current location.

Thanks a ton!

Newbee Questions

Hello,

Sorry for the remedial questions here but I'm new to git hub and new to python. Can anyone give me direction on the following:

  1. Is there a way to get a more localized set of lists for a given location?

For example:
listings = api.get_homes("Long Beach, NY", offset=1000, items_per_grid=1000)

Gets me 100 locations but they are not all in the long beach area they are not geographically close to each other the listings. Is there away for me to give a coordinate and get the adjacently close listings? I tried to give the gps in api.get_homes but that doesn't seem to work too good.

  1. Even though I'm setting offset and item_per_grid to 1000 I can only seem to grab 100 listings. I'm assuming that is a limit put in by airbnb?

Thanks for your help if you have the time. Nothing pressing here just trying to learn python.

I can't get more than 300 listings.

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?

Would be great to adjust the parameters dictionary (ie set guest to 8)

If someone is using the API for comparing what an apartment that can take up to 8 people charges, this feature would allow them to search for a more specific population to make better conclusions on price/occupancy.

Particularly considering the API will only return 306 listings as a maximum, narrowing down the search would be super helpful.

A few other examples are number of bedrooms, bathrooms, amenities, etc. Love the API. If there was a way around the limit of 306 it would be absolutely perfect. I get it though, airbnb only shows 306 properties for a search so there's not much to do. However, if you add the filtering capability to filter further, by cycling through a few different filter options, one might be able to pull more than 306 for a particular location.

how can i transfer the output to csv?

This may seem like a rookie question (because i'm a beginner)
but I used:
api.get_homes("Lebanon")
and I got a messy code output (I think it's json, not sure) Tried converting to dataframe but it didn't work.
how can I turn it into a clean csv?

I would really appreciate your help in this.

Pull reviews from Airbnb experiences instead of accommodations

I'm trying to scrape Airbnb reviews. But not of the accommodations, but my intention is to scratch the reviews of the experiences section.

We can see how the accommodations and experiences differ in the link:

Accommodation: https://www.airbnb.mx/rooms/18298916

Experience: https://www.airbnb.mx/experiences/181572

I use this command: api.get_reviews(18298916, offset=20, limit=20) This command is perfect for accommodations, but when I add the ID of an experience it doesn't return anything.

I guess the reason this GitHub code is designed for hosting, rather than experiences. I think modifying it is easy, but I can't find it in the GitHub code where the hosting links are referenced.

Can you help me? Thank you!

Broken?

I canโ€™t get this to work anymore. Anyone still use it successfully?

Package not found in pip

I'd like to try the api but pip wont install them. I cloned the repo but it would be nice to have the package installed by pip

KeyError: 'listings'

I'm looping through requests to listings and I get a keyerror below:
KeyError: 'listings'

Has anyone encountered this error and found a work around to it?

Added wishlist support

I added functions for getting wishlists (saved lists) and their listings:

    @require_auth
    def get_wishlist(self, wishlist_id):
        """
        Get a wishlist's primary information
        """
        r = self._session.get(API_URL + "/wishlists/" + wishlist_id)
        r.raise_for_status()

        return r.json()

    @require_auth
    def get_wishlist_listings(self, wishlist_id, offset=0, limit=100):
        """
        Get a wishlist's listings
        """
        params = {
            'wishlist_id':str(wishlist_id),
            '_format': 'for_collaborator',
            '_offset': str(offset),
            '_limit': str(limit)
        }

        r = self._session.get(API_URL + "/wishlisted_listings", params=params)
        r.raise_for_status()

        return r.json()

Feel free to add/merge if desired. Just posting here to help in case others want it.

Thanks for a great library! Helped me plan a fantastic escape for my girl and I.

feature request: get payout for each guest on the calendar

Now that they have stopped taking care of payouts to my cohost (quite some months ago now), I have to do some manual calculations periodically (once a month or so) to give him his commission plus the cleaning fee. I keep a log to keep track of which guests I've paid him for. So I'd like to script this.

Do we know how to get the payout amount from the API?

Number of guests

Hello. First of all... very nice work! It is something I was searching and you made it :)
Now the question... is there a way I can have, from the api.get_calendar, the number of guests that have reserved my room? I see that the calendar rerturns me some info about if a certain date is available or not but not about the number of guests that are coming.
Thanks very much for your help/support!

Gianluca

VerificationError

Hey,

I can not login with the api and my e-mail + pw.
I get this error: "raise VerificationError"

Is it still working for you?
Airbnb recently uses more and more verification processes, could this be the problem?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.