Examples

Relate Examples

Examples of the JSON sent to the params argument of the Relate endpoint.

For more information, read about the Relate endpoint.

Example One

In this example, we'll simulate the DateNight experience with two Movies and a Source filter. The request accepts two Factors indicating what the recommendations should be based upon, and then we control the outcome by:

  • Setting the ReturnType to Movies.
  • Specifying that the results must be available on iTunes or Google Play.
{
"factors": [
{
"id": "mhmov-gladiator"
},
{
"id": "mhmov-the-notebook"
}
],
"filters": {
"returnType": {
"$eq": "Movie"
},
"sources": {
"$in": ["mhsrc-itunes", "mhsrc-googleplay"]
}
}
}

Example Two

In this example, we ask for personalized Movie recommendations for a User, and we customize the response by asking for:

  • The Primary Image of each recommended Movie.
  • The Source availability.
{
"factors": [{ "id": "mhals-current-user" }],
"filters": {
"returnType": {
"$eq": "Movie"
}
},
"components": [{ "name": "primaryImage" }, { "name": "sources" }]
}

Example Three

In this example, we are looking for Movies like Gladiator, in an order personalized for the User. This is accomplished via the boostOnly flag. boostOnly Factors don’t contribute Traits like normal Factors. Instead, they increase only the value of traits in common with Gladiator. Additionally, we will request:

  • All Movies must be available on iTunes.
  • The Primary Image of each Movie.
  • Each Movie's Key Contributors.
{
"factors": [
{
"id": "mhals-current-user",
"boostOnly": "true"
},
{
"id": "mhmov-gladiator"
}
],
"filters": {
"returnType": {
"$eq": "Movie"
},
"source": {
"$eq": "mhsrc-itunes"
}
},
"components": [{ "name": "primaryImage" }, { "name": "keyContributors" }]
}