ApiClient.interaction
The Interaction APIs let you manage your interaction records stored with Miso.
ApiClient.interaction.upload()
Insert user Interaction records, and engine will be trained to fit user behavior.
Example
from miso.sdk import ApiClient
api_client = ApiClient(api_key="{api_key}")
interactions = [
# First interaction
{
"user_id":"f5df9ef",
"type":"search",
"search": {
"keywords": "chips",
},
"timestamp": "2023-01-24T14:15:21Z",
},
# Second interaction, from another user
{
"type": "product_detail_page_view",
"duration": 61.5,
"product_ids": [
"123ABC-BLACK"
],
"product_group_ids": [
"123ABC"
],
"user_id": "5b09700",
"anonymous_id": "86D51273AD8BF84217E1567B6CBE7152D7034404",
"timestamp": "2023-01-24T14:15:22Z",
"miso_id": "123e4567-e89b-12d3-a456-426614174000",
"context": {
"campaign": {
"name": "spring_sale",
"source": "Google",
"medium": "cpc",
"term": "running+shoes",
"content": "textlink"
},
"truncated_ip": "1.1.1.0",
"locale": "en-US",
"region": "US East",
"page": {
"url": "https://example.com/miso-tshirt-123ABC",
"referrer": "https://example.com/",
"title": "My Product Page"
},
"user_agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0",
"custom_context": {
"session_variable_1": [
"value_1",
"value_2"
]
}
}
},
]
api_client.interaction.upload(data=interactions)
Parameters
Name | Type | Description |
---|---|---|
data |
dict | List of user interactions. |
data
is a list of dictionaries, each dictionary represents a single user interaction.
For different interaction types, different fields can be used:
Return Value
A dictionary of returned result with following properties:
Name | Type | Description |
---|---|---|
errors |
bool | Upload successed or failed. |
message |
str | Summarized message. |
data |
list[str] | Detail for each error happend. |
ApiClient.interaction.delete()
Delete interaction data for specified users.
This function should be when receiving data removal request from users (right to be forgotten).
Example
Request
from miso.sdk import ApiClient
api_client = ApiClient(api_key="{api_key}")
user_ids = ["5b09700", "f5df9ef", "2bc5d3f"]
response = api_client.interaction.delete(user_ids=user_ids)
Parameters
Name | Type | Description |
---|---|---|
user_ids |
list[str] | List of user IDs to be removed. |
Return Value
Name | Type | Description |
---|---|---|
message |
str | Summarized message. |
Learn more
For advanced usage and extra parameters, see REST API for detail.