Skip to main content

Using Filters in Requests

Using filters is a standard technique that works uniformly in the search methods of the Dateno API. Filters allow your application to exclude irrelevant results from the response, which can contain multiple descriptors. Here, we use the Search Entries method as an example, noting that filters work the same way in other methods.

Filter Usage

The filters supported in Dateno API requests generally correspond to the facets available to users of the Dateno web application. Each filter relates to one of the properties of datasets or catalogs, such as language, country, type of catalog, data format, etc.

A filter defined in a request restricts descriptors included in the response by specific values of the corresponding properties. Most of these values are directory entries. For example, you can exclude from the response any datasets whose language is not French.

Finding Filter Names

The available filters surface in response outcomes. For example, the Country facet appears on the search web page.

A corresponding object in a dataset descriptor is shown below.

"source": {
/* other properties are skipped */
"countries": [
{
"name": "Canada",
"id": "CA"
}
]
}

Adding Filters to Requests

Use the filters parameter to pass filters to the Dateno API.

A filter name can be derived directly from the structure of the output JSON object. For example, the name of the country filter would be source.countries.name or source.countries.id, depending on whether you prefer to use names or identifiers.

The format of a filter value is a pair structured as:

filters="filter name"="target value".

The filters parameter can be included multiple times in a request if you need to restrict results by several properties.

Example

Assume the goal is to retrieve datasets related to rabbits, associated with Canada, and written in French. The query would be:

https://api.dateno.io/index/0.1/query?apikey=qwertyuiopasdfghjklzxcvbnm123456&q=rabbits&filters="source.countries.name"="Canada"&filters="source.langs.id"="FR"