【62期获取股票数据API接口】如何用Python、Java等五种主流语言实例演示获取股票行情API接口之沪深A股派现与募资对比数据及接口API说明文档

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

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

1、python

python 复制代码
import requests  
  
url = "https://api.zhituapi.com/hs/margin/pxmz/000001?token=ZHITU_TOKEN_LIMIT_TEST"  
response = requests.get(url)  
data = response.json()  
print(data)

2、JavaScript (Node.js)

javascript 复制代码
const axios = require('axios');  
  
const url = "https://api.zhituapi.com/hs/margin/pxmz/000001?token=ZHITU_TOKEN_LIMIT_TEST";  
axios.get(url)  
  .then(response => {  
    console.log(response.data);  
  })  
  .catch(error => {  
    console.log(error);  
  });

3、Java

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/margin/pxmz/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#

csharp 复制代码
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/margin/pxmz/000001?token=ZHITU_TOKEN_LIMIT_TEST";  
            HttpResponseMessage response = await client.GetAsync(url);  
            string responseBody = await response.Content.ReadAsStringAsync();  
            Console.WriteLine(responseBody);  
        }  
    }  
}

5、Ruby

ruby 复制代码
require 'net/http'  
require 'json'  
  
url = URI("https://api.zhituapi.com/hs/margin/pxmz/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

返回的数据:

json 复制代码
[{"pxcs":26,"pxze":60203467634.61,"rzcs":10,"rzze":110403606146.97,"fhl":5.5,"gxzfl":26.51,"pxrzb":54.53,"sfrze":0,"zrze":110403606146.97,"sfrzcs":1,"zfrzcs":4,"zqrzcs":1}]

派现与募资对比

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

描述:根据《股票列表》得到的股票代码作为参数,得到股票的派现与募资对比。

更新频率:每日21:00

字段名称 数据类型 字段说明
pxcs number 派现次数
pxze number 派现总额(元)
rzcs number 融资次数
rzze number 融资总额(元)
fhl number 分红率(%)
gxzfl number 股息支付率(%)
pxrzb number 派现融资比(%)
sfrze number 首发融资额(元)
sfrzcs number 首发融资次数
zfrzcs number 增发融资次数
zqrzcs number 债券融资次数
相关推荐
Chase_Mos3 小时前
Spring 必会之微服务篇(1)
java·spring·微服务
码上淘金3 小时前
【Python】Python常用控制结构详解:条件判断、遍历与循环控制
开发语言·python
Brilliant Nemo3 小时前
四、SpringMVC实战:构建高效表述层框架
开发语言·python
2301_787552874 小时前
console-chat-gpt开源程序是用于 AI Chat API 的 Python CLI
人工智能·python·gpt·开源·自动化
懵逼的小黑子4 小时前
Django 项目的 models 目录中,__init__.py 文件的作用
后端·python·django
Y3174294 小时前
Python Day23 学习
python·学习
Ai尚研修-贾莲5 小时前
Python语言在地球科学交叉领域中的应用——从数据可视化到常见数据分析方法的使用【实例操作】
python·信息可视化·数据分析·地球科学
格林威5 小时前
Baumer工业相机堡盟工业相机的工业视觉中为什么偏爱“黑白相机”
开发语言·c++·人工智能·数码相机·计算机视觉
小林学习编程5 小时前
SpringBoot校园失物招领信息平台
java·spring boot·后端
撸码到无法自拔5 小时前
docker常见命令
java·spring cloud·docker·容器·eureka