金店参考价格「最新价格」接入点(2145-2)使用指南
# 金店参考价格「最新价格」接入点(2145-2)使用指南
> 接入点 2145-2(最新价格)· 免费 · 请求方式 POST/GET · 返回 JSON · 阅读时间约 3 分钟
## 核心要点
- 2145-2 接收品牌 _id,返回该品牌黄金/铂金参考价与报价日期。
- 必填参数 `id` 来自「支持金店」接入点(2145-1)返回的 _id。
- 价格每天 13:40 更新;ret_code -1 表示该 _id 未找到。
## Why:这跟我有什么关系
拿到品牌 _id 后,就用「最新价格」接入点取实时参考价。这是金店参考价格接口里真正产出金价的一步。
## What:前置条件与接口速览
**接入点信息**
| 项 | 值 |
|---|---|
| 接入点 | 最新价格(2145-2) |
| 地址 | `https://route.showapi.com/2145-2?appKey={your_appKey}` |
| 请求方式 | POST / GET |
| 必填参数 | `id`(String,来自 2145-1 的 _id) |
| 更新频率 | 每天 13:40 更新 |
| 返回 | goldPrice / platinumPrice / 日期 / brand / _id / remark |
## How:接入步骤
**调用示例**
```python
import requests
brand_id = "5da958ead3fb8b0eefc6a3d2" # 来自「支持金店」接入点返回的 _id
url = "https://route.showapi.com/2145-2"
resp = requests.post(
url,
params={"appKey": "YOUR_APPKEY"},
data={"id": brand_id},
headers={"content-type": "application/x-www-form-urlencoded"},
timeout=10,
)
body = resp.json()["showapi_res_body"]
if body["ret_code"] == 0:
print(body["brand"], "黄金", body["goldPrice"], "铂金", body["platinumPrice"], body["auLastDate"])
elif body["ret_code"] == -1:
print("未找到该品牌:", body.get("remark"))
```
```bash
curl -X POST "https://route.showapi.com/2145-2?appKey=YOUR_APPKEY" \
-H "content-type: application/x-www-form-urlencoded" \
-d "id=5da958ead3fb8b0eefc6a3d2"
```
```javascript
const brandId = "5da958ead3fb8b0eefc6a3d2";
const resp = await fetch("https://route.showapi.com/2145-2?appKey=YOUR_APPKEY", {
method: "POST",
headers: { "content-type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({ id: brandId }),
});
const body = (await resp.json()).showapi_res_body;
if (body.ret_code === 0) {
console.log(body.brand, "黄金", body.goldPrice, "铂金", body.platinumPrice, body.auLastDate);
} else if (body.ret_code === -1) {
console.log("未找到该品牌:", body.remark);
}
```
## 返回示例与解析
**返回示例**
```python
{
"showapi_res_error": "",
"showapi_fee_num": 1,
"showapi_res_code": 0,
"showapi_res_id": "67a5aaf5fb638c27e15696c2",
"showapi_res_body": {
"ret_code": 0,
"platinumPrice": 409,
"_id": "5da958ead3fb8b0eefc6a3d2",
"remark": "",
"auLastDate": "2025-02-07",
"showapi_fee_code": 0,
"ptLastDate": "2025-02-07",
"brand": "周大生",
"goldPrice": 869
}
}
```
字段:`goldPrice` 黄金参考价、`platinumPrice` 铂金参考价、`auLastDate`/`ptLastDate` 报价日期、`brand` 品牌名、`ret_code` 0 成功 / -1 未找到。
## 进阶 / 边界
- `id` 必填;传错或品牌已下架会返回 ret_code -1。
- 价格每天 13:40 更新,auLastDate 是报价日期而非请求日期。
- 返回字段完整说明见[返回字段与状态码全解](https://www.showapi.com/guides/gold-price-response-codes-2145)。
## FAQ
**Q:id 参数从哪里来?**
来自「支持金店」接入点(2145-1)返回的 _id,不能自己构造。
**Q:返回 -1 怎么排查?**
先回 2145-1 重新拉品牌清单,确认 _id 是否变化或该品牌是否仍在支持列表。
**Q:金价单位是元/克吗?**
文档示例 goldPrice=869、platinumPrice=409,按行业惯例为元/克,但最终以官方说明为准;本文档未显式标注单位,展示时建议注明「参考价」。
## 相关能力 / 下一步阅读
- [金店参考价格:支持金店接入点(2145-1)使用指南](https://www.showapi.com/guides/gold-price-brand-list-2145)
- [金店参考价格:两步调用工作流](https://www.showapi.com/guides/gold-price-two-step-2145)
- [金店参考价格:返回字段与状态码全解](https://www.showapi.com/guides/gold-price-response-codes-2145)
- **本系列共 12 篇**:查看[金店参考价格 · 官方指南总目录](https://www.showapi.com/guides/gold-price-guides-2145)