Coder Social home page Coder Social logo

glennneiger / airbnb-python Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nderkach/airbnb-python

0.0 1.0 0.0 52 KB

A Python wrapper around the Airbnb API (unofficial)

License: Do What The F*ck You Want To Public License

Python 100.00%

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

Watchers

 avatar

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.