Module sktmls.apis.recommendation_api
Classes
class MLSRecommendationAPIClient (env: MLSENV = None, runtime_env: MLSRuntimeENV = None, client_id: str = None, apikey: str = None)
-
MLS 추천 API를 호출할 수 있는 클라이언트입니다.
MMS를 제외한 환경에서는 테스트용 호출로 처리됩니다.
EDD 환경은 지원하지 않습니다.
Args
- env: (
MLSENV
) 접근할 MLS 환경 (MLSENV.DEV
|MLSENV.STG
|MLSENV.PRD
) (기본값:MLSENV.STG
) - runtime_env: (
MLSRuntimeENV
) 클라이언트가 실행되는 환경 (MLSRuntimeENV.YE
|MLSRuntimeENV.MMS
|MLSRuntimeENV.LOCAL
) (기본값:MLSRuntimeENV.LOCAL
) - client_id: (optional) (str) 호출 클라이언트 (
tw
,twd
,netcrm
등) - apikey: (optional) (str) 클라이언트의 API Key
아래의 환경 변수가 정의된 경우 해당 파라미터를 생략 가능합니다.
- $MLS_ENV: env
- $AWS_ENV: env
- $MLS_RUNTIME_ENV: runtime_env
runtime_env가
MLSRuntimeENV.MMS
인 경우client_id
와apikey
파라미터를 생략 가능합니다.Returns
Example
recommendation_api_client = MLSRecommendationAPIClient(client_id="tw", apikey="test_apikey", env=MLSENV.STG, runtime_env=MLSRuntimeENV.YE)
Methods
def get_env(self) ‑> MLSENV
def get_runtime_env(self) ‑> MLSRuntimeENV
def predict(self, api_type: str, target_id: str, channel_ids: List[str], keys: List[Any] = [])
-
MLS 추천 API v3를 호출합니다.
Args
- api_type: (str) 식별자 타입 (
user
|target
) - target_id: (str) 추천 타겟의 고유 식별자
- channel_ids: (list(str)) 조회할 채널 ID 리스트
- keys: (optional) (list) 추가 전달할 keys 리스트 (기본값: [])
Returns
dict
Example
rec_dict = recommendation_api_client.predict( api_type="user", target_id=hashlib.sha256("1234567890".encode()).hexdigest(), channel_ids=["test"], keys=[], )
- api_type: (str) 식별자 타입 (
async def predict_async(self, api_type: str, target_id: str, channel_ids: List[str], keys: List[Any] = [])
-
MLS 추천 API v3를 비동기 호출합니다.
Args
- api_type: (str) 식별자 타입 (
user
|target
) - target_id: (str) 추천 타겟의 고유 식별자
- channel_ids: (list(str)) 조회할 채널 ID 리스트
- keys: (optional) (list) 추가 전달할 keys 리스트 (기본값: [])
Returns
dict
Example
rec_dict = await recommendation_api_client.predict_async( api_type="user", target_id=hashlib.sha256("1234567890".encode()).hexdigest(), channel_ids=["test"], keys=[], )
- api_type: (str) 식별자 타입 (
def request(self, version: str, user_id: str, channel_ids: List[str]) ‑> Dict[str, Any]
-
MLS 추천 API v1/v2를 호출합니다.
Args
- version: (str) 호출할 추천 API 버전(
v1
|v2
) - user_id: (str) 해시된 유저 고유 ID (해시된 서비스관리번호)
- channel_ids: (list(str)) 조회할 채널 ID 리스트
Returns
dict
Example
rec_dict = recommendation_api_client.request( version="v2", user_id=hashlib.sha256("1234567890".encode()).hexdigest(), channel_ids=["test"] )
- version: (str) 호출할 추천 API 버전(
async def request_async(self, version: str, user_id: str, channel_ids: List[str]) ‑> Dict[str, Any]
-
MLS 추천 API v1/v2를 비동기 호출합니다.
Args
- version: (str) 호출할 추천 API 버전(
v1
|v2
) - user_id: (str) 해시된 유저 고유 ID (해시된 서비스관리번호)
- channel_ids: (list(str)) 조회할 채널 ID 리스트
Returns
dict
Example
rec_dict = await recommendation_api_client.request_async( version="v2", user_id=hashlib.sha256("1234567890".encode()).hexdigest(), channel_ids=["test"] )
- version: (str) 호출할 추천 API 버전(
- env: (