{"id":13488283,"url":"https://github.com/akfamily/aktools","last_synced_at":"2025-05-14T14:09:29.589Z","repository":{"id":38106248,"uuid":"228558704","full_name":"akfamily/aktools","owner":"akfamily","description":"AKTools is an elegant and simple HTTP API library for AKShare, built for AKSharers!","archived":false,"fork":false,"pushed_at":"2025-03-30T20:12:49.000Z","size":28,"stargazers_count":733,"open_issues_count":6,"forks_count":149,"subscribers_count":16,"default_branch":"main","last_synced_at":"2025-05-13T02:19:59.051Z","etag":null,"topics":["akshare","asyncio","data","data-science","fastapi","openapi","pydanti"],"latest_commit_sha":null,"homepage":"https://aktools.akfamily.xyz/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akfamily.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-12-17T07:30:06.000Z","updated_at":"2025-05-12T17:15:48.000Z","dependencies_parsed_at":"2022-08-08T23:01:08.167Z","dependency_job_id":"fcb96118-d158-495c-af67-de4a192a985d","html_url":"https://github.com/akfamily/aktools","commit_stats":{"total_commits":301,"total_committers":2,"mean_commits":150.5,"dds":0.006644518272425293,"last_synced_commit":"bcdc57fcb725da648bcabb14518bffbd8c89cd7e"},"previous_names":[],"tags_count":86,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akfamily%2Faktools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akfamily%2Faktools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akfamily%2Faktools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akfamily%2Faktools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akfamily","download_url":"https://codeload.github.com/akfamily/aktools/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254160365,"owners_count":22024568,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["akshare","asyncio","data","data-science","fastapi","openapi","pydanti"],"created_at":"2024-07-31T18:01:13.024Z","updated_at":"2025-05-14T14:09:24.569Z","avatar_url":"https://github.com/akfamily.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# AKTools\n\nAKTools is a package of HTTP API for AKShare! It depends on AKShare, FastAPI and Typer.\n\n[AKTools](https://github.com/akfamily/aktools) 是一款用于快速搭建 [AKShare](https://github.com/akfamily/akshare) HTTP API 的工具，通过 [AKTools](https://github.com/akfamily/aktools)\n可以利用一行命令来启动 HTTP 服务，从而让原本专属服务于 Python 用户的开源财经数据接口库 [AKShare](https://github.com/akfamily/akshare) 的使用\n突破编程语言的限制。无论您使用的是 C/C++、Java、Go、Rust、Ruby、PHP、JavaScript、R、Matlab、Stata 等编程语言或软件都可以快速、轻松获取财经数据，助力您更好地展开研究和开发工作。\n\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/akshare.svg)](https://pypi.org/project/akshare/)\n[![PyPI](https://img.shields.io/pypi/v/aktools.svg)](https://pypi.org/project/aktools/)\n[![Downloads](https://pepy.tech/badge/aktools)](https://pepy.tech/project/aktools)\n[![Documentation Status](https://readthedocs.org/projects/aktools/badge/)](https://aktools.akfamily.xyz/)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![aktools](https://img.shields.io/badge/Data%20Science-AKShare-green)](https://github.com/akfamily/aktools)\n[![Actions Status](https://github.com/akfamily/aktools/workflows/build/badge.svg)](https://github.com/akfamily/aktools/actions)\n[![MIT Licence](https://img.shields.io/badge/license-MIT-blue)](https://github.com/akfamily/aktools/blob/master/LICENSE)\n[![](https://img.shields.io/github/forks/akfamily/aktools)](https://github.com/akfamily/aktools)\n[![](https://img.shields.io/github/stars/akfamily/aktools)](https://github.com/akfamily/aktools)\n[![](https://img.shields.io/github/issues/akfamily/aktools)](https://github.com/akfamily/aktools)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)\n\n**[AKTools 中文文档](https://aktools.readthedocs.io/)**\n\n## Installation\n\n```shell\npip install aktools\n```\n\n## Upgrade\n\n```shell\npip install aktools --upgrade -i https://pypi.org/simple  # AKTools's version should great than 0.0.88\n```\n\n## AKShare\n\n[Please visit AKShare's Documentation](https://akshare.akfamily.xyz/)\n\n## FastAPI\n\n[Please visit FastAPI's Documentation](https://fastapi.tiangolo.com/)\n\n## Typer\n\n[Please visit Typer's Documentation](https://typer.tiangolo.com/)\n\n## Fast Run\n\n1. just type the cmd/bash command: `python -m aktools`\n2. then type `http://127.0.0.1:8080/` in your Chrome and you can fetch your homepage and more information\n3. if you just want to test data api, you can type `http://127.0.0.1:8080/api/public/stock_zh_a_hist` in your Chrome\n4. if you want to set parameter for API, then you just type like `http://127.0.0.1:8080/api/public/stock_zh_a_hist?symbol=600000`\n\n## Homepage\n\nAKTools set a simple homepage for user to provide simple reference information. When you set up your\nenvironment and deploy your local application, then you can type `http:127.0.0.1:8080` in your browser.\nWe are developing more functions now, please pay more attention!\n\n## Demo\n\n### Test-Postman\n\n![](https://dss-1252952517.cos.ap-chengdu.myqcloud.com/image-20211209235248006.png)\n\n### Test-R\n\nR-Program\n\n```\nlibrary(RCurl)  # 需要先安装该包\nlibrary(jsonlite)  # 需要先安装该包\noptions (warn = -1)  # 该行有助于在无参数请求时去掉 warning 信息\n\ntemp_df \u003c-\n  getForm(\n    uri = 'http://127.0.0.1:8080/api/public/stock_zh_a_hist',  # 此处的 http://127.0.0.1:8080 需要替换为您定义的地址和端口\n    symbol = '000001',\n    period = 'daily',\n    start_date = '20211109',\n    end_date = '20211209',\n    adjust = 'hfq',\n    .encoding = \"utf-8\"\n  )\ninner_df \u003c- fromJSON(temp_df)\ninner_df\n```\n\nR-Result\n\n```shell\n         日期    开盘    收盘    最高    最低      成交量     成交额    振幅  涨跌幅  涨跌额 换手率\n1  2021-11-09 3009.83 3017.96 3037.46 2974.07 1240573 2163193120 2.11   0.60  17.88   0.64\n2  2021-11-10 3006.58 2996.83 3008.20 2957.82 1220851 2109735152 1.67  -0.70 -21.13   0.63\n3  2021-11-11 2988.70 3151.23 3164.23 2983.82 2084729 3752413856 6.02   5.15 154.40   1.07\n4  2021-11-12 3144.73 3138.23 3196.74 3112.22  957546 1753072720 2.68  -0.41 -13.00   0.49\n5  2021-11-15 3151.23 3164.23 3196.74 3126.85  655090 1203764096 2.23   0.83  26.00   0.34\n6  2021-11-16 3152.85 3130.10 3182.11 3121.97  601110 1099113408 1.90  -1.08 -34.13   0.31\n7  2021-11-17 3118.72 3112.22 3143.10 3091.09  664640 1203859184 1.66  -0.57 -17.88   0.34\n8  2021-11-18 3108.97 3061.84 3113.85 3050.46  799844 1430058304 2.04  -1.62 -50.38   0.41\n9  2021-11-19 3061.84 3118.72 3133.35 3045.58  786372 1414506384 2.87   1.86  56.88   0.41\n10 2021-11-22 3099.22 3113.85 3134.97 3078.09  738618 1337768176 1.82  -0.16  -4.87   0.38\n11 2021-11-23 3112.22 3074.84 3151.23 3042.33 1235978 2213817584 3.50  -1.25 -39.01   0.64\n12 2021-11-24 3056.96 3073.21 3086.22 3039.08  741311 1316774400 1.53  -0.05  -1.63   0.38\n13 2021-11-25 3052.09 3042.33 3060.21 3034.21  603533 1068221312 0.85  -1.00 -30.88   0.31\n14 2021-11-26 3032.58 3026.08 3040.71 3016.33  694500 1219937312 0.80  -0.53 -16.25   0.36\n15 2021-11-29 2998.45 3014.70 3024.46 2990.33  512595  895105984 1.13  -0.38 -11.38   0.26\n16 2021-11-30 3019.58 3003.33 3042.33 2988.70  733616 1280384560 1.78  -0.38 -11.37   0.38\n17 2021-12-01 3001.70 3035.83 3056.96 2991.95  706925 1243666848 2.16   1.08  32.50   0.36\n18 2021-12-02 3032.58 3027.71 3063.46 2991.95  994798 1749164560 2.36  -0.27  -8.12   0.51\n19 2021-12-03 3035.83 3037.46 3045.58 2998.45  707600 1242375056 1.56   0.32   9.75   0.36\n20 2021-12-06 3069.96 3110.60 3185.36 3061.84 2145625 3896385168 4.07   2.41  73.14   1.11\n21 2021-12-07 3143.10 3169.11 3203.24 3118.72 1616444 2979968976 2.72   1.88  58.51   0.83\n22 2021-12-08 3167.48 3170.73 3183.73 3120.35  980281 1798691056 2.00   0.05   1.62   0.51\n23 2021-12-09 3173.98 3208.11 3266.62 3154.48 1455887 2726663440 3.54   1.18  37.38   0.75\n```\n\n### Test-MATLAB\n\nMATLAB-Program\n\n```\napi = 'http://127.0.0.1:8080/api/public/';\nurl = [api 'stock_zh_a_hist'];\noptions = weboptions('ContentType','json', 'CharacterEncoding', 'utf-8');\ndata = webread(url, options, symbol = '000001', period = 'daily', start_date = '20211109', end_date = '20211209', adjust = 'hfq');\ndata % 由于 MATLAB 无法显示中文字段名，请自行修改为英文字段，参考链接：https://iso2mesh.sourceforge.net/cgi-bin/index.cgi?jsonlab/Doc/Examples\n```\n\nMATLAB-Result\n\n```shell\n'2021-11-09'\t3009.83000000000\t3017.96000000000\t3037.46000000000\t2974.07000000000\t1240573\t2163193120.00000\t2.11000000000000\t0.600000000000000\t17.8800000000000\t0.640000000000000\n'2021-11-10'\t3006.58000000000\t2996.83000000000\t3008.20000000000\t2957.82000000000\t1220851\t2109735152.00000\t1.67000000000000\t-0.700000000000000\t-21.1300000000000\t0.630000000000000\n'2021-11-11'\t2988.70000000000\t3151.23000000000\t3164.23000000000\t2983.82000000000\t2084729\t3752413856.00000\t6.02000000000000\t5.15000000000000\t154.400000000000\t1.07000000000000\n'2021-11-12'\t3144.73000000000\t3138.23000000000\t3196.74000000000\t3112.22000000000\t957546\t1753072720.00000\t2.68000000000000\t-0.410000000000000\t-13\t0.490000000000000\n'2021-11-15'\t3151.23000000000\t3164.23000000000\t3196.74000000000\t3126.85000000000\t655090\t1203764096.00000\t2.23000000000000\t0.830000000000000\t26\t0.340000000000000\n'2021-11-16'\t3152.85000000000\t3130.10000000000\t3182.11000000000\t3121.97000000000\t601110\t1099113408.00000\t1.90000000000000\t-1.08000000000000\t-34.1300000000000\t0.310000000000000\n'2021-11-17'\t3118.72000000000\t3112.22000000000\t3143.10000000000\t3091.09000000000\t664640\t1203859184.00000\t1.66000000000000\t-0.570000000000000\t-17.8800000000000\t0.340000000000000\n'2021-11-18'\t3108.97000000000\t3061.84000000000\t3113.85000000000\t3050.46000000000\t799844\t1430058304.00000\t2.04000000000000\t-1.62000000000000\t-50.3800000000000\t0.410000000000000\n'2021-11-19'\t3061.84000000000\t3118.72000000000\t3133.35000000000\t3045.58000000000\t786372\t1414506384.00000\t2.87000000000000\t1.86000000000000\t56.8800000000000\t0.410000000000000\n'2021-11-22'\t3099.22000000000\t3113.85000000000\t3134.97000000000\t3078.09000000000\t738618\t1337768176.00000\t1.82000000000000\t-0.160000000000000\t-4.87000000000000\t0.380000000000000\n'2021-11-23'\t3112.22000000000\t3074.84000000000\t3151.23000000000\t3042.33000000000\t1235978\t2213817584.00000\t3.50000000000000\t-1.25000000000000\t-39.0100000000000\t0.640000000000000\n'2021-11-24'\t3056.96000000000\t3073.21000000000\t3086.22000000000\t3039.08000000000\t741311\t1316774400.00000\t1.53000000000000\t-0.0500000000000000\t-1.63000000000000\t0.380000000000000\n'2021-11-25'\t3052.09000000000\t3042.33000000000\t3060.21000000000\t3034.21000000000\t603533\t1068221312.00000\t0.850000000000000\t-1\t-30.8800000000000\t0.310000000000000\n'2021-11-26'\t3032.58000000000\t3026.08000000000\t3040.71000000000\t3016.33000000000\t694500\t1219937312.00000\t0.800000000000000\t-0.530000000000000\t-16.2500000000000\t0.360000000000000\n'2021-11-29'\t2998.45000000000\t3014.70000000000\t3024.46000000000\t2990.33000000000\t512595\t895105984\t1.13000000000000\t-0.380000000000000\t-11.3800000000000\t0.260000000000000\n'2021-11-30'\t3019.58000000000\t3003.33000000000\t3042.33000000000\t2988.70000000000\t733616\t1280384560.00000\t1.78000000000000\t-0.380000000000000\t-11.3700000000000\t0.380000000000000\n'2021-12-01'\t3001.70000000000\t3035.83000000000\t3056.96000000000\t2991.95000000000\t706925\t1243666848.00000\t2.16000000000000\t1.08000000000000\t32.5000000000000\t0.360000000000000\n'2021-12-02'\t3032.58000000000\t3027.71000000000\t3063.46000000000\t2991.95000000000\t994798\t1749164560.00000\t2.36000000000000\t-0.270000000000000\t-8.12000000000000\t0.510000000000000\n'2021-12-03'\t3035.83000000000\t3037.46000000000\t3045.58000000000\t2998.45000000000\t707600\t1242375056.00000\t1.56000000000000\t0.320000000000000\t9.75000000000000\t0.360000000000000\n'2021-12-06'\t3069.96000000000\t3110.60000000000\t3185.36000000000\t3061.84000000000\t2145625\t3896385168.00000\t4.07000000000000\t2.41000000000000\t73.1400000000000\t1.11000000000000\n'2021-12-07'\t3143.10000000000\t3169.11000000000\t3203.24000000000\t3118.72000000000\t1616444\t2979968976.00000\t2.72000000000000\t1.88000000000000\t58.5100000000000\t0.830000000000000\n'2021-12-08'\t3167.48000000000\t3170.73000000000\t3183.73000000000\t3120.35000000000\t980281\t1798691056.00000\t2\t0.0500000000000000\t1.62000000000000\t0.510000000000000\n'2021-12-09'\t3173.98000000000\t3208.11000000000\t3266.62000000000\t3154.48000000000\t1455887\t2726663440.00000\t3.54000000000000\t1.18000000000000\t37.3800000000000\t0.750000000000000\n```\n\n### Test-Rust\n\nRust-Program\n\n```rust\nuse reqwest::blocking;\nuse serde_json::Value;\nuse std::collections::HashMap;\n\n// 定义常量，用于存储API的URL。\nconst URL: \u0026str = \"http://127.0.0.1:8080/api/public\";\n\n/// 获取股票数据的函数。\n///\n/// # 参数\n/// * `symbol` - 股票代码。\n/// * `period` - 时间周期。\n/// * `start_date` - 开始日期。\n/// * `end_date` - 结束日期。\n/// * `adjust` - 复权类型。\n///\n/// # 返回值\n/// 返回一个Result，如果成功返回空的Ok，如果失败返回错误。\nfn get_data(\n    endpoint: \u0026str,\n    symbol: \u0026str,\n    period: \u0026str,\n    start_date: \u0026str,\n    end_date: \u0026str,\n    adjust: \u0026str,\n) -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    // 初始化查询参数，使用提供的函数参数。\n    let params = HashMap::from([\n        (\"symbol\", symbol),\n        (\"period\", period),\n        (\"start_date\", start_date),\n        (\"end_date\", end_date),\n        (\"adjust\", adjust),\n    ]);\n\n    // 创建一个阻塞的HTTP客户端。\n    let client = blocking::Client::new();\n    // 构建HTTP GET请求，并将查询参数附加到请求上。\n    let full_url = format!(\"{}/{}\", URL, endpoint);\n    let resp = client.get(full_url).query(\u0026params).send()?;\n\n    // 检查响应状态码是否表示成功。\n    if resp.status().is_success() {\n        // 解析响应体为JSON并打印。\n        let stock_data_list: Value = resp.json()?;\n        println!(\"{:#?}\", stock_data_list);\n    } else {\n        // 如果响应不是成功的，则打印错误信息。\n        eprintln!(\"请求失败，状态码为: {}\", resp.status());\n    }\n\n    Ok(())\n}\n\nfn main() {\n    // 调用`get_data`函数，并传递股票参数。\n    // 如果出现错误，则打印错误信息。\n    if let Err(e) = get_data(\"stock_zh_a_hist\", \"000001\", \"daily\", \"20240125\", \"20240127\", \"\") {\n        eprintln!(\"发生错误: {}\", e);\n    }\n}\n```\n\nRust-Result\n\n```shell\nArray [\n    Object {\n        \"开盘\": Number(9.33),\n        \"成交量\": Number(2162514),\n        \"成交额\": Number(2037648413.07),\n        \"振幅\": Number(2.89),\n        \"换手率\": Number(1.11),\n        \"收盘\": Number(9.5),\n        \"日期\": String(\"2024-01-25T00:00:00.000\"),\n        \"最低\": Number(9.27),\n        \"最高\": Number(9.54),\n        \"涨跌幅\": Number(1.82),\n        \"涨跌额\": Number(0.17),\n    },\n    Object {\n        \"开盘\": Number(9.47),\n        \"成交量\": Number(2272287),\n        \"成交额\": Number(2172799799.01),\n        \"振幅\": Number(2.42),\n        \"换手率\": Number(1.17),\n        \"收盘\": Number(9.62),\n        \"日期\": String(\"2024-01-26T00:00:00.000\"),\n        \"最低\": Number(9.44),\n        \"最高\": Number(9.67),\n        \"涨跌幅\": Number(1.26),\n        \"涨跌额\": Number(0.12),\n    },\n]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakfamily%2Faktools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakfamily%2Faktools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakfamily%2Faktools/lists"}