沪深股市
聚合数据 官方文档
数据仅供参考,不作投资使用,每5分钟更新一次;不支持对外展示,只支持自用学习研究
基本说明:
接口地址:http://web.juhe.cn/finance/stock/hs
返回格式:json
请求方式:get/post
请求示例:http://web.juhe.cn/finance/stock/hs?key=1
请求参数说明:
名称 类型 必填 说明
key string 必填 聚合密钥 扫码关注公众号
返回参数说明:
名称 类型 说明
- - 见json
JSON返回示例:
{
	"resultcode": "200",
	"reason": "SUCCESSED!",
	"result": [{
		"data": {
			"gid": "sh601009",
			/*股票编号*/
			"increPer": "9.91",
			/*涨跌百分比*/
			"increase": "43.99",
			/*涨跌额*/
			"name": "南京银行",
			/*股票名称*/
			"todayStartPri": "8.26",
			/*今日开盘价*/
			"yestodEndPri": "8.26",
			/*昨日收盘价*/
			"nowPri": "8.37",
			/*当前价格*/
			"todayMax": "8.55",
			/*今日最高价*/
			"todayMin": "8.25",
			/*今日最低价*/
			"competitivePri": "8.37",
			/*竞买价*/
			"reservePri": "8.38",
			/*竞卖价*/
			"traNumber": "34501453",
			/*成交量*/
			"traAmount": "290889560",
			/*成交金额*/
			"buyOne": "10870",
			/*买一*/
			"buyOnePri": "8.37",
			/*买一报价*/
			"buyTwo": "177241",
			/*买二*/
			"buyTwoPri": "8.36",
			/*买二报价*/
			"buyThree": "92600",
			/*买三*/
			"buyThreePri": "8.35",
			/*买三报价*/
			"buyFour": "87200" /*买四*/
			"buyFourPri": "8.34",
			/*买四报价*/
			"buyFive": "113700",
			/*买五*/
			"buyFivePri": "8.42",
			/*买五报价*/
			"sellOne": "47556",
			/*卖一*/
			"sellOnePri": "8.38",
			/*卖一报价*/
			"sellTwo": "103057",
			/*卖二*/
			"sellTwoPri": "8.39",
			/*卖二报价*/
			"sellThree": "186689",
			/*卖三*/
			"sellThreePri": "8.40",
			/*卖三报价*/
			"sellFour": "49000",
			/*卖四*/
			"sellFourPri": "8.41",
			/*卖四报价*/
			"sellFive": "214535",
			/*卖五*/
			"sellFivePri": "15.21",
			/*卖五报价*/
			"date": "2012-12-11",
			/*日期*/
			"time": "15:03:06",
			/*时间*/
		},
		"dapandata": {
			"dot": "7.690",
			/*当前价格*/
			"name": "南京银行",
			"nowPic": "-0.070",
			/*涨量*/
			"rate": "-0.90",
			/*涨幅(%)*/
			"traAmount": "17265",
			/*成交额(万)*/
			"traNumber": "223355" /*成交量*/
		},
		"gopicture": {

			"minurl": "http://image.sinajs.cn/newchart/min/n/sh601009.gif",
			/*分时K线图*/
			"dayurl": "http://image.sinajs.cn/newchart/daily/n/sh601009.gif",
			/*日K线图*/
			"weekurl": "http://image.sinajs.cn/newchart/weekly/n/sh601009.gif",
			/*周K线图*/
			"monthurl": "http://image.sinajs.cn/newchart/monthly/n/sh601009.gif" 
		    /*月K线图*/
		}
	}]
}
服务级错误码参照
错误码 说明
10001 错误的请求KEY
10002 该KEY无请求权限
10003 KEY过期
10004 错误的OPENID
10005 应用未审核超时,请提交认证
10007 未知的请求源
10008 被禁止的IP
10009 被禁止的KEY
10011 当前IP请求超过限制
10012 请求超过次数限制
10013 测试KEY超过请求限制
10014 系统内部异常
10020 接口维护
10021 接口停用
完整教学代码示例
<?php
/**
 * Created by PhpStorm.
 * User: FZS
 * Time: 2023/11/10 14:26
 */
class freeApi
{
    private $apiUrl;

    public function __construct()
    {
        $this->apiUrl = 'http://web.juhe.cn/finance/stock/hs?key=1';
    }

    /**
     * 获取结果
     * @return array
     */
    public function getResult()
    {
        return file_get_contents($this->apiUrl);
    }
}
package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
)

const (
	APIURL   = "http://web.juhe.cn/finance/stock/hs?key=1"
)

func main() {
	queryUrl := fmt.Sprintf("%s",APIURL)
	resp, err := http.Get(queryUrl)
	if err != nil {
		log.Println(err)
		return
	}

	defer resp.Body.Close()

	body, err := ioutil.ReadAll(resp.Body)

	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(string(body))
}