Searching by Metadata

Many SHIFT users enrich their media with metadata. You can use your metadata when searching for your media.

Searching for a specific key and value

The most common case is to search for your files that contain a specific metadata key and value. For this example let's find any files with a location of "Catalina".

curl --request GET \
  --url https://api.shift.io/v3/assets?_query={"and": [{"metadata.key": {"eq": "location"}}, {"metadata.value": {"eq": "Catalina"}}]} \
  --header 'accept: application/json' \
  --header 'x-key: YOUR_API_KEY' \
  --header 'x-secret: YOUR_API_SECRET'

Searching for a combination of metadata

It's also common to need to search for assets that have a combination of metadata key values. Searching for just one pair may not be enough. Let's find all files with a location of Catalina and that were directed by "Michael Chapel".

curl --request GET \
  --url https://api.shift.io/v3/assets?_query={"and": [{"and": [{"metadata.key": {"eq": "location"}}, {"metadata.value": {"eq": "Catalina"}}]}, {"and": [{"metadata.key": {"eq": "director"}}, {"metadata.value": {"eq": "Michael Chapel"}}]}]} \
  --header 'accept: application/json' \
  --header 'x-key: YOUR_API_KEY' \
  --header 'x-secret: YOUR_API_SECRET'

This query is a bit large. Let's looks at it pretty printed.

{
    "and": [{
        "and": [{
            "metadata.key": {
                "eq": "location"
            }
        }, {
            "metadata.value": {
                "eq": "Catalina"
            }
        }]
    }, {
        "and": [{
            "metadata.key": {
                "eq": "director"
            }
        }, {
            "metadata.value": {
                "eq": "Michael Chapel"
            }
        }]
    }]
}

Did this page help you?