【指南】OpenApi 接入指南
发布于:2021-03-18 00:02,阅读数:674,点赞数:2
> 由于 OpenApi 给服务器带来了巨大的压力,将于「2021年05月20日」起停止服务。 # 接入文档 以下是 OpenApi 的接入文档,可以获取到国内基金详细信息和历史信息。 ## 获取所有基金 ### 请求地址 ``` https://openmfund.yuusann.com/api/fund/all ``` ### 返回参数 |Field|Type|Comments| |:--|:--|:--| |data|List|基金代码、基金名称、基金类型| ### 请求示例 ``` /api/fund/all ``` ``` { "success": true, "msg": "nil", "data": [ [ "000001", "华夏成长混合", "混合型" ], [ "000002", "华夏成长混合(后端)", "混合型" ], ... ] } ``` ## 批量获取基金信息 ### 请求地址 ``` https://openmfund.yuusann.com/api/fund/info ``` ### 请求参数 |Field|Type|Required|Comments| |:--|:--|:--|:--| |code|List|true|基金代码,多个代码用逗号,分隔,游客上限为10个,会员上限100个| ### 返回参数 |Field|Type|Required|Comments| |:--|:--|:--|:--| |code|String|true|基金代码| |name|String|true|基金名称| |type|String|true|基金类型| |manager|String|true|基金经理| |scale|String|true|基金规模| |netWorth|String|true|当前净值| |netDate|String|true|净值日期| |updated|Bool|true|今日净值是否更新| |expectWorth|String|false|当前估值| |expectGrowth|String|false|估值涨幅| |expectDate|String|false|估值时间| |dayGrowth|String|false|最近一日涨幅| |weekGrowth|String|false|最近一周涨幅| |monthGrowth|String|false|最近一月涨幅| |quarterGrowth|String|false|最近一季度涨幅| |halfYearGrowth|String|false|最近半年涨幅| |yearGrowth|String|false|最近一年涨幅| ### 请求示例 ``` /api/fund/info?code=000001,000003 ``` ``` { "success": true, "msg": "nil", "data": [ { "code": "000001", "name": "华夏成长混合", "type": "混合型", "manager": "阳琨", "scale": "48.1亿", "netWorth": "1.248", "netDate": "2021-03-17", "updated": true, "expectWorth": "1.2558", "expectGrowth": "1.6", "expectDate": "2021-03-17 15:00:00", "dayGrowth": "0.97", "weekGrowth": "1.87", "monthGrowth": "-18.7", "quarterGrowth": "-5.67", "halfYearGrowth": "-7.36", "yearGrowth": "18.6" }, { "code": "000003", "name": "中海可转债债券A", "type": "债券型", "manager": "彭海平", "scale": "1.3亿", "netWorth": "0.874", "netDate": "2021-03-17", "updated": true, "expectWorth": "0.8741", "expectGrowth": "0.24", "expectDate": "2021-03-17 15:00:00", "dayGrowth": "0.23", "weekGrowth": "1.98", "monthGrowth": "-2.56", "quarterGrowth": "-5.21", "halfYearGrowth": "-4.06", "yearGrowth": "9.66" } ], } ``` ## 获取基金历史净值 ### 请求地址 ``` https://openmfund.yuusann.com/api/fund/history ``` ### 请求参数 |Field|Type|Required|Comments| |:--|:--|:--|:--| |code|String|true|基金代码,不支持批量查询| |from|String|false|起点日期,格式为:1970-01-01| ### 返回参数 |Field|Type|Comments| |:--|:--|:--| |code|String|基金代码| |name|String|基金名称| |data|List|基金名称| 内部结构: |Field|Type|Comments| |:--|:--|:--| |worth|String|当日净值| |growth|String|当日涨幅| |date|String|净值日期| # 请求示例 ``` /api/fund/history?code=000001&from=2021-03-10 ``` ``` { "success": true, "msg": "nil", "data": { "code": "000001", "name": "华夏成长混合", "data": [ { "growth": "1.8300", "worth": "1.2250", "date": "2021-03-10" }, { "growth": "2.2000", "worth": "1.2520", "date": "2021-03-11" }, ... ] } } ``` ## 获取基金排行榜 ### 请求地址 ``` https://openmfund.yuusann.com/api/fund/rank ``` ### 请求参数 |Field|Type|Required|Comments| |:--|:--|:--|:--| |order|String|true|排序依据:day(天涨幅), week(周涨幅), month(月涨幅), quarter(季度涨幅), year(年涨幅)| |order|String|true|排序方法:asc(升序), desc(降序)| ### 返回参数 与基金信息的结构一致,每个排行榜返回十个基金。 ### 请求示例 ``` /api/fund/rank?rank=day&order=desc ``` ``` { "msg": "nil", "success": true, "data": [ { "code": "007151", "name": "前海开源沪港深聚瑞混合", "type": "混合型", "manager": "刘小明", "scale": "0.68亿", "netWorth": "1.7417", "netDate": "2021-03-17", "updated": true, "expectGrowth": "1.16", "expectWorth": "1.7403", "expectDate": "2021-03-17 15:00:00", "dayGrowth": "1.24", "weekGrowth": "5.07", "monthGrowth": "-10.79", "quarterGrowth": "13.78", "halfYearGrowth": "20.7", "yearGrowth": "72.21" }, { "code": "006614", "name": "嘉实港股通新经济指数C", "type": "股票指数", "manager": "陈正宪", "scale": "1.11亿", "netWorth": "1.4552", "netDate": "2021-03-17", "updated": true, "expectGrowth": "0.05", "expectWorth": "1.4504", "expectDate": "2021-03-17 15:00:00", "dayGrowth": "0.38", "weekGrowth": "5.0", "monthGrowth": "-9.85", "quarterGrowth": "3.97", "halfYearGrowth": "13.2", "yearGrowth": "63.16" } ] } ``` ## 批量获取基金估值 ### 请求地址 ``` https://openmfund.yuusann.com/api/fund/expect ``` ### 请求参数 |Field|Type|Required|Comments| |:--|:--|:--|:--| |code|List|true|基金代码,多个代码用逗号,分隔,游客上限为10个,会员上限100个| ### 返回参数 没有估值的基金将不会出现在返回结果中。 |Field|Type|Comments| |:--|:--|:--| |code|String|基金代码| |name|String|基金名称| |growth|String|估值涨幅| |date|String|估值时间| ### 请求示例 ``` /api/fund/expect?code=000001,000003 ``` ``` { "success": true, "msg": "nil", "data": [ { "code": "000001", "name": "华夏成长混合", "growth": "1.6", "date": "2021-03-17 15:00:00" }, { "code": "000003", "name": "中海可转债债券A", "growth": "0.24", "date": "2021-03-17 15:00:00" } ] } ``` ## 批量获取基金净值 ### 请求地址 ``` https://openmfund.yuusann.com/api/fund/worth ``` ### 请求参数 |Field|Type|Required|Comments| |:--|:--|:--|:--| |code|List|true|基金代码,多个代码用逗号,分隔,游客上限为10个,会员上限100个| ### 返回参数 没有估值的基金将不会出现在返回结果中。 |Field|Type|Comments| |:--|:--|:--| |code|String|基金代码| |name|String|基金名称| |growth|String|估值涨幅| |date|String|估值时间| |updated|Bool|今日净值是否更新| ### 请求示例 ``` /api/fund/worth?code=000001,000003 ``` ``` { "success": true, "msg": "nil", "data": [ { "code": "000001", "name": "华夏成长混合", "worth": "1.248", "growth": "0.97", "date": "2021-03-17", "updated": true }, { "code": "000003", "name": "中海可转债债券A", "worth": "0.874", "growth": "0.23", "date": "2021-03-17", "updated": true } ] } ``` # 权限和限制 ## 身份信息 在任意 API 的返回头中可以看到以下两个参数: |Field|Comments| |:--|:--| |x-open-api-user|当前用户身份| |x-open-api-remain|当前身份剩余请求次数| 这两个参数用于提示当前访问的身份以及当前身份所剩余的请求次数。 ## 访问限制 当`x-open-api-user`字段为`guest`时,表示当前请求正在作为访客身份请求。 访客的请求限制为每小时 100 次。 当`x-open-api-user`字段为你的用户名时,表示当前请求正在作为用户身份请求。 用户的请求限制为每小时 7200 次。 ## 关联身份 如果您是[「Mercurius」](https://mfund.yuusann.com)的用户,则可以在「应用」「服务中心」「OpenApi」页面或直接点击[这里](https://mfund.yuusann.com/#/service/openapi)找到用于关联的 TOKEN。 在每次请求时将 TOKEN 写入头 `x-open-api-token` 中即可关联账户。 对此有任何问题欢迎加群或直接发邮件联系我。 # 获取更多信息 - 更多文档:[【目录】Mercurius 文档中心](https://blog.yuusann.com/corpus/article/21002) - 发邮件给我:[i@yuusann.com](mailto:i@yuusann.com?subject=[Mercurius]用户反馈) - 加入微信交流群:添加微信号`zzzhyq_mk2`为好友,通过后回复消息`基金`获取链接进群。
评论:0条