User Interactions

Create One Interaction

POST users/<str:user_id>/interactions/<str:item_id>/

Note

Authorized Roles: root, manager, backend, frontend

This endpoint allows you to create a new interaction for a user and an item. An inferred rating will be created or updated for the tuple (user_id, item_id). The taste profile of the user will then be updated in real-time by the online machine learning algorithm.

Request JSON Object
  • interaction_type (string) – [max-length: 64] Interaction type

  • timestamp (float64) – Optional. [min: -150000000000.0 (year -2786) max: 3500000000.0 (year 2080)] Interaction timestamp (default: now)

EXAMPLE QUERY BODY
  {
      "interaction_type": "productView",
      "timestamp": 1588812345
  }

Errors:

  • ServerUnavailable with error name DB_IMPLICIT_TO_EXPLICIT_PARAMS_NOT_FOUND if no “implicit-to-explicit” parameters have been set for this database

Create Interactions for Many Users in Bulk

POST interactions-bulk/

Note

Authorized Roles: root, manager, backend

Create or update large bulks of interactions for many users and many items. Inferred ratings will be created or updated for all tuples (user_id, item_id).

Request JSON Object
  • interactions (object-array) –

    Interactions array

    Inner fields:

    • user_id (ID) – [see Flexible Identifiers] User ID

    • item_id (ID) – [see Flexible Identifiers] Item ID

    • interaction_type (O) – [max-len:64chars] Interaction type

    • timestamp (float64) – [min: -150000000000.0 (year -2786) max: 3500000000.0 (year 2080)] Interaction timestamp

EXAMPLE QUERY BODY
  {
      "interactions": [
          {"user_id": 1234, "item_id": "123e4567-e89b-12d3-a456-426614174000", "interaction_type": "productView", "timestamp": 1588812345},
          {"user_id": 1234, "item_id": "c3391d83-553b-40e7-818e-fcf658ec397d", "interaction_type": "productView", "timestamp": 1588854321},
          {"user_id": 333, "item_id": "c3391d83-553b-40e7-818e-fcf658ec397d", "interaction_type": "addToCart", "timestamp": 1588811111},
      ]
  }

Errors:

  • ServerUnavailable with error name DB_IMPLICIT_TO_EXPLICIT_PARAMS_NOT_FOUND if no “implicit-to-explicit” parameters have been set for this database

List Interactions for All Users In Bulk

GET interactions-bulk/

Note

Authorized Roles: root, manager, backend

This endpoint allows you to list the interactions of one database. The response is paginated, you can control the response amount and offset using the query parameters amt and cursor.

Query Parameters
  • amt (int) – Optional. [min: 1] Amount of interactions to return

  • cursor (string) – Optional. Pagination cursor, typically from the next_cursor value from the previous response

EXAMPLE QUERY PARAMS
  ?amt=10&cursor=F25pU1vHb1LjSEp...
Response JSON Object
  • interactions (object-array) –

    Interactions array

    Inner fields:

    • user_id (ID) – [see Flexible Identifiers] User ID

    • item_id (ID) – [see Flexible Identifiers] Item ID

    • interaction_type (O) – [max-len:64chars] Interaction type

    • timestamp (float64) – [min: -150000000000.0 (year -2786) max: 3500000000.0 (year 2080)] Interaction timestamp

  • has_next (bool) – Indicates whether or not there are more interactions to request

  • next_cursor (string) – Pagination cursor to use in next request to get more interactions

EXAMPLE RESPONSE
  {
      "has_next": true,
      "next_cursor": "Q21vU1pHb1FjSEp...",
      "interactions": [
          {"user_id": 1234, "item_id": "123e4567-e89b-12d3-a456-426614174000", "interaction_type": "productView", "timestamp": 1588812345},
          {"user_id": 1234, "item_id": "c3391d83-553b-40e7-818e-fcf658ec397d", "interaction_type": "addToCart", "timestamp": 1588854321},
          {"user_id": 333, "item_id": "c3391d83-553b-40e7-818e-fcf658ec397d", "interaction_type": "productView", "timestamp": 1588811111},
      ]
  }