## Breaking changes ahead!
Version 0.11.0, due to be released sometime after July 1st. Errors will no longer return null values. Instead, errors will be thrown.
# _Unofficial_ **airbnb.com** REST API wrapper for node.js
![](http://eloisecleans.com/blog/wp-content/uploads/2018/02/airbnb-logo-png-logo-black-transparent-airbnb-329-300x300.png)
![](https://cdn2.iconfinder.com/data/icons/nodejs-1/256/nodejs-256.png)
![](https://travis-ci.org/zxol/airbnbapi.svg?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/zxol/airbnbapi/badge.svg?branch=master)](https://coveralls.io/github/zxol/airbnbapi?branch=master)
---
Hi there! ð This is a javascript library for interacting with airbnb's API.
_Disclaimer: this library is not associated with airbnb and should only be used for educational reasons. It is an interface for a private API used by airbnb's mobile applications._
This is a pre 1.0 library. Please request endpoints and functionality as repo issues. Collaborators wanted!
# Essential Info
- All functions return [**promises**.](https://github.com/wbinnssmith/awesome-promises)
- The returned data format is pre-parsed JSON, i.e. a javascript object. Multiple records will be returned as an array.
- The auth system is a simple crypto token. For the uninitiated, this is like a username and password in one. If you're only using a single account, you can supply a token with `.setDefaultToken()`, otherwise, you will have to supply a token with every function call.
- Yeah, I know, airlock is a massive pain in the posterior.
- Error reporting and data validation is spotty at this stage!
- This library only has one dependency - request-promise.
# Getting started ð¨âð»
## Installing
```
npm install airbnbapijs
```
## Importing
```
var airbnb = require('airbnbapijs')
```
or es6...
```
import airbnb from 'airbnbapijs'
```
# Reference ð
## Contents
1. Authorization
1. Users
1. Calendars
1. Listings
1. Threads
1. Reservations
1. Posting
1. Configuration
---
## AUTHORIZATION
### testAuth
Test a token
```js
airbnb.testAuth('faketoken3sDdfvtF9if5398j0v5nui')
// returns bool
```
### newAccessToken
Request a new token
```js
airbnb.newAccessToken({ username: 'foo@bar.com', password: 'hunter2' })
// returns {token: 'faketoken3sDdfvtF9if5398j0v5nui'} or {error: {error obj}}
```
### login
Request a new token (v2 endpoint). Similar to the above function but returns a user info summary with much more information.
```js
airbnb.login({ username: 'foo@bar.com', password: 'hunter2' })
// returns a user info object (includes token) or {error: {error obj}}
```
### setDefaultToken
Set the token to use if a token is not supplied for an endpoint function.
```js
airbnb.setDefaultToken('faketoken3sDdfvtF9if5398j0v5nui')
```
TODO: support other login methods (facebook, twitter, etc...)
---
## USERS
### getGuestInfo
Get a user's public facing information
```js
airbnb.getGuestInfo(2348485493)
// returns public info about user (JSON)
```
### getOwnUserInfo
Obtain user data for the logged in account
```js
airbnb.getOwnUserInfo('faketoken3sDdfvtF9if5398j0v5nui')
// returns private info about user (JSON)
```
---
## CALENDARS
### getPublicListingCalendar
Public availability and price data on a listing. `count` is the duration in months.
```js
airbnb.getPublicListingCalendar({
id: 109834757,
month: 1,
year: 2018,
count: 1
})
// returns array of calendar days, with availability and price
```
### getCalendar
Private calendar data regarding your listings. Reservations, cancellations, prices, blocked days.
```js
airbnb.getCalendar({
token: 'faketoken3sDdfvtF9if5398j0v5nui',
id: 109834757,
startDate: '2018-01-01',
endDate: '2018-02-28'
})
// returns array of calendar days with extended info, for your listings
```
### setPriceForDay
Set a price for a day.
```js
airbnb.setPriceForDay({
token: 'faketoken3sDdfvtF9if5398j0v5nui',
id: 109834757,
date: '2018-01-01',
price: 1203
})
// returns a result of the operation
```
### setAvailabilityForDay
Set availability for a day.
```js
airbnb.setAvailabilityForDay({
token: 'faketoken3sDdfvtF9if5398j0v5nui',
id: 109834757,
date: '2018-01-01',
availability: 'available' // or 'blocked'?
})
// returns a result of the operation
```
---
## LISTINGS
### listingSearch
Airbnb's mighty search bar in JSON form. All arguments are optional.
```js
airbnb.listingSearch({
location: 'Akihabara, Tokyo',
checkin: '2020-01-21',
checkout: '2020-02-10',
offset: 0,
limit: 20,
language: 'en-US',
currency: 'USD',
guests: 6, // Number of guests for price quote
instantBook: true, // only list instant bookable listings.
minBathrooms: 0,
minBedrooms: 2,
minBeds: 6,
minPrice: 0,
maxPrice: 0,
superhost: true,
amenities: [1, 2, 4, 23], // array of IDs.
hostLanguages: [1, 3, 6], // array of IDs.
keywords: 'ocean view,garden,quiet', //comma separated
roomTypes: ['Entire home/apt', 'Private room', 'Shared room'],
neighborhoods: ['westside', 'riverside'],
minPicCount: 4,
sortDirection: 1 // 1 = forward, 0 = reverse
})
// returns an array of listings
```
### getListingInfo
Gets public facing data on any listing.
```js
airbnb.getListingInfo(109834757)
// returns public info for any listing (JSON)
```
### getListingInfoHost
Gets private data on one of your listings.
```js
airbnb.getListingInfoHost({
token: 'faketoken3sDdfvtF9if5398j0v5nui',
id: 109834757
})
// returns extended listing info for your listing (JSON)
```
### getHostSummary
Gets an object containing a host's active listings, alerts, and upcoming reservations
```js
airbnb.getHostSummary('faketoken3sDdfvtF9if5398j0v5nui')
// returns host summary info for your account (JSON)
```
### getOwnActiveListings
Gets an array containing a host's active listings
```js
airbnb.getOwnActiveListings('faketoken3sDdfvtF9if5398j0v5nui')
// returns listing array for your account (JSON)
```
---
### getOwnListings
Gets an array containing a host's listings
```js
airbnb.getOwnListings({
token: 'faketoken3sDdfvtF9if5398j0v5nui',
userId: '2344594'
})
// returns listing array for your account (JSON)
```
---
## THREADS
### getThread
Returns a conversation with a guest or host. This is a legacy endpoint which is somewhat limited in the content (only basic messages are reported in the 'posts' array)
```js
airbnb.getThread({
token: 'faketoken3sDdfvtF9if5398j0v5nui',
id: 909878797
})
// returns a single thread in the legacy format (JSON)
```
### getThreads
A simple list of thread ID's, ordered by latest update. The offset is how many to skip, and the limit is how many to report.
```js
airbnb.getThreads({
token: 'faketoken3sDdfvtF9if5398j0v5nui',
offset: 0,
limit: 20
})
// returns an array of thread IDS (only the ids, ordered by latest update) (JSON)
```
### getThreadsFull
This is the best way to pull thread data. Returns an array of full thread data, ordered by latest update. The `offset` is how many to skip, and the `limit` is how many to report.
```js
airbnb.getThreadsFull({
token: 'faketoken3sDdfvtF9if5398j0v5nui',
offset: 0,
limit: 10
})
// returns an array of threads in the new format, ordered by latest update (JSON)
```
### getThreadsBatch
A batch version of the above. You can grab a collection of threads referenced by thread ID.
```js
airbnb.getThreadsBatch({
token: 'faketoken3sDdfvtF9if5398j0v5nui',
ids: [23049848, 203495875, 398328244]
})
// returns an array of threads in the new format (JSON)
```
---
## RESERVATIONS
### getReservation
Reservation data for one reservation.
```js
airbnb.getReservation({
token: 'faketoken3sDdfvtF9if5398j0v5nui',
id: 909878797
})
// returns a single reservation in the mobile app format (JSON)
```
### getReservations
Returns a list of reservations in the same format as above, ordered by l
没有合适的资源?快使用搜索试试~ 我知道了~
用于 node.js 的非官方 airbnb.com REST API 包装器_JavaScript_代码_下载
共19个文件
js:9个
json:3个
yml:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 88 浏览量
2022-06-26
22:01:15
上传
评论
收藏 68KB ZIP 举报
温馨提示
基本信息 所有函数都返回promises。 返回的数据格式是预解析的 JSON,即一个 javascript 对象。多条记录将作为数组返回。 身份验证系统是一个简单的加密令牌。对于外行来说,这就像用户名和密码合二为一。如果您只使用一个帐户,您可以使用 提供一个令牌.setDefaultToken(),否则,您必须在每个函数调用中提供一个令牌。 是的,我知道,气闸在后部是一个巨大的痛苦。 在这个阶段,错误报告和数据验证参差不齐! 这个库只有一个依赖——request-promise。 更多详情、使用方法,请下载后阅读README.md文件
资源推荐
资源详情
资源评论
收起资源包目录
airbnbapi-master.zip (19个子文件)
airbnbapi-
.gitignore 1018B
README.md 11KB
test
main.js 27KB
dummydata.json 2KB
.prettierrc 107B
LICENSE 1KB
package.json 1KB
.coveralls.yml 46B
src
main.js 34KB
metapoints.js 588B
log.js 450B
config.js 621B
.babelrc 243B
build
main.js 36KB
metapoints.js 805B
log.js 540B
config.js 695B
.travis.yml 117B
package-lock.json 235KB
共 19 条
- 1
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9156
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功