携程酒店价格实时采集接口API
近期调研发现iDataRiver平台 https://idatariver.com 上有供应商上架了开箱即用的携程酒店API,可以按需调用。本人简单测试了一下效果还可以,故记录下来以备日后使用。
接口使用详情请参考携程API文档
https://idatariver.com/zh-cn/project/7713
接口介绍
1. 获取携程酒店指定日期的客房列表
| 参数 | 类型 | 是否必填 | 默认值 | 示例值 | 描述 |
|---|---|---|---|---|---|
| apikey | string | 是 | idr_*** | 从控制台里复制apikey | |
| hotel_id | string | 是 | 16983307 | 酒店id | |
| check_in | string | 是 | 2024-06-05 | 入住日期 | |
| check_out | string | 是 | 2024-06-06 | 离店日期 |
python代码使用requests库请求示例
import requests
# 构建请求URL
# Build request URL
url = "https://apiok.us/api/7713/hotel/rooms/v1"
# 将apikey替换为自己的
# Replace apikey with yours
params = {
'apikey': 'idr_***',
'hotel_id': '16983307',
'check_in': '2024-06-05',
'check_out': '2024-06-06',
}
response = requests.get(url, params=params, timeout=60)
data = response.json()
# 打印返回结果
# print response
print(f"Your response is: {data}")