urban-investment-research/ThirdPartyApi/Yujingtong/Apis.py

30 lines
900 B
Python
Raw Normal View History

2023-03-23 17:06:26 +08:00
from typing import List
from .Schemas import ShareHolderItemInfo
from Utils.DataUtils import JsDict
class YujingtongConfig:
# 公司股东信息获取接口
shareholder_info_url = "http://open.api.tianyancha.com/services/open/ic/holder/2.0"
class YujingtongApi:
def __init__(self, token: str, config: YujingtongConfig = YujingtongConfig):
self.config = config
self.token = token
def get_company_share_holder(self, keyword) -> List[ShareHolderItemInfo]:
"""
返回公司股东信息列表
"""
url = f"{self.config.shareholder_info_url}?objs={keyword}"
headers = {'Authorization': self.token}
res = self.rq.get(url, headers=headers)
data = res.json()
holder_list = []
if data['error_code'] == 0:
holder_list = [JsDict(item) for item in data['result']]
return holder_list