接口编号: 602 | 接口名称: 股票指数 | 连接应用: 1251个 |
应用编号: 120021 | 应用标识: finance.globalindex_history | 服务商: NowAPI |
说明
查询全球主要股票指数历史行情,分一天级和一分钟级两种数据类型(K线)。 数据更新说明 一天级(HT1D) 1. 沪深和香港股指每开市日每17点(北京时间)同步更新。 2. 美股指开市日每06点(北京时间)同步更新. 一分钟级(HT1M) 1. 沪深\香港\美股每30-60秒更新. 一天级示例(HT1D): https://sapi.k780.com/?app=finance.globalindex_history&inxId=1010&htType=HT1D&dateYmd=20210108&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json (示例中sign会不定期调整) 一分钟级示例(HT1M): https://sapi.k780.com/?app=finance.globalindex_history&inxId=1010&htType=HT1M&dateYmd=20210108&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json (示例中sign会不定期调整) 扣费扣量特别说明(扣量: 包月套餐扣可用配额次数,流量包套餐扣可用次数) 1. result.dtCount节点值为数据条数,每10条数据或不足10条扣量1次;例如:数据条数为9扣量1次,为11扣量2次。 股指编号列表
股指编号(inxId) | 股指 | 数据可用时段(一天级) | 数据可用时段(一分钟级) |
1010 | 上证指数 | 1990-12-19至今 | 2021-01-05至今 |
1011 | 深证成指 | 1991-04-03至今 | 2021-01-05至今 |
1012 | 沪深300 | 2005-01-04至今 | 2021-01-05至今 |
1013 | 创业板指 | 2010-06-01至今 | 2021-01-05至今 |
1014 | 中小板指 | 2006-01-24至今 | 2021-01-05至今 |
1015 | 恒生指数 | 2019-12-31至今 | 2021-01-05至今 |
1016 | 国企指数 | 2019-12-31至今 | 2021-01-05至今 |
1017 | 红筹指数 | 2019-12-31至今 | 2021-01-05至今 |
1111 | 道琼斯 | 2020-01-07至今 | 2021-01-05至今 |
1112 | 标普500 | 2023-07-22至今 | 2023-07-22至今 |
1114 | 纳斯达克 | 2020-01-07至今 | 2021-01-05至今 |
请求网址
HTTP: http://api.k780.com
HTTPS: https://sapi.k780.com
请求方式
Get/Post
请求Header
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
请求参数
参数 | 类型 | 是否必须 | 备注 |
---|---|---|---|
app | string | 是 | 固定值 finance.globalindex |
inxId | string | 是 | 指数编号 |
htType | string | 是 | 数据类型 HT1D: 历史1天级别 HT1M: 历史1分钟级别 |
dateYmd | date | 是 | 数据时间范围(年月日) 单天: 20201228 多天区段: 20201228-20201230 (需付费) 最多支持365天范围段 dtType=HT1M时与dataYmdhi参数二选一 |
dateYmdhi | date | 是 | dtType=HT1M扩展使用,数据时间范围(年月日时分) 单分钟: 202012280930 多天多分钟区段: 202012280930-202012301600 (需付费) 最多支持365天范围段 与dataYmd参数二选一 |
appkey | string | 是 | 使用API的唯一凭证 获取 |
sign | string | 是 | md5后的32位密文,登陆用. 获取 |
format | {json|xml} | 否 | 返回数据格式 |
Json请求示例
http://api.k780.com/?app=finance.globalindex_history&inxId=1010&htType=HT1D&dateYmd=20210108&appkey=APPKEY&sign=SIGN&format=json
Json返回示例
1. 成功 { success: "1", result: { dtQuery: "20201228-20201230", dtCount: "3", dtAppend: { inxId: "1010", inxNm: "上证指数" }, dtList: [{ dateYmd: "20201230",/*数据日期*/ openPrice: "3375.01",/*今日开盘价*/ closePrice: "3414.45",/*今日收盘价*/ yesyPrice: "3379.04",/*昨日收盘价*/ highPrice: "3414.45",/*今日最高价*/ lowPrice: "3374.42",/*今日最低价*/ changePrice: "35.41",/*涨跌额*/ changeMargin: "1.05",/*涨跌幅%*/ volume: "291023544",/*成交量*/ turnover: "377542352896"/*成交额 美股港股指无成交额*/ }, { dateYmd: "20201229", openPrice: "3399.29", closePrice: "3379.04", yesyPrice: "3397.29", highPrice: "3407.09", lowPrice: "3376.09", changePrice: "-18.25", changeMargin: "-0.54", volume: "311769185", turnover: "382102564864" }, { dateYmd: "20201228", openPrice: "3396.36", closePrice: "3397.29", yesyPrice: "3396.56", highPrice: "3412.52", lowPrice: "3383.65", changePrice: "0.73", changeMargin: "0.02", volume: "316181542", turnover: "398159970304" } ]} } ------------------------------------------------------------------ 2. 错误 { "success":"0", "msgid":"错误编号", "msg":"错误说明" }
示例代码
<?php header("Content-Type:text/html;charset=UTF-8"); function nowapiRequest($postData,&$errMsg=''){ $apiUrl = 'https://sapi.k780.com/'; $useContext = stream_context_create(array( 'http' => array( 'method' => 'POST', 'header' => 'Content-type:application/x-www-form-urlencoded', 'content' => http_build_query($postData) ) )); if(!$resData=file_get_contents($apiUrl,false,$useContext)){ $errMsg = 'ERR_CONNECT'; return false; } if(!$arrData=json_decode($resData,true)){ $errMsg = 'ERR_DECODE'; return false; } if($arrData['success']!=1){ $errMsg = $arrData['msgid'].' '.$arrData['msg']; return false; } return $arrData['result']; } $postData['app'] = 'finance.globalindex_history'; $postData['inxId'] = '1010'; $postData['htType'] = 'HT1D'; $postData['dateYmd'] = '20210108'; $postData['appkey'] = '10003';//替换成自己的appkey $postData['sign'] = 'b59bc3ef6191eb9f747dd4e83c99f2a4';//替换成自己的sign $postData['format'] = 'json'; $result = nowapiRequest($postData,$errMsg); print_r($errMsg); print_r($result);
#python import json,urllib from urllib import urlencode url = 'http://api.k780.com' params = { 'app' : 'finance.globalindex_history', 'inxId' : '1010', 'htType' : 'HT1D', 'dateYmd' : '20210108', 'appkey' : 'APPKEY', 'sign' : 'SIGN', 'format' : 'json', } params = urlencode(params) f = urllib.urlopen('%s?%s' % (url, params)) nowapi_call = f.read() #print content a_result = json.loads(nowapi_call) if a_result: if a_result['success'] != '0': print a_result['result']; else: print a_result['msgid']+' '+a_result['msg'] else: print 'Request nowapi fail.';
import java.net.*; import java.io.*; public class test{ public static void main(String args[]) throws Exception { URL u=new URL("http://api.k780.com/?app=finance.globalindex_history&inxId=1010&htType=HT1D&dateYmd=20210108&appkey=APPKEY&sign=SIGN&format=json"); InputStream in=u.openStream(); ByteArrayOutputStream out=new ByteArrayOutputStream(); try { byte buf[]=new byte[1024]; int read = 0; while ((read = in.read(buf)) > 0) { out.write(buf, 0, read); } } finally { if (in != null) { in.close(); } } byte b[]=out.toByteArray( ); System.out.println(new String(b,"utf-8")); } }
curl "http://api.k780.com/?app=finance.globalindex_history&inxId=1010&htType=HT1D&dateYmd=20210108&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json"
流量包套餐说明:
买多少用多少,多买有优惠,10元起买,适合大多数应用场景.
规格 | 套餐名称 | 价格 | 描述 |
---|---|---|---|
201 | 流量包 5000 次 | 10 元 | 约 0.00200 元/次 |
202 | 流量包 52500 次 | 100 元 | 约 0.00190 元/次 |
203 | 流量包 106000 次 | 200 元 | 约 0.00189 元/次 |
204 | 流量包 160500 次 | 300 元 | 约 0.00187 元/次 |
205 | 流量包 272500 次 | 500 元 | 约 0.00183 元/次 |
206 | 流量包 550000 次 | 1000 元 | 约 0.00182 元/次 |
207 | 流量包 1110000 次 | 2000 元 | 约 0.00180 元/次 |
208 | 流量包 1680000 次 | 3000 元 | 约 0.00179 元/次 |
209 | 流量包 2875000 次 | 5000 元 | 约 0.00174 元/次 |
210 | 流量包 6000000 次 | 10000 元 | 约 0.00167 元/次 |
包月套餐说明:
适合调用量比较平均的高频应用场景;有配额限制,超出配额会被暂停调用1小时,请留意购买足够配额.
规格 | 套餐名称 | 价格 | 描述 |
---|---|---|---|
101 | 200 次配额/每小时 | 48 元/月 | - |
102 | 400 次配额/每小时 | 87 元/月 | 省¥ 9 享9.8折 |
103 | 600 次配额/每小时 | 130 元/月 | 省¥ 14 享9.5折 |
104 | 1000 次配额/每小时 | 218 元/月 | 省¥ 22 享9折 |
105 | 2000 次配额/每小时 | 439 元/月 | 省¥ 41 享8.5折 |
106 | 4000 次配额/每小时 | 883 元/月 | 省¥ 77 享8折 |
107 | 6000 次配额/每小时 | 1332 元/月 | 省¥ 108 享7.5折 |
108 | 8000 次配额/每小时 | 1786 元/月 | 省¥ 134 享7折 |
109 | 10000 次配额/每小时 | 2244 元/月 | 省¥ 156 享6.5折 |
110 | 20000 次配额/每小时 | 4800 元/月 | - |
免费试用套餐说明:
商用请选择付费套餐。 (系统繁忙或极端情况下,优先保证付费用户使用).
规格 | 套餐名称 | 价格 | 描述 |
---|---|---|---|
0 | 试用套餐 10 次/每小时 | 0 元/月 | 可免费试用3个月,延长试用或次数不够可联系客服增加 |