
| 接口编号: 603 | 接口名称: 股票数据 | 连接应用: 1204个 |
| 应用编号: 120030 | 应用标识: finance.stock_realtime | 服务商: NowAPI |
说明
实时股市行情查询接口,含沪深股市、香港股市、美国股市 扣费扣量特别说明(扣量: 包月套餐扣可用配额次数,流量包套餐扣可用次数) 1. 响应result.totline节点值为数据条数,每10或不足10条扣1次量。例如:条数1或10扣1次量,条数11扣2次量。 数据更新及延迟说明: 沪深北小于10秒更新,无延迟。 港股小于10秒更新,无延迟。 美股小于12秒更新,依照惯例国内延迟15分钟 。 测试示例: https://sapi.k780.com/?app=finance.stock_realtime&stoSym=sh600000,sh60000&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json (示例中sign会不定期调整)
请求网址
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.stock_realtime |
| stoSym | string | 是 | 股票代码,多个逗号隔开,单次查询最多5000个,查看支持股票代码列表
说明: 1.单次查询10个或不足10个品种扣1次量。(例:单次查1个或10个扣1次量,查11个扣2次量) 2.单次查询超500个建议POST方式。 |
| appkey | string | 是 | 使用API的唯一凭证 获取 |
| sign | string | 是 | md5后的32位密文,登陆用. 获取 |
| format | {json|xml} | 否 | 返回数据格式 |
| jsoncallback | string | 否 | js跨域使用jsonp时可使用此参数 |
Json请求示例
http://api.k780.com/?app=finance.stock_realtime&stoSym=sh600000&appkey=APPKEY&sign=SIGN&format=json
Json返回示例
1. 沪深股市
{
success: "1",
result: {
totline: "1",
disline: "1",
page: "1",
lists: {
sh600000: {
stoid: "1", /*自定义编号*/
symbol: "sh600000", /*股票代号*/
scode: "600000", /*股票编号*/
sname: "浦发银行", /*股票名称*/
sname_eng: "", /*股票名称英文*/
open_price: "16.390", /*开盘价*/
yesy_price: "16.400", /*昨收价*/
last_price: "16.430", /*当前价*/
high_price: "16.450", /*最高价*/
low_price: "16.380", /*最低价*/
rise_fall: "0.030", /*涨跌额*/
rise_fall_per: "0.18", /*涨跌幅*/
volume: "21269924", /*成交量*/
turn_volume: "349039232.000", /*成交量额*/
buy1_n: "6300", /*买1*/
buy1_m: "16.420", /*买1报价*/
buy2_n: "6980", /*买2*/
buy2_m: "16.410", /*买2报价*/
buy3_n: "343800", /*买3*/
buy3_m: "16.400", /*买3报价*/
buy4_n: "473321", /*买4*/
buy4_m: "16.390", /*买4报价*/
buy5_n: "292400", /*买5*/
buy5_m: "16.380", /*买5报价*/
sell1_n: "254", /*卖1*/
sell1_m: "16.430", /*卖1报价*/
sell2_n: "223459", /*卖2*/
sell2_m: "16.440", /*卖2报价*/
sell3_n: "368981", /*卖3*/
sell3_m: "16.450", /*卖3报价*/
sell4_n: "226339", /*卖4*/
sell4_m: "16.460", /*卖4报价*/
sell5_n: "237610", /*卖5*/
sell5_m: "16.470", /*卖5报价*/
uptime: "2016-11-07 14:58:50" /*更新时间*/
}
}
}
}
备注: 涨停价/跌停价计算方式,涨停=昨日收盘价+(昨日收盘价*0.1) 跌停=昨日收盘价-(昨日收盘价*0.1)
------------------------------------------------------------------
2.香港股市
{
success: "1",
result: {
totline: "1",
disline: "1",
page: "1",
lists: {
hk00001: {
stoid: "2906", /*自定义编号*/
symbol: "hk00001", /*股票代码*/
scode: "00001", /*股票代号*/
sname: "长和", /*股票名称*/
sname_eng: "CHEUNG KONG", /*股票名称英文*/
open_price: "95.250", /*开盘价*/
yesy_price: "95.500", /*昨收价*/
last_price: "96.000", /*当前价*/
high_price: "96.250", /*最高价*/
low_price: "94.800", /*最低价*/
rise_fall: "0.500", /*涨跌额*/
rise_fall_per: "0.52", /*涨跌幅*/
volume: "2341664", /*成交量*/
turn_volume: "224225024.000", /*成交额*/
peratio: "11.713", /*市盈率*/
week52_high: "105.400", /*52周最高*/
week52_low: "80.600", /*52周最低*/
uptime: "2016-11-07 15:36:00" /*更新时间*/
}
}
}
}
------------------------------------------------------------------
3.美国股市
{
success: "1",
result: {
totline: "1",
disline: "1",
page: "1",
lists: {
gb_aapl: {
stoid: "4803",/*自定义编号*/
symbol: "gb_aapl", /*股票代码*/
scode: "AAPL", /*股票代号*/
sname: "苹果公司", /*股票名称*/
sname_eng: "Apple Inc.", /*股票名称英文*/
open_price: "108.530", /*开盘价*/
yesy_price: "109.830", /*昨收价*/
last_price: "108.840", /*当前价*/
high_price: "110.250", /*最高价*/
low_price: "108.110", /*最低价*/
rise_fall: "-0.990", /*涨跌额*/
rise_fall_per: "-0.90", /*涨跌幅*/
volume: "29939342", /*成交量*/
turn_volume: "0.000", /*成交额 美股暂无法提供提交额*/
peratio: "13.100", /*市盈率*/
week52_high: "121.810", /*52周最高*/
week52_low: "89.470", /*52周最低*/
day10_volume: "34542335", /*10日均量*/
mvalue: "2147483647", /*市值*/
ep_share: "8.310", /*每股收益*/
beta_coefficient: "13.100", /*贝塔系数*/
dividend: "2.180", /*股息*/
yield: "1.100", /*收益率*/
equity: "2147483647", /*股本*/
db_price: "108.950", /*盘后价*/
db_volume: "779446", /*盘后成交量*/
uptime: "2016-11-05 04:57:56" /*更新时间*/
}
}
}
}
------------------------------------------------------------------
4. 错误
{
"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.stock_realtime';
$postData['stoSym'] = 'sh600000';
$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.stock_realtime',
'stoSym' : 'sh600000',
'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.stock_realtime&stoSym=sh600000&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.stock_realtime&stoSym=sh600000&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json"
流量包套餐说明:
买多少用多少,多买有优惠,10元起买,适合大多数应用场景.
| 规格 | 套餐名称 | 价格 | 描述 |
|---|---|---|---|
| 201 | 流量包 1000 次 | 10 元 | 约可更新1万条行情或历史数据 |
| 202 | 流量包 11000 次 | 100 元 | 约可更新11万条行情或历史数据 |
| 203 | 流量包 22000 次 | 200 元 | 约可更新22万条行情或历史数据 |
| 204 | 流量包 33000 次 | 300 元 | 约可更新33万条行情或历史数据 |
| 205 | 流量包 55000 次 | 500 元 | 约可更新55万条行情或历史数据 |
| 206 | 流量包 110000 次 | 1000 元 | 约可更新110万条行情或历史数据 |
| 207 | 流量包 220000 次 | 2000 元 | 约可更新220万条行情或历史数据 |
| 208 | 流量包 330000 次 | 3000 元 | 约可更新330万条行情或历史数据 |
| 209 | 流量包 550000 次 | 5000 元 | 约可更新550万条行情或历史数据 |
| 210 | 流量包 1100000 次 | 10000 元 | 约可更新1100万条行情或历史数据 |
包月套餐说明:
适合调用量比较平均的高频应用场景;有配额限制,超出配额会被暂停调用1小时,请留意购买足够配额.
| 规格 | 套餐名称 | 价格 | 描述 |
|---|---|---|---|
| 102 | 10000 次配额/每小时 | 88 元/月 | 约可更新10万条行情或历史数据/每小时 |
| 103 | 18000 次配额/每小时 | 132 元/月 | 约可更新18万条行情或历史数据/每小时 |
| 104 | 24000 次配额/每小时 | 176 元/月 | 约可更新24万条行情或历史数据/每小时 |
| 105 | 36000 次配额/每小时 | 264 元/月 | 约可更新36万条行情或历史数据/每小时 |
| 106 | 60000 次配额/每小时 | 440 元/月 | 约可更新60万条行情或历史数据/每小时 |
| 107 | 120000 次配额/每小时 | 880 元/月 | 约可更新120万条行情或历史数据/每小时 |
| 108 | 240000 次配额/每小时 | 1760 元/月 | 约可更新240万条行情或历史数据/每小时 |
| 109 | 360000 次配额/每小时 | 2640 元/月 | 约可更新360万条行情或历史数据/每小时 |
| 110 | 720000 次配额/每小时 | 5280 元/月 | 约可更新720万条行情或历史数据/每小时 |
| 111 | 1440000 次配额/每小时 | 10560 元/月 | 约可更新1440万条行情或历史数据/每小时 |
免费试用套餐说明:
商用请选择付费套餐。 (系统繁忙或极端情况下,优先保证付费用户使用).
| 规格 | 套餐名称 | 价格 | 描述 |
|---|---|---|---|
| 0 | 试用套餐 50 次/每小时 | 0 元/月 | 可免费试用3个月,延长试用或次数不够可联系客服增加 |