본문 바로가기

Data Science/Data Collection

[04. 금융감독원 API] 007. 사업보고서 주요정보 – 최대주주 현황

728x90

최대주주 현황 API 코드를 작성해보자.

 

[그림 4.7] 최대주주 현황 개발가이드

 

import json
import pandas as pd
import requests

def get_the_largest_shareholder(api_key, code, year, report_code):
    fullUrl = 'https://opendart.fss.or.kr/api/hyslrSttus.json?crtfc_key=%s&corp_code=%s&' \
              'bsns_year=%s&reprt_code=%s' % (api_key, code, year, report_code)

    response = requests.get(fullUrl, headers={'User-Agent': 'Mozilla/5.0'})
    result = response.text
    result = json.loads(result)

    if result['status'] == '000':
        data = pd.DataFrame(result['list'])

        return data

if __name__ == '__main__':
    api_key ='*'
    code = '00126380'
    year = '2018'
    report_code = '11011'

    the_largest_shareholder = get_the_largest_shareholder(api_key, code, year, report_code)
    print(the_largest_shareholder)


결과 값
      rcept_no     corp_cls  ... trmend_posesn_stock_co trmend_posesn_stock_qota_rt
0   20190401004781        Y  ...            249,273,200                        4.18
1   20190401004781        Y  ...             19,048,733                        0.32
2   20190401004781        Y  ...              1,268,546                        0.15
3   20190401004781        Y  ...             88,802,052                        1.49
4   20190401004781        Y  ...                 28,500                        0.00
5   20190401004781        Y  ...                175,000                        0.00
6   20190401004781        Y  ...                 99,750                        0.00
7   20190401004781        Y  ...                 50,000                        0.00
8   20190401004781        Y  ...                      0                        0.00
9   20190401004781        Y  ...                619,900                        0.08
10  20190401004781        Y  ...            298,818,100                        5.01
11  20190401004781        Y  ...              4,484,150                        0.08
12  20190401004781        Y  ...              1,880,750                        0.03
13  20190401004781        Y  ...             54,153,600                        0.91
14  20190401004781        Y  ...             42,020,150                        0.70
15  20190401004781        Y  ...            508,157,148                        8.51
16  20190401004781        Y  ...                 43,950                        0.01
17  20190401004781        Y  ...          1,266,991,133                       21.22
18  20190401004781        Y  ...              1,932,396                        0.23
728x90