贝壳 API - 二手房详情 (V1)
获取贝壳(链家)平台上特定二手房房源列表的详细信息。
数据内容包括:
- 价格信息(总价与单价)。
- 物理属性(面积、户型、楼层、朝向)。
- 房源元数据(标签、挂牌日期)。
- 经纪人联系方式。
典型应用场景:
- 向用户展示完整的房源详情页。
- 特定房源之间的详细价格对比。
请求参数
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
token | query | string | 是 | 用户鉴权令牌。 |
cityId | query | string | 是 | 城市ID(例如,北京为'110000')。 |
houseCode | query | string | 是 | 房源信息的唯一标识符。 |
代码示例
💡 环境说明
默认示例使用 https://api.justoneapi.com (prod-global)。中国大陆地区建议替换为 http://47.117.133.51:30015 (prod-cn) 以获得更好的访问体验。详见 环境选择。
bash
# 提示: 中国大陆地区建议将 https://api.justoneapi.com 替换为 http://47.117.133.51:30015
curl -X GET "https://api.justoneapi.com/api/beike/ershoufang/detail/v1?token=YOUR_API_KEY&cityId=VALUE&houseCode=VALUE"text
我想使用 Just One API 提供的“二手房详情 (V1)”接口。
接口地址: https://api.justoneapi.com/api/beike/ershoufang/detail/v1
HTTP 方法: GET
身份验证: 在 URL 后添加查询参数“?token=您的API密钥”。
OpenAPI 定义: https://docs.justoneapi.com/openapi/beike-apis/resale-housing-details-v1-zh.json
请求参数说明:
- token (query): 用户鉴权令牌。 (必填)
- cityId (query): 城市ID(例如,北京为'110000')。 (必填)
- houseCode (query): 房源信息的唯一标识符。 (必填)
返回格式: JSON
响应处理与错误码:
1. 需通过返回体中的 "code" 字段判断业务结果(code 为 0 表示成功)。
2. 超时建议:建议将请求超时时间设置为至少 60 秒。
3. 业务码说明:
- 0: 成功
- 100: Token 无效或已失效
- 301: 采集失败,请重试
- 302: 超出速率限制
- 303: 超出每日配额
- 400: 参数错误
- 500: 内部服务器错误
- 600: 权限不足
- 601: 余额不足
请帮我用我擅长的编程语言写一个脚本来调用这个接口,并处理返回结果。python
# 提示: 中国大陆地区建议将 https://api.justoneapi.com 替换为 http://47.117.133.51:30015
import requests
url = "https://api.justoneapi.com/api/beike/ershoufang/detail/v1?token=YOUR_API_KEY&cityId=VALUE&houseCode=VALUE"
response = requests.get(url)
print(response.json())js
// 提示: 中国大陆地区建议将 https://api.justoneapi.com 替换为 http://47.117.133.51:30015
const response = await fetch("https://api.justoneapi.com/api/beike/ershoufang/detail/v1?token=YOUR_API_KEY&cityId=VALUE&houseCode=VALUE", {
method: "GET"
});
const data = await response.json();
console.log(data);java
// 提示: 中国大陆地区建议将 https://api.justoneapi.com 替换为 http://47.117.133.51:30015
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.justoneapi.com/api/beike/ershoufang/detail/v1?token=YOUR_API_KEY&cityId=VALUE&houseCode=VALUE"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}go
// 提示: 中国大陆地区建议将 https://api.justoneapi.com 替换为 http://47.117.133.51:30015
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
client := &http.Client{}
url := "https://api.justoneapi.com/api/beike/ershoufang/detail/v1?token=YOUR_API_KEY&cityId=VALUE&houseCode=VALUE"
req, _ := http.NewRequest("GET", url, nil)
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}php
// 提示: 中国大陆地区建议将 https://api.justoneapi.com 替换为 http://47.117.133.51:30015
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.justoneapi.com/api/beike/ershoufang/detail/v1?token=YOUR_API_KEY&cityId=VALUE&houseCode=VALUE");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$response = curl_exec($ch);
curl_close($ch);
echo $response;响应结果
json
{
"code": 0,
"data": {
"miniProgram": {
"accessKey": "gh_2dbd87cb164c",
"path": "subpackages/ershoufang/pages/esfDetail/esfDetail?cityId=110000&houseCode=101127449675&share_user_id=0&share_device_union_id=&share_user_type=2&share_time=1773065058267&source=share_beikeapp&from=shell&share=true&share_entity_union_id=9bc3e7520cbecc195593a75de78a9ba4&share_id=33f06867fb5e7bdb3ccd8b6de115f13d"
},
"isVr": false,
"verificationInfo": {
"title": "房源维护人",
"agentUcid": "1000000010081720",
"agentName": "张忠良",
"digV": "{\"u\":1000000010081720,\"v\":\"V1\",\"s\":\"NATURAL\",\"adId\":100011429,\"flow\":\"natural\",\"b\":\"HouseHolderAgentBuilder\",\"p\":\"\",\"g\":\"\",\"sid\":\"1000000010081720_1111027379646\",\"rid\":\"8124032703957783648\"}",
"certificateInfo": [
{
"title": "房源发布人",
"icon": "http://ke-image.ljcdn.com/beike/1545043505977.png",
"list": [
{
"name": "从业人员工作牌",
"path": "https://img.ljcdn.com/ehr-personnel/202004111008285365UW0QVPQ.jpg"
},
{
"name": "全国房地产经纪人协理证",
"certCode": "30620191011100002734",
"path": "https://image1.ljcdn.com/ehr-personnel/20190108180804890B5IW0ZJU.png",
"jumpContent": "持有全国房地产经纪人协理职业资格证。\r\n由中国房地产估价师与房地产经纪人学会颁发人力资源社会保障部、住房城乡建设部监制,中国房地产估价师与房地产经纪人学会用印的相应级别《中华人民共和国房地产经纪专业人员职业资格证书》在全国范围有效。"
},
{
"name": "费率",
"path": "https://img.ljcdn.com/ehr-personnel/a810ff7a-e7f0-42fc-a508-96f51c6f94b0.jpg"
}
]
},
{
"title": "房源发布机构",
"icon": "http://ke-image.ljcdn.com/beike/1545043505977.png",
"list": [
{
"name": "营业执照",
"path": "https://img.ljcdn.com/ehr-personnel/20240813183721981NR3TQWSP.jpg",
"jumpContent": "企业信用信息查询网址:http://www.gsxt.gov.cn/index.html"
},
{
"name": "经纪备案",
"path": "https://img.ljcdn.com/ehr-personnel/20240507173107450KNIGTHDT.jpg"
}
]
}
]
},
"headPictures": [
{
"groupId": 2,
"groupName": "户型",
"imgObjectList": [
{
"groupId": 2,
"groupName": "户型",
"imgUrl": "http://ke-image.ljcdn.com/hdic-frame/standard_adc2f732-b0e3-4046-b580-06e34ccc1a75.png.1440x1080.jpg?from=ke.com"
}
]
}
],
"styleSet": {
"styleName": "normal",
"titleSize": 22,
"basicTitleColor": "FA5741",
"basicItemSize": 16,
"jumpItemColor": "3072F6",
"jumpItemSize": 16,
"sectionTitleSize": 20,
"navigateWordColor": "3072F6",
"stressColor": "FA5741"
},
"colorTags": [
{
"desc": "满五年",
"color": "849AAE",
"boldFont": 0
},
{
"desc": "随时可看",
"color": "849AAE",
"boldFont": 0
},
{
"desc": "房主自荐",
"color": "849AAE",
"boldFont": 0
}
],
"basicInfo": {
"isFocus": false,
"isOffSale": false,
"title": "双裕花园西区 1室1厅 63.4平米",
"cityId": "110000",
"houseCode": "101127449675",
"communityId": "1111027379646",
"communityName": "双裕花园西区",
"price": 2350000,
"unitPrice": 37067,
"floorState": "顶层/4层",
"blueprintHallNum": 1,
"blueprintBedroomNum": 1,
"area": 63.4,
"orientation": "南",
"mUrl": "https://m.ke.com/bj/ershoufang/101127449675.html",
"hasFramePoints": 0
},
"basicList": [
{
"name": "售价",
"value": "235万"
},
{
"name": "房型",
"value": "1室1厅"
},
{
"name": "建筑面积",
"value": "63.4㎡"
}
],
"infoList": [
{
"name": "单价:",
"value": "37067元/平"
},
{
"name": "挂牌:",
"value": "2024.11.05"
},
{
"name": "朝向:",
"value": "南"
},
{
"name": "楼层:",
"value": "顶层(共4层)"
},
{
"name": "楼型:",
"value": "板楼"
},
{
"name": "电梯:",
"value": "无"
},
{
"name": "装修:",
"value": "精装"
},
{
"name": "年代:",
"value": "2003年建成",
"alertText": "根据本栋部分房源产权证中《房屋登记表》上的测图日期统计生成,可能本栋不同房源之间存在差异,仅供参考。"
},
{
"name": "用途:",
"value": "普通住宅"
},
{
"name": "权属:",
"value": "商品房"
}
],
"infoJumpList": [
{
"id": "xiaoqurukou",
"name": "小区:",
"value": "双裕花园西区 (顺义区-后沙峪)",
"actionUrl": "lianjiabeike://community/detailv4?communityid=1111027379646"
},
{
"id": "gengduofangyuanxinxi",
"name": "其他:",
"value": "梯户比 供暖方式",
"actionUrl": "lianjiabeike://ershou/detail/info?houseCode=101127449675&strategyInfo=&shareAgentUcid="
},
{
"id": "goufangyusuan",
"sfTotal": 45,
"monthlySupply": 9500,
"name": "首付:",
"value": "净首付(不含税)45万,月供9500元",
"actionUrl": "https://tax.jiaoyi.ke.com/sf/detail?cityCode=110000&houseCode=101127449675&taxStatus=0&source=beike&ots=1773065058000&cjj=2350000&sk=fbf885bd36ea57987a7549dcc233e89d",
"color": "3072F6",
"clickName": "shoufurukou_succeed"
}
],
"userRelated": {
"isFollowed": 0,
"isFollowedPrice": 0,
"isAddCart": 0
},
"isDefault": false,
"hasFollowedPrice": 1,
"textFormatDownPrice": {
"itemKey": "textFormatDownPrice",
"textHead": "专属经纪人",
"textEnd": "电话讲解",
"color": "3072F6"
},
"declareInfo": {
"title": "风险提示",
"icon": "https://img.ljcdn.com/beike/api/1595215420267.png",
"actionUrl": "lianjiabeike://web/main?login=false&url=https%3A%2F%2Fm.ke.com%2Ftext%2Fdisclaimer"
},
"share": {
"showWeixin": true,
"showCircle": true,
"showAgent": true,
"showMsg": true
},
"vrAndLiveCard": [
{
"type": "live",
"url": "lianjiabeike://web/main?login=false&url=https%3A%2F%2Ffang-trade.ke.com%2FliveRoom%2FchannelV2%3FcityId%3D110000%26tagId%3DentityType2",
"statisticsText": "本市直播",
"title": "直播看房",
"subTitle": "随时随地 想看就看",
"buttonTitle": "立即观看",
"iconUrl": "https://img.ljcdn.com/beike/arsenal/1631786157239.gif",
"coverColor": "0DFE615A",
"strokeColor": "FE615A",
"buttonColor": "ED423B"
}
],
"hasLiveCard": true,
"isVrAndLiveCardBottom": 0,
"houseKeys": {
"title": "钥匙房源 随时看房",
"iconUrl": "http://ke-image.ljcdn.com/beike/1568101580073.png",
"actionUrl": "lianjiabeike://ershou/daikan?houseCode=101127449675&cityId=110000&requestFrom=0"
},
"nav": [
{
"name": "房源",
"key": "basicInfo"
}
]
}
}💡 提示:为简化展示,列表类数据样例仅保留 1-2 条记录,实际返回条数以接口响应为准。
