-
노션 API와 주식 API를 통해서 주식종목 정리하기(3) - 주식 API 사용해보기코딩 2023. 1. 29. 23:16
우선 공공데이터 포털에서 제공하는 데이터를 통해서 내가 원하는 데이터를 받을 수 있을지 확인해 보자
해당 API를 사용하려면 활용신청을 하고 승인이 나야 하는데 보통 1일 정도 걸리는 거 같습니다. (거의 바로 처리되는 거 같기도...)
공공데이터 포털 API 사용하기
까먹고 있다가 시간이 지나고 나서 다시 들어와 보니 신청건이 활용건으로 바뀌어 있습니다.
일일 트래픽이 10000건인데 제가 많이 사용해 봤자 100건을 넘기긴 힘들 거 같으니 충분할 거 같습니다.
활용가이드에 나와있는 대로
https://apis.data.go.kr/1160100/service/GetStockSecuritiesInfoService/getStockPriceInfo?serviceKey=인증키&numOfRows=1&pageNo=1
해당 EndPoint에 호출을 해보도록 하겠습니다.
오 데이터가 잘옵니다.
그러면 내가 원하는 데이터를 뽑기 위해 param 설정을 해보겠습니다.
KOSPI, KOSDAQ 거래량 1000만 이상 종목
KOSPI, KOSDAQ 상한가 종목
원하는 데이터를 뽑을 수 있겠습니다. 그런데 오늘이 일요일인데 왜 금요일 데이터가 안 나와서 찾아보니
데이터가 다음 근무일 오전 10시쯤이면 확인이 가능하다는 글이 있는데 당일날 데이터를 당일에 확인이 안 된다고 하면...
이 API를 사용하는 의미가 없는 거 같습니다.
증권사 API
- 키움증권 - https://www.kiwoom.com/h/customer/download/VOpenApiInfoView
- 대신증권 - https://money2.daishin.com/E5/WTS/Customer/GuideTrading/DW_CybosPlus_Page.aspx?p=8812&v=8632&m=9508
- 유안타증권 - https://www.myasset.com/myasset/trading/apiSvc/TR_1604001_P1.cmd
- 한국투자증권 - https://apiportal.koreainvestment.com/apiservice/oauth2#L_5c87ba63-740a-4166-93ac-803510bb9c02
증권사의 API를 통해서 만들어보려고 했지만 Mac OS에서 사용가능한 API가 찾아본 것 중에는 한국투자증권이 유일한데
API 문서를 살펴보니 한국투자증권 API를 통해서는 원하는 조건(상한가 & 거래량 천만 이상)의 종목을 추려낼 수가 없다. (개별종목들은 조회가 가능)
네이버 증권
이 방법 외에는 떠오르지가 않습니다. 평소에 일일이 정리할 때 보던 네이버 증권의 사이트를 스크래핑해서 데이터를 만들어봐야겠습니다.
사랑해요 네이버
어떻게 웹페이지의 내용을 스크래핑할 수 있는지에 대한 방법은 따로 포스팅을 하도록 하고 다음 포스팅에서는 스크래핑해서 가져온 데이터를 통해서 원하는 데이터를 추출해서 노션에 넣어보도록 하겠습니다.
'코딩' 카테고리의 다른 글
노션 API와 주식 API를 통해서 주식종목 정리하기(2) - 노션 API 사용준비 (0) 2023.01.12 노션 API와 주식 API를 통해서 주식종목 정리하기(1) - 계기 (0) 2023.01.10