Searching and Filtering Assets

Assumptions

search for assets

In order to search for assets based on a string, just like in the portal, you only need to use the retrieve assets call, with the keyword parameter populated.

Example

In order to retrieve the same results as shown above, you will have to make the following call:

HTTP Parameter Value
HTTP Method GET
URL https://byndair.getbynder.com/api/v4/media/?keyword=mountain
Headers Authorization : OAuth version 1.0 generated authorization header

Filter using dates

filter on last week's assets

A common scenario for filtering is retrieving the most recent assets. In the current example we are going to get only the assets that were created during the past week. To do so, just like as shown in the portal, you only need to use the retrieve assets call with the dateCreated parameter populated with the day of one week earlier.

Augmenting on this example, to pick the assets that were created or modified within a specific range of dates, you can use:

Example

To retrieve the same results as shown above, you will have to make the following call:

HTTP Parameter Value
HTTP Method GET
URL https://byndair.getbynder.com/api/v4/media/?dateCreated=2017-03-20T00:00:00Z
Headers Authorization : OAuth version 1.0 generated authorization header

Filter using metaproperties

filter with metaproperties

Filtering assets using metaproperties is something that will be expected to be done by your application, since it contains the main custom filters that have been created in your Bynder portal.

However, you should know which options are available before retrieving your assets. To make this functionality possilbe, you have to follow a 2 steps process:

  1. Build your metaproperty filters using the retrieve metaproperties call (this is something that you may want to cache, as this information is not bound to change very often).
  2. Using this information you can make the actual call to retrieve your assets with the propertyOptionId parameter populated with the comma-separated list of metaproperty option ids that you want.

Let's jump to our example to see how it's done.

Example

1. Get all metaproperties

HTTP Parameter Value
HTTP Method GET
URL https://byndair.getbynder.com/api/v4/metaproperties/
Headers Authorization : OAuth version 1.0 generated authorization header

Below is part of the response:

[....
    "Country": {
        "isMultiselect": 0,
        "isMultifilter": 1,
        "isRequired": 0,
        "isMainfilter": 1,
        "isFilterable": 1,
        "name": "Country",
        "label": "Country",
        "labels": {
          "nl_NL": "Country",
          "en_US": "Country"
        },
        "zindex": 4,
        "id": "9BFE610F-D211-40CD-9CB07CEC13C490C5",
        "type": "select2",
        "isSearchable": 1,
        "isEditable": 1,
        "options": [
            ...
            {
                "displayLabel": "Greece",
                "date": "October, 12 2015 11:20:32 +0000",
                "pregeneratedZipFileSize": 0,
                "labels": {
                  "ar": "اليونان"
                },
                "linkedOptionIds": [
                  "30EB3C01-8322-4F8F-97D54F6863382980"
                ],
                "isSelectable": 1,
                "zindex": 1,
                "image": "https://d1ra4hr810e003.cloudfront.net/visual/mpoimage/8E6076D2-0B37-41A7-BD0CDA48DB3DA329/medium-93AAC4B0-9A9B-4DC3-9C641CE171368B5D.png",
                "product_suffix": "",
                "name": "Greece",
                "id": "8E6076D2-0B37-41A7-BD0CDA48DB3DA329",
                "active": 1,
                "label": "Greece",
                "descriptions": {},
                "description": "",
                "hideByDefault": 0
            },
            ...
        ]
    },
....
]

In the response you can see that there is a metaproperty Country available which has an option Greece. Thus, you can filter for assets that have the metaproperty Country set to Greece.

2. Retrieve the assets

Make the following call to retrieve the assets with Country Greece (the id of Greece as you can see above is 8E6076D2-0B37-41A7-BD0CDA48DB3DA329).

HTTP Parameter Value
HTTP Method GET
URL https://byndair.getbynder.com/api/v4/media/?propertyOptionId=8E6076D2-0B37-41A7-BD0CDA48DB3DA329
Headers Authorization : OAuth version 1.0 generated authorization header

Filter with multiple parameters

You can combine more parameters to limit your results. Let's say you want to get only the assets satisfy the following conditions:

HTTP Parameter Value
HTTP Method GET
URL https://byndair.getbynder.com/api/v4/media/?keyword=mountain&propertyOptionId=8E6076D2-0B37-41A7-BD0CDA48DB3DA329&dateCreated=2017-03-20T00:00:00Z&dateCreatedTo=2017-03-25T00:00:00Z
Headers Authorization : OAuth version 1.0 generated authorization header