【2025年14期免费获取股票数据API接口】实例演示五种主流语言获取股票行情api接口之沪深A股近年增发数据获取实例演示及接口API说明文档

在近一至两年期间,股票量化分析逐步成为备受关注的热门议题。对于投身于该领域工作而言,首要步骤便是获取全面且精准的股票数据。无论是实时交易数据、历史交易记录、财务数据,亦或是基本面信息,这些数据均是开展量化分析过程中不可或缺的宝贵资源。我们的核心任务在于从这些数据中提炼出具有价值的信息,从而为投资策略提供坚实有力的指导。

在数据探索进程中,我尝试运用了多种方法,涵盖自编网易股票页面爬虫程序、申万行业数据爬虫程序,以及同花顺问财的爬虫程序,甚至还采用了聚宽的免费数据 API。然而,爬虫作为数据来源,时常呈现出稳定性不足的状况,给我们的量化分析工作带来了一定程度的困扰 。

在量化分析领域,实时且准确的数据接口是成功的基石。经过多次实际测试,我将已确认可用的数据接口分享给正在从事量化分析的朋友们,希望能够对你们的研究和工作有所帮助,接下来我会用Python、JavaScript(Node.js)、Java、C#和Ruby五种主流语言的实例代码给大家逐一演示一下如何获取各类股票数据:

1、python

import requests  
  
url = "https://api.zhituapi.com/hs/gs/jnzf/000001?token=ZHITU_TOKEN_LIMIT_TEST"  
response = requests.get(url)  
data = response.json()  
print(data)

2、JavaScript (Node.js)

const axios = require('axios');  
  
const url = "https://api.zhituapi.com/hs/gs/jnzf/000001?token=ZHITU_TOKEN_LIMIT_TEST";  
axios.get(url)  
  .then(response => {  
    console.log(response.data);  
  })  
  .catch(error => {  
    console.log(error);  
  });

3、Java

import java.net.URI;  
import java.net.http.HttpClient;  
import java.net.http.HttpRequest;  
import java.net.http.HttpResponse;  
import java.io.IOException;  
  
public class Main {  
    public static void main(String[] args) {  
        HttpClient client = HttpClient.newHttpClient();  
        HttpRequest request = HttpRequest.newBuilder()  
            .uri(URI.create("https://api.zhituapi.com/hs/gs/jnzf/000001?token=ZHITU_TOKEN_LIMIT_TEST"))  
            .build();  
  
        try {  
            HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());  
            System.out.println(response.body());  
        } catch (IOException | InterruptedException e) {  
            e.printStackTrace();  
        }  
    }  
}

4、C#

using System;  
using System.Net.Http;  
using System.Threading.Tasks;  
  
class Program  
{  
    static async Task Main()  
    {  
        using (HttpClient client = new HttpClient())  
        {  
            string url = "https://api.zhituapi.com/hs/gs/jnzf/000001?token=ZHITU_TOKEN_LIMIT_TEST";  
            HttpResponseMessage response = await client.GetAsync(url);  
            string responseBody = await response.Content.ReadAsStringAsync();  
            Console.WriteLine(responseBody);  
        }  
    }  
}

5、Ruby

require 'net/http'  
require 'json'  
  
url = URI("https://api.zhituapi.com/hs/gs/jnzf/000001?token=ZHITU_TOKEN_LIMIT_TEST")  
  
http = Net::HTTP.new(url.host, url.port)  
request = Net::HTTP::Get.new(url)  
response = http.request(request)  
data = JSON.parse(response.read_body)  
puts data

返回的数据:

[{"sdate":"2015-05-20","type":"定向配售、网下询价配售","price":"16.70元","tprice":"1,000,000.00万元","fprice":"6,000.00万元","amount":"59880.2395万股"},{"sdate":"2014-01-08","type":"定向配售","price":"11.17元","tprice":"1,478,221.03万元","fprice":"4,850.00万元","amount":"132338.4991万股"},{"sdate":"2011-07-29","type":"定向配售","price":"17.75元","tprice":"269,005.23万元","fprice":"0.00元","amount":"163833.6654万股"},{"sdate":"2010-09-16","type":"定向配售","price":"18.26元","tprice":"693,113.08万元","fprice":"2,386.23万元","amount":"37958万股"}]

近年增发

API地址:https://api.zhituapi.com/hs/gs/jnzf/股票代码?token=token证书

描述:根据《股票列表》得到的股票代码获取上市公司的近年来的增发情况。按公告日期倒序。

更新频率:每日03:30

字段名称 数据类型 字段说明
sdate string 公告日期yyyy-MM-dd
type string 发行方式
price string 发行价格
tprice string 实际公司募集资金总额
fprice string 发行费用总额
amount string 实际发行数量

【重要提示】

上方所有演示中的API接口Url链接结尾的ZHITU_TOKEN_LIMIT_TEST,均为数据请求token证书,因为这个证书是官方测试证书,仅可用于验证各个接口的有效性,所以这个证书限制了只可请求股票代码为000001的数据,正式环境中是不能使用的,证书可以自己去申请一个替换掉就好了,证书是免费申请的:https://www.zhituapi.com/gettoken.html,替换成自己申请的证书就可以请求任何股票数据了。

你可能感兴趣的:(python,开发语言,java,股票API,股票数据接口)