1. 크롤링 데이터 등록 (POST)

무조건 유저가 자신 주식 포트폴리오 등록을 하면 요청 보내기

{
	"stockType": "korea" or "us",
	"stockName": 검색했을 때 주식이 나오는 stockName. 예를 들어 '엔비디아'가 아니라 'NVDA'
}

2. 레포트 생성 (POST)

2-1. 기본 경제 레포트 생성

{
	"reportType": "economy",
	"stockName": "",
	"riskTolerance": 위험 수용 성향 (1개),
	"reportDifficultyLevel": 레포트 난이도 (1개),
	"interestAreas": [관심 분야 (배열로 보내기)]
}

2-2. 주식 레포트 생성

{
	"reportType": "stock",
	"stockName": 검색했을 때 주식이 나오는 stockName. 예를 들어 '엔비디아'가 아니라 'NVDA',
	"riskTolerance": 위험 수용 성향 (1개),
	"reportDifficultyLevel": 레포트 난이도 (1개),
	"interestAreas": [관심 분야 (배열로 보내기)]
}

3. API POST 요청 시 주의 사항

  1. json으로 보내기
  2. response 데이터를 utf-8로 디코딩하기 → 그래야 한글이 제대로 받아와짐
  3. 예시 파이썬 코드
import requests, json

data = {
    "reportType": "stock",
    "stockName": "NVDA",
    "riskTolerance": "하이리스크 하이리턴",
    "reportDifficultyLevel": "전문가 수준의 레포트를 원합",
    "interestAreas": ["주식시장", "국제 정세", "경제 지표", "기술 동향"],
}

headers = {
    "Content-Type": "application/json"
}

response = requests.post("<https://dockerel.o-r.kr/api/v1/report>",
													data=json.dumps(data),
													headers=headers)

decoded = response.content.decode("utf-8")

data = json.loads(decoded)
print(f"summary : {data['data']['summary']}")
print(f"summary : {data['data']['insight']}")