Python实战:白银价格查询API获取实时行情
·
白银价格查询API覆盖了三大核心市场:

以上海黄金交易所为例,接口返回的数据包含:

实战演示:获取上海黄金交易所白银行情
下面通过 Python 代码,调用上海黄金交易所接口,获取当前白银行情。
import urllib3
import json
host = 'https://market.aliyun.com/detail/cmapi00065850'#接口地址
path = '/silver/shgold'
method = 'GET'
appcode = '你自己的AppCode' # 替换为真实 AppCode
url = host + path
http = urllib3.PoolManager()
headers = {
'Authorization': 'APPCODE ' + appcode
}
response = http.request('GET', url, headers=headers)
content = response.data.decode('utf-8')
data = json.loads(content)
print(json.dumps(data, indent=2, ensure_ascii=False))
返回结果示例
接口地址:https://market.aliyun.com/detail/cmapi00065850
{
"code": 1,
"msg": "操作成功",
"data": {
"list": [
{
"type": "Ag(T+D)",
"typename": "白银延期",
"price": "17800",
"openingprice": "0",
"maxprice": "0",
"minprice": "0",
"changepercent": "-0.31",
"lastclosingprice": "17800",
"tradeamount": "250724",
"updatetime": "2026-04-04 21:12:00"
},
{
"type": "Ag99.99",
"typename": "白银9999",
"price": "18000",
"openingprice": "0",
"maxprice": "0",
"minprice": "0",
"changepercent": "1.47",
"lastclosingprice": "18000",
"tradeamount": "30",
"updatetime": "2026-04-04 21:12:00"
}
]
}
}
应用场景

更多推荐



所有评论(0)