稳定、快速、免费的 API 接口服务
每10分钟自动更新黄金价格,包含国内黄金价格,纽约期货黄金价格,伦敦现货黄金价格
接口地址: https://58.linkpc.net/api/huangjin
返回格式: JSON
请求方式: GET
请求示例: https://58.linkpc.net/api/huangjin
请求参数说明:
名称 | 必填 | 类型 | 说明 |
---|
返回参数说明:
名称 | 类型 | 说明 |
---|
返回示例:
{
"code": 200,
"msg": "成功",
"data": {
"ShanghaiGoldExchange": {
"price": "779.50",
"change": "1.00",
"changePercentage": "-0.26%",
"highest": "786.00",
"lowest": "778.47",
"open": "781.69",
"previousSettlement": "781.57",
"updateTime": "15:30:04",
"date": "2025-04-30",
"market": "上海黄金交易所 人民币\/克"
},
"NewYorkCommodityExchange": {
"price": "3226.23",
"change": "-92.87",
"changePercentage": "-2.80%",
"highest": "3300.60",
"lowest": "3209.40",
"open": "3299.00",
"previousSettlement": "3319.10",
"updateTime": "23:09:18",
"date": "2025-05-01",
"market": "美国纽约商品交易所 美元\/盎司"
},
"LondonSpotGoldMarket": {
"price": "3220.14",
"change": "-67.98",
"changePercentage": "-2.07%",
"highest": "3290.05",
"lowest": "3201.92",
"open": "3288.14",
"previousSettlement": "3288.12",
"updateTime": "23:09:00",
"date": "2025-05-01",
"market": "英国伦敦黄金交易市场 美元\/盎司"
}
}
}
错误码格式说明:
名称 | 类型 | 说明 |
---|
代码示例:
<?php
header('Content-type: application/json; charset=utf-8');
date_default_timezone_set('PRC');
$url = 'https://58.linkpc.net/api/huangjin';
$type = isset($_GET['type']) ? $_GET['type'] : '';
if ($type == 'json' || $type == 'JSON') {
$result = file_get_contents($url . '?type=json');
echo htmlspecialchars($result);
} else {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
curl_close($ch);
if (strpos($contentType, 'image') !== false) {
header('Content-Type: ' . $contentType);
echo $response;
} elseif (strpos($contentType, 'text') !== false) {
header('Content-Type: ' . $contentType);
echo $response;
} elseif (strpos($contentType, 'application/json') !== false) {
header('Content-Type: application/json');
echo $response;
} else {
header('Content-Type: text/html');
echo $response;
}
}
?>