擷取旅宿的靜態資料
SDP (靜態資料平台) 提供各類不常變更的靜態資料,例如旅宿編號、名稱、描述、地址、設施等。
利用此平台的一種方式是將這些資料儲存在您本地的伺服器上,定期更新,並僅針對房況和價格等易變資料呼叫 Lodging API。這樣做可以減少實際的 API 呼叫次數,並提升應用程式的效能。
本頁面示範如何使用 SDP DownloadURL API 擷取可存取的旅宿 ID 清單,以及這些屬性的位置資訊。有關存取 SDP 所支援的其他靜態資料的詳細資訊,請參閱此處:。
從 SDP DownloadURL API 擷取可存取的 Expedia 旅宿 ID
GetFeedDownloadUrlOperationParams getPropertyIdListParams =
GetFeedDownloadUrlOperationParams.builder()
// Use the type LISTINGS to get the list of accessible property IDs.
.type(GetFeedDownloadUrlOperationParams.Type.LISTINGS)
// Without any filters, this operation will return the information of all lodging
// properties in en_US by default.
.build();
GetFeedDownloadUrlOperation getFeedDownloadUrlOperation =
new GetFeedDownloadUrlOperation(getPropertyIdListParams);
Response<PresignedUrlResponse> downloadUrlListingsResponse =
client.execute(getFeedDownloadUrlOperation);
// Get the download URL from the response.
String listingsDownloadUrl = downloadUrlListingsResponse.getData()
.getBestMatchedFile()
.getDownloadUrl();該下載網址指向一個 ZIP 檔案,其中包含多個 jsonl 檔案。Jsonl 檔案中的每一行都包含一個 JSON 物件,該物件代表一個旅宿。
以下是LISTINGS 檔案中的一行 JSON 範例 (其中propertyId.expedia 欄位即為 Expedia 的旅宿識別碼):
{
"propertyId": {
"expedia": "1234567",
"hcom": "123456789",
"vrbo": "123.1234567.7654321"
},
"bookable": {
"expedia": true,
"hcom": true,
"vrbo": true
},
"propertyType": {
"id": 16,
"name": "Apartment"
},
"lastUpdated": "10-27-2024 13:41:16",
"country": "France",
"inventorySource": "vrbo",
"referencePrice": {
"value": "89.52",
"currency": "USD"
},
"vrboPropertyType": {
"instantBook": true
}
}從LISTINGS 檔案中擷取的旅宿 ID,可用於呼叫住宿清單 API。您可以在旅宿的「ID 搜尋」功能中,查看如何取得房源內容、價格及空房狀況的範例。
然而,目前在「住宿列表」中,Vrbo 房源若為**(而非** instant-bookable),則可透過**(而非**)存取。
在 LISTINGS` ` 檔案中,您可以透過檢查 propertyId.vrbo 欄位是否為空來識別 Vrbo 房源,並根據 ``vrboPropertyType.instantBook 欄位進行篩選。
從 SDP DownloadURL API 擷取 Vrbo 旅宿的 ID
GetFeedDownloadUrlOperationParams getPropertyIdListParams =
GetFeedDownloadUrlOperationParams.builder()
// Use the type VACATION_RENTAL to get the list of accessible Vrbo property IDs.
.type(GetFeedDownloadUrlOperationParams.Type.VACATION_RENTAL)
// Without any filters, this operation will return the information of all Vrbo
// properties in en_US by default.
.build();
GetFeedDownloadUrlOperation getFeedDownloadUrlOperation =
new GetFeedDownloadUrlOperation(getPropertyIdListParams);
Response<PresignedUrlResponse> downloadUrlVacationRentalResponse =
client.execute(getFeedDownloadUrlOperation);
// Get the download URL from the response.
String vacationRentalDownloadUrl = downloadUrlListingsResponse.getData()
.getBestMatchedFile()
.getDownloadUrl();與LISTINGS 檔案類似,該下載網址指向一個包含 jsonl 檔案的 zip 檔案,其中每一行都包含一個 JSON 物件,代表一個 Vrbo 旅宿。
以下是VACATION_RENTAL 檔案中的一行 JSON 範例 (propertyId.expedia 欄位即為此 Vrbo 房源旅宿的 Expedia ID):
{
"propertyId": {
"expedia": "1234567",
"hcom": "987654321",
"vrbo": "123.1234567.7654321"
},
"country": "France",
"propertySize": {
"measurement": 441,
"units": "SQUARE_FEET"
},
"maxOccupancy": 4,
"bathrooms": {
"numberOfBathrooms": 1
},
"bedrooms": {
"numberOfBedrooms": 2
},
"houseRules": {
"partyOrEventRules": {
"partiesOrEventsPermitted": false,
"ownerPartyFreeText": "No events allowed"
},
"smokingRules": {
"smokingPermitted": false,
"ownerSmokingFreeText": "Smoking is not permitted"
},
"petRules": {
"petsPermitted": true,
"ownerPetsFreeText": "Pets allowed"
},
"childRules": {
"childrenPermitted": true,
"ownerChildrenFreeText": "Children allowed: ages 0-17 "
}
},
"propertyManager": {
"name": "Résidences Louis",
"hostType": "Professional"
},
"premierHost": true,
"propertyLiveDate": "2022-05-31"
}從VACATION_RENTAL 檔案中擷取的 Expedia 旅宿識別碼,可用於呼叫「住宿報價 API」或「住宿空房日曆 API」。您可以在的「住宿報價」 以及的「Vrbo 空房日曆」 中,查看查詢房源價格與空房狀況的範例。
擷取房產的名稱與位置資訊
GetFeedDownloadUrlOperationParams getPropertyLocationParams =
GetFeedDownloadUrlOperationParams.builder()
// Use the type LOCATIONS to get the names and address of accessible properties.
.type(GetFeedDownloadUrlOperationParams.Type.LOCATIONS)
// If you are looking for Vrbo properties specifically, you can also filter the properties by brand.
// .brand(GetFeedDownloadUrlOperationParams.Brand.VRBO)
.build();
GetFeedDownloadUrlOperation getFeedDownloadUrlOperation =
new GetFeedDownloadUrlOperation(getPropertyLocationParams);
Response<PresignedUrlResponse> downloadUrlLocationsResponse =
client.execute(getFeedDownloadUrlOperation);
// Get the download URL from the response.
String locationsDownloadUrl = downloadUrlLocationsResponse.getData()
.getBestMatchedFile()
.getDownloadUrl();該檔案的結構與其他 SDP 檔案類似。
以下是LOCATIONS 檔案中的一行 JSON 範例:
{
"propertyId": {
"expedia": "1234567",
"hcom": "987654321",
"vrbo": "123.1234567.1234567"
},
"propertyType": {
"id": 16,
"name": "Apartment"
},
"propertyName": "Property Name",
"address1": "",
"address2": "",
"city": "Newark",
"province": "Delaware",
"country": "United States",
"postalCode": "19711",
"geoLocation": {
"latitude": "10.999999",
"longitude": "-10.999999",
"obfuscated": false
},
"locationAttribute": {
"neighborhood": {
"id": "553248635976468695",
"name": "Westmoreland"
},
"city": {
"id": "8946",
"name": "Newark"
},
"region": {
"id": "6055689",
"name": "North Wilmington"
},
"airport": {
"id": "6028579",
"code": "ILG",
"name": "Wilmington, DE (ILG-New Castle)",
"distance": "13.17",
"unit": "km"
},
"distanceFromCityCenter": {
"distance": "1.24",
"unit": "km"
}
}
}此時,您可以將旅宿的名稱與位置資訊,與旅宿的 ID 結合,藉此建立您的本地快取。
靈活運用 SDP 可協助您減少對住宿 API 的即時呼叫次數,並節省成本。您也可以利用這些資料來建立自己的搜尋引擎或推薦系統。