Examples

Explore Examples

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

For more information, read about the Explore endpoint.

Example One

In this example, we'll ask for both Movies and ShowSeries that:

  • Have George Clooney in them.
  • Are available on iTunes or Google Play.
  • Are not in the User's Watched List Collection.

We'll also request a Primary Image for each result:

Copy
JSON
{
  "filters": {
    "returnType": {
      "$in": [
        "Movie",
        "ShowSeries"
      ]
    },
    "contributors": {
      "$eq": "mhric-george-clooney"
    },
    "sources": {
      "$in": [
        "mhsrc-itunes",
        "mhsrc-googleplay"
      ]
    },
    "collections": {
      "$ne": "mhcol-examplewatchedlist"
    }
  },
  "components": [
    "primaryImage"
  ]
}

We have used the $ne boolean operator in the collections filter to indicate that we want to prohibit elements contained in that Collection. This is a convenient way to hide elements that a User has already seen via a Collection your app can maintain.

Example Two

In this example, we'll ask for Movies that:

  • Have the Traits, Exciting and Heist.
  • Have either both George Clooney and Matt Damon, OR both Edward Norton and Mark Wahlberg.
Copy
JSON
{
  "filters": {
    "returnType": {
      "$eq": "Movie"
    },
    "traits": {
      "$all": [
        "mhmod-exciting",
        "mhsgn-heist"
      ]
    },
    "contributors": {
      "$or": [
        {
          "$all": [
            "mhric-george-clooney",
            "mhric-matt-damon"
          ]
        },
        {
          "$all": [
            "mhric-edward-norton",
            "mhric-mark-wahlberg"
          ]
        }
      ]
    }
  }
}

Why you would need this specific request is anyone's guess, but the point is that you can express arbitrarily complex relationships with HQL and we'll still answer your questions.

No Components are specified here, which means you will get just the default metadata for the top-level results.

Example Three

In this example, we'll look at one of the inverted filters: contributorsOf. ContributorsOf is the inversion of contributors.

We ask for:

  • Contributors that contributed to the Content, Gladiator.
  • The Primary Images of each of those top-level Contributors.
  • Each Contributor's Contributions and the Primary Images of each of those Contributions.

We'll also use sort to order our results alphabetically:

Copy
JSON
{
  "filters": {
    "returnType": {
      "$eq": "Contributor"
    },
    "contributorsOf": {
      "$eq": "mhmov-gladiator"
    }
  },
  "sort": [
    {
      "type": "property",
      "property": "name",
      "order": "ascending"
    }
  ],
  "components": [
    "primaryImage",
    {
      "name": "contributions",
      "components": [
        "primaryImage"
      ]
    }
  ]
}