API Objects

Object/Context Pairs

The standard response structure for MediaHound objects.

Overview

Within the content array that is standard for most endpoints, you will find what we refer to as Object/Context pairs. Anytime the API returns an object, it will be inside of an Object/Context Pair. These pairs are used to split and illustrate objects that are static versus information about those objects in the context of the call that was just made.

Copy
JSON
"content": [
  "object": {},
  "context": {}
]

Property Summary

PropertyDescription
objectThe Object is the main element you requested. Objects can be cached as they rarely change.
contextThe Context represents information about the relationship between the Object, and the parent object that this content array existed inside of. Context data should not be cached. It contains information such as sorting data or roles.

An Example

Below we have the actual response for a Lookup request for the ID of Gladiator with the Components of contributors:

Copy
JSON
{
  "content": [
    {
      "object": {
        "mhid": "mhmovPeR81SeVnIPqEFsr36NYUqfqHuXzO9lDuQkq72G",
        "name": "Gladiator",
        "altId": "mhmov-gladiator",
        "releaseDate": 946684800,
        "description": "A disgraced Roman general, played by Russell Crowe, is forced to fight in the iconic Coliseum as a gladiator for the entertainment of the people, and the man responsible for his downfall.",
        "contributors": {
          "content": [
            {
              "object": {
                "mhid": "mhricdHv2eCnYem0LZ5rNMCgBOesPtPAxPbwhNd9Pvub",
                "name": "Ridley Scott",
                "altId": "mhric-ridley-scott"
              },
              "context": {
                "sorting": {
                  "position": 1
                },
                "relationships": [
                  {
                    "contribution": "Director"
                  },
                  {
                    "contribution": "Producer"
                  }
                ]
              }
            },
            {
              "object": {
                "mhid": "mhricPM4FE1LAJ4HoahHtcEXfXISghonBm1xqdwbQfyJ",
                "name": "Russell Crowe",
                "altId": "mhric-russell-crowe"
              },
              "context": {
                "sorting": {
                  "position": 2
                },
                "relationships": [
                  {
                    "contribution": "Cast",
                    "role": "Maximus"
                  }
                ]
              }
            },
            {
              "object": {
                "mhid": "mhricy1v4gGapcEcyCd1YWfMQea7VhdQFj0KHrnlEV6N",
                "name": "Joaquin Phoenix",
                "altId": "mhric-joaquin-phoenix"
              },
              "context": {
                "sorting": {
                  "position": 3
                },
                "relationships": [
                  {
                    "contribution": "Cast",
                    "role": "Commodus"
                  }
                ]
              }
            },
            {
              "object": {
                "mhid": "mhric0ehJSnDfAkPbUiIbdL9eR6YwKFlvuaoUDtS7qo8",
                "name": "Connie Nielsen",
                "altId": "mhric-connie-nielsen"
              },
              "context": {
                "sorting": {
                  "position": 4
                },
                "relationships": [
                  {
                    "contribution": "Cast",
                    "role": "Lucilla"
                  }
                ]
              }
            },
            {
              "object": {
                "mhid": "mhricx7OJojMdAP5Shne5Hbu57bweBIlcPq26FvVYUQC",
                "name": "Oliver Reed",
                "altId": "mhric-oliver-reed"
              },
              "context": {
                "sorting": {
                  "position": 5
                },
                "relationships": [
                  {
                    "contribution": "Cast",
                    "role": "Proximo"
                  }
                ]
              }
            }
          ],
          "pagingInfo": {
            "next": "https://api.mediahound.com/1.3/graph/lookup/mhmovPeR81SeVnIPqEFsr36NYUqfqHuXzO9lDuQkq72G/contributors?params=%7B%22page%22%3A1%2C%22pageSize%22%3A5%2C%22components%22%3A%5B%7B%22name%22%3A%22metadata%22%2C%22components%22%3A%5B%5D%7D%5D%7D",
            "previous": null
          }
        }
      },
      "context": {}
    }
  ],
  "pagingInfo": {
    "next": null,
    "previous": null
  }
}

As you can see, we get back a content array containing the Gladiator object, which internally contains another content array under contributors. This is where context comes into play:

Each Contributor in the contributors array has both an Object and Context. In our example, the first Object is Ridley Scott's information. The first Context is information about how Ridley Scott contributed to the Movie Gladiator. Information returned inside of Context objects is always only relevant for the current structure of the data. Ridley Scott was not the Director and Producer of every piece of Media he has ever contributed in!