全球股票指数历史

查询国际股票指数,上证指数,深证成指,沪深300,创业板指,恒生指数等
接口编号: 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沪深3002005-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标普5002023-07-22至今2023-07-22至今
1114纳斯达克2020-01-07至今2021-01-05至今

调用方式

Get/Post

请求url

 HTTP: http://api.k780.com
HTTPS: https://sapi.k780.com

请求参数

参数 类型 是否必须 备注
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小时,请留意购买足够配额.

规格套餐名称价格描述
101200 次配额/每小时48 元/月-
102400 次配额/每小时87 元/月省¥ 9 享9.8折
103600 次配额/每小时130 元/月省¥ 14 享9.5折
1041000 次配额/每小时218 元/月省¥ 22 享9折
1052000 次配额/每小时439 元/月省¥ 41 享8.5折
1064000 次配额/每小时883 元/月省¥ 77 享8折
1076000 次配额/每小时1332 元/月省¥ 108 享7.5折
1088000 次配额/每小时1786 元/月省¥ 134 享7折
10910000 次配额/每小时2244 元/月省¥ 156 享6.5折
11020000 次配额/每小时4800 元/月-
立即开通

免费试用套餐说明:

商用请选择付费套餐。 (系统繁忙或极端情况下,优先保证付费用户使用).

规格套餐名称价格描述
0试用套餐 10 次/每小时0 元/月可免费试用3个月,延长试用或次数不够可联系客服增加
立即开通

客户服务

客服QQ: 1486133340 
QQ群8: 204490433

客服微信:

数据定制

定制接口、定制数据格式、采集等;联系请提供数据样式范本。1486133340 

意见反馈