黄金价格查询 API 接入文档gold
实时黄金价格聚合查询,一次返回三大维度的金价数据: • 国际黄金报价(4 项):国际金价、国际铂金、国际银价、国际钯金,含最新价 / 涨跌额 / 涨跌幅 / 最高价 / 最低价 / 报价时间 • 国内黄金报价(7 项):国内金价、国内银价、投资金条、黄金回收价格、铂金回收价格、18K 金回收价格、钯金回收价格 • 十大品牌金店金价(17 家):内地周大福、周生生、六福珠宝、老凤祥、老庙黄金、中国黄金、周六福、菜百、明牌珠宝、潮宏基等十大品牌的当日黄金 / 铂金 / 金条价格(元/克) 通过参数 type 可只取某一类(all=全部,brand=品牌金店,international=国际,domestic=国内)。 基于 huangjinjiage.cn 数据源,已修复源码 GBK 编码乱码 bug,内建 10 分钟缓存。
1. 基本信息
| 接口地址 | https://v1.apizero.cn/api/gold |
|---|---|
| 请求方法 | GET |
| 分类 | finance |
| 提供方 | 极数本源 |
| 计费模式 | 免费试用 |
| 单次消耗 | 0 积分 |
| 起步价 | — |
| QPS 限制 | 5 req/s |
| 每日免费额度 | 200 次(已认证用户) |
| 匿名每日额度 | 50 次(无 API Key) |
| VIP 免费 | 否 |
| 调用次数 |
2. 认证
匿名每日 50 次、QPS 2;登录用户每日 200 次、QPS 5(全部免费)。已内建 10 分钟缓存。
获取 API Key:登录 https://apizero.cn/account/keys
3. 请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
type | string | 否 | 返回类型:all=全部(默认)/ brand=品牌金店 / international=国际黄金 / domestic=国内黄金 | all |
4. 请求头
| Header | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
Authorization | string | 否 | API Key 鉴权头,格式 Bearer sk_live_xxx;匿名调用时可省略(每日 50 次免费) | Bearer sk_live_xxxxxxxxxxxxxx |
5. 请求示例
以下 5 种语言示例都是可直接运行的,只需把 YOUR_API_KEY 替换为实际 Key。
cURL
curl "https://v1.apizero.cn/api/gold?type=all&key=YOUR_API_KEY"Python
import requests
resp = requests.get(
"https://v1.apizero.cn/api/gold",
params={
"type": "all",
"key": "YOUR_API_KEY",
},
timeout=15,
)
resp.raise_for_status()
print(resp.json())JavaScript (Node.js)
// Node.js 18+ / 浏览器原生 fetch
const params = new URLSearchParams({
"type": "all",
"key": "YOUR_API_KEY",
});
const res = await fetch(`https://v1.apizero.cn/api/gold?${params}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.json();
console.log(data);Go
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
req, _ := http.NewRequest("GET", "https://v1.apizero.cn/api/gold", nil)
q := req.URL.Query()
q.Set("type", "all")
q.Set("key", "YOUR_API_KEY")
req.URL.RawQuery = q.Encode()
resp, err := http.DefaultClient.Do(req)
if err != nil { panic(err) }
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}PHP
<?php
$url = "https://v1.apizero.cn/api/gold?" . http_build_query([
"type" => "all",
"key" => "YOUR_API_KEY",
]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$body = curl_exec($ch);
curl_close($ch);
$data = json_decode($body, true);
print_r($data);6. 响应字段
| 字段 | 类型 | 说明 | 示例 |
|---|---|---|---|
update_time | string | 本次缓存更新时间(YYYY-MM-DD HH:mm:ss) | — |
source | string | 数据源标识:huangjinjiage.cn | — |
type | string | 返回类型,回传请求中的 type 值 | — |
international | array | 国际黄金价格列表(4 项) | — |
international[].name | string | 品种名(国际金价/国际铂金/国际银价/国际钯金) | — |
international[].price | string | 最新价 | — |
international[].change | string | 涨跌额 | — |
international[].percent | string | 涨跌幅(含 %) | — |
international[].high | string | 日内最高价 | — |
international[].low | string | 日内最低价 | — |
international[].time | string | 报价时间 | — |
domestic | array | 国内黄金价格列表(7 项),结构同 international[] | — |
brand | array | 十大品牌金店列表(17 家) | — |
brand[].brand | string | 品牌名称(如 内地周大福) | — |
brand[].gold_price | string | 黄金价格(元/克) | — |
brand[].pt_price | string | 铂金价格(元/克),无数据时为 - | — |
brand[].bar_price | string | 金条价格(元/克) | — |
brand[].unit | string | 价格单位,固定 元/克 | — |
brand[].time | string | 报价时间 | — |
7. 响应示例
{
"code": 0,
"msg": "成功",
"data": {
"update_time": "2026-05-06 15:30:00",
"source": "huangjinjiage.cn",
"type": "all",
"international": [
{
"name": "国际金价",
"price": "4647.3",
"change": "7.19",
"percent": "0.39%",
"high": "1828.34",
"low": "1815.50",
"time": "2026-5-6"
},
{
"name": "国际银价",
"price": "75.28",
"change": "0.21",
"percent": "0.91%",
"high": "23.24",
"low": "22.78",
"time": "2026-5-6"
}
],
"domestic": [
{
"name": "国内金价",
"price": "1022.9",
"change": "2.08",
"percent": "0.56%",
"high": "375",
"low": "372.76",
"time": "2026-5-6"
}
],
"brand": [
{
"brand": "内地周大福",
"gold_price": "1413",
"pt_price": "-",
"bar_price": "1239",
"unit": "元\/克",
"time": "2026-5-6"
}
]
},
"request_id": "abc123def456"
}8. 错误码
| code | status | 说明 |
|---|---|---|
4000 | — | 参数错误:type 非法(仅支持 all/brand/international/domestic) |
4015 | — | 匿名调用每日额度用完,需要 API Key |
4029 | — | QPS 超限 |
4030 | — | 今日额度用完 |
5020 | — | 上游服务不可用 / HTTP 拉取失败 |
5021 | — | 上游 HTML 解析失败(页面结构可能已改版) |
9. 变更日志
- 1.0.0(2026-05-06)
- 首次上线,聚合国际黄金/国内黄金/十大品牌金店三类金价数据
- 修复源码 GBK 编码 bug(源码用 <?xml encoding="utf-8" ?> 强制 UTF-8 解析 GBK 内容会导致中文乱码)
- 缓存改用 Redis(10 分钟),不再依赖文件系统
- 解析失败容错(三个表都空时返回 5021 而非空 200)
- 支持 type 参数按需返回单类数据(节省带宽)
常见问题
黄金价格查询 接口怎么免费使用?
未登录用户每个 IP 每天 50 次免费。登录用户创建 API Key 后每天 200 次免费,超额部分按点数计费(0 点/次)。
黄金价格查询 支持哪些调用方式?
接口使用 GET 请求。文档提供 cURL、Python、JavaScript (Node.js)、Go、PHP 五种语言的可运行示例。也可以下载 /openapi.json 导入 Postman / Insomnia / Apifox 反向生成 SDK。
调用不限额么? QPS 是多少?
本接口 QPS 限制 5 req/s,每个 API Key 每日免费 200 次。需要更高额度可升级 VIP 套餐或联系售后提高 QPS。
这个接口跟自己直连上游有什么区别?
极数本源 作为中间层提供:统一鉴权(一个 Key 调所有接口)、统一计费(点数制)、统一限流、统一错误码、多上游自动切换。免去逐个对接上游、维护 Key、统计调用量的运维成本。