Module sktmls.apis
Sub-modules
sktmls.apis.conversion_tracking_api
sktmls.apis.graph_api
sktmls.apis.profile_api
sktmls.apis.recommendation_api
Classes
class Edge (**kwargs)
-
GraphDB의 Edge 클래스입니다.
Args
- kwargs
- id: (str) Edge 고유 ID
- label: (str) Edge 라벨
- properties: (dict) Edge property 값들
Returns
Methods
def get(self)
- kwargs
class MLSConversionTrackingAPIClient (client_id: str, apikey: str, env: MLSENV = None, runtime_env: MLSRuntimeENV = None)
-
MLS Conversion Tracking API를 호출할 수 있는 클라이언트입니다.
모든 호출은 테스트용 호출로 처리됩니다.
MMS, EDD 환경은 지원하지 않습니다.
Args
- client_id: (str) 호출 클라이언트 (
tw
,twd
,netcrm
등) - apikey: (str) 클라이언트의 API Key
- env: (
MLSENV
) 접근할 MLS 환경 (MLSENV.DEV
|MLSENV.STG
|MLSENV.PRD
) (기본값:MLSENV.STG
) - runtime_env: (
MLSRuntimeENV
) 클라이언트가 실행되는 환경 (MLSRuntimeENV.YE
|MLSRuntimeENV.LOCAL
) (기본값:MLSRuntimeENV.LOCAL
)
아래의 환경 변수가 정의된 경우 해당 파라미터를 생략 가능합니다.
- $MLS_ENV: env
- $AWS_ENV: env
- $MLS_RUNTIME_ENV: runtime_env
Returns
MLSConversionTrackingAPIClient
Example
conversion_tracking_api_client = MLSConversionTrackingAPIClient(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 request(self, user_id: str, channel_id: str, conversion_type: str, process_id: str, item_id: str) ‑> Dict[str, Any]
-
MLS Conversion Tracking API를 호출합니다.
Args
- user_id: (str) 추천 요청의 user ID (해시된 서비스관리번호)
- channel_id: (str) 추천 요청 또는 응답의 channel ID
- conversion_type: (str) 이벤트 타입(
impression
|click
|detail_view
|like
|dislike
) - process_id: (str) 추천 결과 응답의 process ID
- item_id : (str) 추천 결과 응답의 item_id
Returns
dict
Example
conversion_tracking_dict = conversion_tracking_api_client.request( user_id=hashlib.sha256("1234567890".encode()).hexdigest(), channel_id="sample_channel", conversion_type="impression", process_id="sample_process", item_id="sample_item", )
async def request_async(self, user_id: str, channel_id: str, conversion_type: str, process_id: str, item_id: str) ‑> Dict[str, Any]
-
MLS Conversion Tracking API를 비동기 호출합니다.
Args
- user_id: (str) 추천 요청의 user ID (해시된 서비스관리번호)
- channel_id: (str) 추천 요청 또는 응답의 channel ID
- conversion_type: (str) 이벤트 타입(
impression
|click
|detail_view
|like
|dislike
) - process_id: (str) 추천 결과 응답의 process ID
- item_id : (str) 추천 결과 응답의 item_id
Returns
dict
Example
conversion_tracking_dict = await conversion_tracking_api_client.request_async( user_id=hashlib.sha256("1234567890".encode()).hexdigest(), channel_id="sample_channel", conversion_type="impression", process_id="sample_process", item_id="sample_item", )
- client_id: (str) 호출 클라이언트 (
class MLSGraphAPIClient (env: MLSENV = None, runtime_env: MLSRuntimeENV = None)
-
MLS 그래프 API를 호출할 수 있는 클라이언트입니다.
EDD 환경은 지원하지 않습니다.
Args
- env: (
MLSENV
) 접근할 MLS 환경 (MLSENV.DEV
|MLSENV.STG
|MLSENV.PRD
) (기본값:MLSENV.STG
) - runtime_env: (
MLSRuntimeENV
) 클라이언트가 실행되는 환경 (MLSRuntimeENV.YE
|MLSRuntimeENV.MMS
|MLSRuntimeENV.LOCAL
) (기본값:MLSRuntimeENV.LOCAL
)
아래의 환경 변수가 정의된 경우 해당 파라미터를 생략 가능합니다.
- $MLS_ENV: env
- $AWS_ENV: env
- $MLS_RUNTIME_ENV: runtime_env
Returns
Example
graph_api_client = MLSGraphAPIClient(env=MLSENV.STG, runtime_env=MLSRuntimeENV.YE)
Methods
def add_edge(self, frm: str, to: str, label: str, properties: Dict[str, Any] = {}) ‑> Edge
-
Edge를 추가합니다.
Args
- frm: (str) Source Vertex의 고유 ID
- to: (str) Target Vertex의 고유 ID
- label: (str) Edge의 라벨
- properties: (dict) Edge의 property 키와 값
Returns
Example
edge = graph_api_client.add_edge( frm="USER001", to="USER002", label="follows", properties={ "weight": 3, "hello": "world", } )
async def add_edge_async(self, frm: str, to: str, label: str, properties: Dict[str, Any] = {}) ‑> Edge
-
Edge를 추가합니다.
Args
- frm: (str) Source Vertex의 고유 ID
- to: (str) Target Vertex의 고유 ID
- label: (str) Edge의 라벨
- properties: (dict) Edge의 property 키와 값
Returns
Example
edge = await graph_api_client.add_edge_async( frm="USER001", to="USER002", label="follows", properties={ "weight": 3, "hello": "world", } )
def add_vertex(self, vertex_id: str, label: str, properties: Dict[str, Any] = {}) ‑> Vertex
-
Vertex를 추가합니다.
Args
- vertex_id: (str) Vertex의 고유 ID
- label: (str) Vertex의 라벨
- properties: (dict) Vertex의 property 키와 값
Returns
Example
vertex = graph_api_client.add_vertex( vertex_id="USER001", label="user", properties={ "name": "김유저", "age": 30, } )
async def add_vertex_async(self, vertex_id: str, label: str, properties: Dict[str, Any] = {}) ‑> Vertex
-
Vertex를 추가합니다.
Args
- vertex_id: (str) Vertex의 고유 ID
- label: (str) Vertex의 라벨
- properties: (dict) Vertex의 property 키와 값
Returns
Example
vertex = await graph_api_client.add_vertex_async( vertex_id="USER001", label="user", properties={ "name": "김유저", "age": 30, } )
def drop_edge(self, edge_id: str) ‑> NoneType
-
단일 Edge를 삭제합니다.
Args
- edge_id: (str) Edge의 고유 ID. 보통은
{source_vertex_id}_{label}_{target_vertex_id}
형식을 따릅니다.
Example
edge = graph_api_client.drop_edge("USER001_follows_USER002")
- edge_id: (str) Edge의 고유 ID. 보통은
async def drop_edge_async(self, edge_id: str) ‑> NoneType
-
단일 Edge를 삭제합니다.
Args
- edge_id: (str) Edge의 고유 ID. 보통은
{source_vertex_id}_{label}_{target_vertex_id}
형식을 따릅니다.
Example
edge = await graph_api_client.drop_edge_async("USER001_follows_USER002")
- edge_id: (str) Edge의 고유 ID. 보통은
def drop_edges(self, query_params: Dict[str, Union[str, List[str]]] = {}) ‑> NoneType
-
조건에 해당하는 모든 Edge를 삭제합니다.
Args
- query_params: (optional) (dict) 쿼리 파라미터. 아래 예시 참조 (기본값: {})
- {property_name}={value}: Vertex.Properties[property_name] == str(value)
- {property_name}__{operator}
- eq, gt, gte, lt, lte: Vertex.Properties[property_name] {operator} float(value)
- bw: {property_name}__bw={value1},{value2}: float(value1) < Vertex.Properties[property_name] < float(value2)
Example
# `hello` property가 `world`값을 가지며 `weight` property가 3보다 큰 Edge를 삭제하기 edges = graph_api_client.delete_edges(query_params={ "hello": "world", "weight__gte": 3, })
- query_params: (optional) (dict) 쿼리 파라미터. 아래 예시 참조 (기본값: {})
async def drop_edges_async(self, query_params: Dict[str, Union[str, List[str]]] = {}) ‑> NoneType
-
조건에 해당하는 모든 Edge를 삭제합니다.
Args
- query_params: (optional) (dict) 쿼리 파라미터. 아래 예시 참조 (기본값: {})
- {property_name}={value}: Vertex.Properties[property_name] == str(value)
- {property_name}__{operator}
- eq, gt, gte, lt, lte: Vertex.Properties[property_name] {operator} float(value)
- bw: {property_name}__bw={value1},{value2}: float(value1) < Vertex.Properties[property_name] < float(value2)
Example
# `hello` property가 `world`값을 가지며 `weight` property가 3보다 큰 Edge를 삭제하기 edges = await graph_api_client.delete_edges_async(query_params={ "hello": "world", "weight__gte": 3, })
- query_params: (optional) (dict) 쿼리 파라미터. 아래 예시 참조 (기본값: {})
def drop_vertex(self, vertex_id: str) ‑> NoneType
-
단일 Vertex를 삭제합니다. 연결된 Edge들 역시 삭제됩니다.
Args
- vertex_id: (str) Vertex의 고유 ID
Example
vertex = graph_api_client.drop_vertex("USER001")
async def drop_vertex_async(self, vertex_id: str) ‑> NoneType
-
단일 Vertex를 삭제합니다. 연결된 Edge들 역시 삭제됩니다.
Args
- vertex_id: (str) Vertex의 고유 ID
Example
vertex = await graph_api_client.drop_vertex_async("USER001")
def drop_vertices(self, query_params: Dict[str, Union[str, List[str]]] = {}) ‑> NoneType
-
조건에 해당하는 모든 Vertex를 삭제합니다.
Args
- query_params: (optional) (dict) 쿼리 파라미터. 아래 예시 참조 (기본값: {})
- {property_name}={value}: Vertex.Properties[property_name] == str(value)
- {property_name}__{operator}
- eq, gt, gte, lt, lte: Vertex.Properties[property_name] {operator} float(value)
- bw: {property_name}__bw={value1},{value2}: float(value1) < Vertex.Properties[property_name] < float(value2)
Example
# `hello` property가 `world`값을 가지며 `latitude` property가 33보다 큰 Vertex를 삭제하기 vertices = graph_api_client.delete_vertices(query_params={ "hello": "world", "latitude__gte": 33, })
- query_params: (optional) (dict) 쿼리 파라미터. 아래 예시 참조 (기본값: {})
async def drop_vertices_async(self, query_params: Dict[str, Union[str, List[str]]] = {}) ‑> NoneType
-
조건에 해당하는 모든 Vertex를 삭제합니다.
Args
- query_params: (optional) (dict) 쿼리 파라미터. 아래 예시 참조 (기본값: {})
- {property_name}={value}: Vertex.Properties[property_name] == str(value)
- {property_name}__{operator}
- eq, gt, gte, lt, lte: Vertex.Properties[property_name] {operator} float(value)
- bw: {property_name}__bw={value1},{value2}: float(value1) < Vertex.Properties[property_name] < float(value2)
Example
# `hello` property가 `world`값을 가지며 `latitude` property가 33보다 큰 Vertex를 삭제하기 vertices = await graph_api_client.delete_vertices_async(query_params={ "hello": "world", "latitude__gte": 33, })
- query_params: (optional) (dict) 쿼리 파라미터. 아래 예시 참조 (기본값: {})
def get_edge(self, edge_id: str) ‑> Edge
-
단일 Edge를 가져옵니다.
Args
- edge_id: (str) Edge의 고유 ID. 보통은
{source_vertex_id}_{label}_{target_vertex_id}
형식을 따릅니다.
Returns
Example
edge = graph_api_client.get_edge("USER001_follows_USER002")
- edge_id: (str) Edge의 고유 ID. 보통은
async def get_edge_async(self, edge_id: str) ‑> Edge
-
단일 Edge를 가져옵니다.
Args
- edge_id: (str) Edge의 고유 ID. 보통은
{source_vertex_id}_{label}_{target_vertex_id}
형식을 따릅니다.
Returns
Example
edge = await graph_api_client.get_edge_async("USER001_follows_USER002")
- edge_id: (str) Edge의 고유 ID. 보통은
def get_env(self) ‑> MLSENV
def get_runtime_env(self) ‑> MLSRuntimeENV
def get_vertex(self, vertex_id: str) ‑> Vertex
-
단일 Vertex를 가져옵니다.
Args
- vertex_id: (str) Vertex의 고유 ID
Returns
Example
vertex = graph_api_client.get_vertex("USER001")
async def get_vertex_async(self, vertex_id: str) ‑> Vertex
-
단일 Vertex를 가져옵니다.
Args
- vertex_id: (str) Vertex의 고유 ID
Returns
Example
vertex = await graph_api_client.get_vertex_async("USER001")
def list_edges(self, query_params: Dict[str, Union[str, List[str]]] = {}) ‑> List[Edge]
-
조건에 해당하는 모든 Edge의 리스트를 가져옵니다. 300개를 초과하는 경우 300개까지만 가져옵니다.
Args
- query_params: (optional) (dict) 쿼리 파라미터. 아래 예시 참조 (기본값: {})
- {property_name}={value}: Vertex.Properties[property_name] == str(value)
- {property_name}__{operator}
- eq, gt, gte, lt, lte: Vertex.Properties[property_name] {operator} float(value)
- bw: {property_name}__bw={value1},{value2}: float(value1) < Vertex.Properties[property_name] < float(value2)
Returns
list(
Edge
)Example
# 모든 Edge 가져오기 (최대 300개로 제한) edges = graph_api_client.list_edges() # `hello` property가 `world`값을 가지며 `weight` property가 3보다 큰 Edge를 가져오기 edges = graph_api_client.list_edges(query_params={ "hello": "world", "weight__gte": 33, })
- query_params: (optional) (dict) 쿼리 파라미터. 아래 예시 참조 (기본값: {})
async def list_edges_async(self, query_params: Dict[str, Union[str, List[str]]] = {}) ‑> List[Edge]
-
조건에 해당하는 모든 Edge의 리스트를 가져옵니다. 300개를 초과하는 경우 300개까지만 가져옵니다.
Args
- query_params: (optional) (dict) 쿼리 파라미터. 아래 예시 참조 (기본값: {})
- {property_name}={value}: Vertex.Properties[property_name] == str(value)
- {property_name}__{operator}
- eq, gt, gte, lt, lte: Vertex.Properties[property_name] {operator} float(value)
- bw: {property_name}__bw={value1},{value2}: float(value1) < Vertex.Properties[property_name] < float(value2)
Returns
list(
Edge
)Example
# 모든 Edge 가져오기 (최대 300개로 제한) edges = await graph_api_client.list_edges_async() # `hello` property가 `world`값을 가지며 `weight` property가 3보다 큰 Edge를 가져오기 edges = await graph_api_client.list_edges_async(query_params={ "hello": "world", "weight__gte": 33, })
- query_params: (optional) (dict) 쿼리 파라미터. 아래 예시 참조 (기본값: {})
def list_vertices(self, query_params: Dict[str, Union[str, List[str]]] = {}) ‑> List[Vertex]
-
조건에 해당하는 모든 Vertex의 리스트를 가져옵니다. 300개를 초과하는 경우 300개까지만 가져옵니다.
Args
- query_params: (optional) (dict) 쿼리 파라미터. 아래 예시 참조 (기본값: {})
- {property_name}={value}: Vertex.Properties[property_name] == str(value)
- {property_name}__{operator}
- eq, gt, gte, lt, lte: Vertex.Properties[property_name] {operator} float(value)
- bw: {property_name}__bw={value1},{value2}: float(value1) < Vertex.Properties[property_name] < float(value2)
Returns
list(
Vertex
)Example
# 모든 Vertex 가져오기 (최대 300개로 제한) vertices = graph_api_client.list_vertices() # `hello` property가 `world`값을 가지며 `latitude` property가 33보다 큰 Vertex를 가져오기 vertices = graph_api_client.list_vertices(query_params={ "hello": "world", "latitude__gte": 33, })
- query_params: (optional) (dict) 쿼리 파라미터. 아래 예시 참조 (기본값: {})
async def list_vertices_async(self, query_params: Dict[str, Union[str, List[str]]] = {}) ‑> List[Vertex]
-
조건에 해당하는 모든 Vertex의 리스트를 가져옵니다. 300개를 초과하는 경우 300개까지만 가져옵니다.
Args
- query_params: (optional) (dict) 쿼리 파라미터. 아래 예시 참조 (기본값: {})
- {property_name}={value}: Vertex.Properties[property_name] == str(value)
- {property_name}__{operator}
- eq, gt, gte, lt, lte: Vertex.Properties[property_name] {operator} float(value)
- bw: {property_name}__bw={value1},{value2}: float(value1) < Vertex.Properties[property_name] < float(value2)
Returns
list(
Vertex
)Example
# 모든 Vertex 가져오기 (최대 300개로 제한) vertices = await graph_api_client.list_vertices_async() # `hello` property가 `world`값을 가지며 `latitude` property가 33보다 큰 Vertex를 가져오기 vertices = await graph_api_client.list_vertices_async(query_params={ "hello": "world", "latitude__gte": 33, })
- query_params: (optional) (dict) 쿼리 파라미터. 아래 예시 참조 (기본값: {})
def update_edge(self, edge_id: str, properties: Dict[str, Any] = {}) ‑> Edge
-
단일 Edge의 property를 업데이트합니다.
Args
- edge_id: (str) Edge의 고유 ID. 보통은
{source_vertex_id}_{label}_{target_vertex_id}
형식을 따릅니다. - properties: (dict) Edge의 property 키와 값
Returns
Example
edge = graph_api_client.update_edge( edge_id="USER001_follows_USER002", properties={ "weight": 5, } )
- edge_id: (str) Edge의 고유 ID. 보통은
async def update_edge_async(self, edge_id: str, properties: Dict[str, Any] = {}) ‑> Edge
-
단일 Edge의 property를 업데이트합니다.
Args
- edge_id: (str) Edge의 고유 ID. 보통은
{source_vertex_id}_{label}_{target_vertex_id}
형식을 따릅니다. - properties: (dict) Edge의 property 키와 값
Returns
Example
edge = await graph_api_client.update_edge_async( edge_id="USER001_follows_USER002", properties={ "weight": 5, } )
- edge_id: (str) Edge의 고유 ID. 보통은
def update_vertex(self, vertex_id: str, properties: Dict[str, Any] = {}) ‑> Vertex
-
단일 Vertex의 property를 업데이트합니다.
Args
- vertex_id: (str) Vertex의 고유 ID
- properties: (dict) Vertex의 property 키와 값
Returns
Example
vertex = graph_api_client.update_vertex( vertex_id="USER001", properties={ "age": 35, } )
async def update_vertex_async(self, vertex_id: str, properties: Dict[str, Any] = {}) ‑> Vertex
-
단일 Vertex의 property를 업데이트합니다.
Args
- vertex_id: (str) Vertex의 고유 ID
- properties: (dict) Vertex의 property 키와 값
Returns
Example
vertex = await graph_api_client.update_vertex_async( vertex_id="USER001", properties={ "age": 35, } )
- env: (
class MLSProfileAPIClient (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
profile_api_client = MLSProfileAPIClient(env=MLSENV.STG, runtime_env=MLSRuntimeENV.YE)
Methods
def get_env(self) ‑> MLSENV
def get_item_profile(self, profile_id: str, item_id: str, keys: List[str] = None) ‑> Dict[str, Any]
-
MLS Item Profile API를 호출합니다.
Args
- profile_id: (str) 호출할 프로파일 ID
- item_id: (str) 아이템 고유 ID
- keys: (optional) (list(str)) 조회할 키 리스트 (기본값: None, 기본값 전달시 모든 키 조회)
Returns
dict
Example
item_profile_dict = profile_api_client.get_item_profile( profile_id="device", item_id="item001", keys=["price", "resolution"] )
async def get_item_profile_async(self, profile_id: str, item_id: str, keys: List[str] = None) ‑> Dict[str, Any]
-
MLS Item Profile API를 비동기로 호출합니다.
Args
- profile_id: (str) 호출할 프로파일 ID
- item_id: (str) 아이템 고유 ID
- keys: (optional) (list(str)) 조회할 키 리스트 (기본값: None, 기본값 전달시 모든 키 조회)
Returns
dict
Example
item_profile_dict = await profile_api_client.get_item_profile_async( profile_id="device", item_id="item001", keys=["price", "resolution"] )
def get_profile(self, profile_id: str, id: str, keys: List[str] = None) ‑> Dict[str, Any]
-
MLS 통합 Profile API를 호출합니다.
Args
- profile_id: (str) 호출할 프로파일 ID
- id: (str) 조회할 ID
Returns
dict
Example
profile_dict = profile_api_client.get_profile( profile_id="default", target_id="001", keys=["age", "gender"] )
async def get_profile_async(self, profile_id: str, id: str, keys: List[str] = None) ‑> Dict[str, Any]
-
MLS 통합 Profile API를 비동기로 호출합니다.
Args
- profile_id: (str) 호출할 프로파일 ID
- id: (str) 조회할 ID
Returns
dict
Example
profile_dict = await profile_api_client.get_profile_async( profile_id="default", target_id="001", keys=["age", "gender"] )
def get_runtime_env(self) ‑> MLSRuntimeENV
def get_user_profile(self, profile_id: str, user_id: str, keys: List[str] = None) ‑> Dict[str, Any]
-
MLS User Profile API를 호출합니다.
Args
- profile_id: (str) 호출할 프로파일 ID
- user_id: (str) 해시된 유저 고유 ID (해시된 서비스관리번호)
- keys: (optional) (list(str)) 조회할 키 리스트 (기본값: None, 기본값 전달시 모든 키 조회)
Returns
dict
Example
user_profile_dict = profile_api_client.get_user_profile( profile_id="default", user_id=hashlib.sha256("1234567890".encode()).hexdigest(), keys=["age", "gender"] )
async def get_user_profile_async(self, profile_id: str, user_id: str, keys: List[str] = None) ‑> Dict[str, Any]
-
MLS User Profile API를 비동기로 호출합니다.
Args
- profile_id: (str) 호출할 프로파일 ID
- user_id: (str) 해시된 유저 고유 ID (해시된 서비스관리번호)
- keys: (optional) (list(str)) 조회할 키 리스트 (기본값: None, 기본값 전달시 모든 키 조회)
Returns
dict
Example
user_profile_dict = await profile_api_client.get_user_profile_async( profile_id="default", user_id=hashlib.sha256("1234567890".encode()).hexdigest(), keys=["age", "gender"] )
- env: (
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: (
class Vertex (**kwargs)
-
GraphDB의 Vertex 클래스입니다.
Args
- kwargs
- id: (str) Vertex 고유 ID
- label: (str) Vertex 라벨
- properties: (dict) Vertex property 값들
Returns
Methods
def get(self)
- kwargs