稳定、快速、免费的 API 接口服务
每10分钟自动更新黄金价格,包含国内黄金价格,纽约期货黄金价格,伦敦现货黄金价格
接口地址: https://58.linkpc.net/api/huangjin
返回格式: JSON
请求方式: GET
请求示例: https://58.linkpc.net/api/huangjin
请求参数说明:
名称 | 必填 | 类型 | 说明 |
---|
返回参数说明:
名称 | 类型 | 说明 |
---|
返回示例:
{
"code": 200,
"msg": "成功",
"data": {
"ShanghaiGoldExchange": {
"price": "783.60",
"change": "2.00",
"changePercentage": "-0.17%",
"highest": "785.57",
"lowest": "775.91",
"open": "784.60",
"previousSettlement": "784.93",
"updateTime": "02:30:00",
"date": "2025-04-26",
"market": "上海黄金交易所 人民币\/克"
},
"NewYorkCommodityExchange": {
"price": "3335.59",
"change": "-13.01",
"changePercentage": "-0.39%",
"highest": "3384.10",
"lowest": "3274.80",
"open": "3362.00",
"previousSettlement": "3348.60",
"updateTime": "04:59:58",
"date": "2025-04-26",
"market": "美国纽约商品交易所 美元\/盎司"
},
"LondonSpotGoldMarket": {
"price": "3316.26",
"change": "-32.24",
"changePercentage": "-0.96%",
"highest": "3370.58",
"lowest": "3265.06",
"open": "3351.09",
"previousSettlement": "3348.50",
"updateTime": "04:55:00",
"date": "2025-04-26",
"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;
}
}
?>