酷徒LOGO

airapi, 访问 Airbnb API的node.js 客户端库


  • 源代码名称:airapi
  • 源代码网址:http://www.github.com/phamtrisi/airapi
  • airapi源代码文档
  • airapi源代码下载
  • Git URL:
    git://www.github.com/phamtrisi/airapi.git
    Git Clone代码到本地:
    git clone http://www.github.com/phamtrisi/airapi
    Subversion代码到本地:
    $ svn co --depth empty http://www.github.com/phamtrisi/airapi
    Checked out revision 1.
    $ cd repo
    $ svn up trunk
    
    AirAPI

    AirAPI是一个方便的NodeJS封装器,用于airbnb端点的API。 这与Airbnb没有任何关联或认可。 Airbnb不提供其API的公共访问权限,因此使用风险由您自行承担。 我不对任何问题负责。

    ##安装

    
    npm install airapi --save
    
    
    
    

    ##使用API

    // Include the library in your appvar airbnb =require('airapi')();// Searchairbnb.search(options);// Get calendarairbnb.getCalendar(options);// Get hosting informationairbnb.getInfo(hostingId);// Get hosting estimate income, given availability, // which can be retrieved using `airbnb.getCalendar()` 上面airbnb.getEstIncome(hostingAvailability);// Get hosting reviewsairbnb.getReviews(userId, options);

    注意:所有这些API端点,除了返回一个 promise。

    ##示例###搜索

    Search instant-bookable hostings in Seattle, Wa from July 3rd - July 6th, 2015, for 2 people, 2nd result page.

    airbnb.search({
     location:'Seattle, WA',
     checkin:'07/03/2015',
     checkout:'07/06/2015',
     guests:2,
     page:2,
     ib:true}).then(function(searchResults) {
     console.log(searchResults);
    });

    可能的搜索选项。这可能会定期更改。 我尽量让它尽可能的保持原样

    
    {
    
    
     checkin: {String}, e.g: '04/30/2015'
    
    
     checkout: {String},
    
    
     guests: {Number},
    
    
     page: {Number},
    
    
     location: {String}, e.g: 'New York, NY' or 'Seattle, WA'
    
    
     price_min: {Number},
    
    
     price_max: {Number},
    
    
     min_bedrooms: {Number},
    
    
     min_bathrooms: {Number},
    
    
     min_beds: {Number},
    
    
     superhost: {Boolean},
    
    
     hosting_amenities: {Array of id}, e.g: [1,4]
    
    
     property_type_id: {Array of id}, e.g: [1]
    
    
     languages: {Array of id}, e.g: [1,64]
    
    
     keywords: {String}, e.g: 'ocean,view,balcony'
    
    
     room_types: {Array}, e.g: ['Entire home/apt', 'Private room', 'Shared room']
    
    
     ib: {Boolean}, instant-book
    
    
     neighborhoods: {Array}, e.g: ['Belltown', 'Queen Anne']
    
    
    }
    
    
    
    

    ###Hosting 日历

    Get may + June 2015 calendar for hosting ID : 4569115

    airbnb.getCalendar(4569115, {
     currency:'USD',
     month:5,
     year:2015,
     count:2}).then(function(schedules) {
     console.log(schedules);
    });

    ###Hosting 信息

    获取主机ID的一般信息: 4569115

    airbnb.getInfo(4569115).then(function(info) {
     console.log(info);
    });

    ###Hosting 估算收入

    估计主机标识的收入: 2015年1月2日4569115

    airbnb.getCalendar(4569115, {
     currency:'USD',
     month:1,
     year:2015,
     count:2}).then(function(schedules) {
     console.log(airbnb.getEstIncome(schedules));
    });

    ###Hosting 评论

    获取用户标识的评论: 4586440,作为主机

    airbnb.getReviews(4586440, {
     page:1,
     role:'host'}).then(function(reviews) {
     console.log(reviews);
    });

    获取用户标识的评论: 4586440,作为客人

    airbnb.getReviews(4586440, {
     page:1,
     role:'guest'}).then(function(reviews) {
     console.log(reviews);
    });
    运行示例
    git clone https://github.com/phamtrisi/airapi.git airapicd airapi && npm install && node example.js

    ##License MIT





    Copyright © 2011 HelpLib All rights reserved.    知识分享协议 京ICP备17041772号-2  |  如果智培  |  酷兔英语  |  帮酷