How To Use Filters

How to Use Filters in the Data Export API

The Data Export API from Demandbase allows users to extract relevant data by applying various filters. This article will guide you through the process of using filters to refine your data exports, ensuring you get exactly the information you need.

Introduction to Filters

Filters are essential tools for narrowing down data to match specific criteria. By using filters, you can customize your data exports to include only the records that meet your requirements. The Data Export API supports multiple filters, allowing you to combine different conditions for more precise results.

Basic Structure of Filters

Filters in the Data Export API are specified in the filters field of the request body when creating an export job. Each filter is an object with the following attributes:

  • field: The name of the field to filter on.
  • operator: The condition to apply to the field.
  • values: The values to match against the field.

Here's a basic structure of a filter:

{
  "field": "fieldName",
  "operator": "operator",
  "values": ["value1", "value2"]
}

Supported Operators

The API supports several operators for filtering data. Here are some common ones:


  • Equals: Matches records where the field value is equal to one of the specified values.
  • Does Not Equal: Matches records where the field value is not equal to any of the specified values.
  • In: Matches records where the field value is in the list of specified values.
  • Not In: Matches records where the field value is not in the list of specified values.
  • Greater Than: Matches records where the field value is greater than the specified value.
  • Less Than: Matches records where the field value is less than the specified value.
  • Greater Than or Equal To: Matches records where the field value is greater than or equal to the specified value.
  • Less Than or Equal to: Matches records where the field value is less than or equal to the specified value.
  • Contains: Matches records where the field value contains the specified value.
  • Begins With: Matches records where the field value begins with the specified value.
  • Does Not Begin With: Matches records where the field value does not begin with the specified value.
  • Ends With: Matches records where the field value ends with the specified value.
  • Does Not End With: Matches records where the field value does not end with the specified value.
  • Exists: Matches records where a field value exists.
  • Does Not Exist: Matches records where a field value does not exist.

Note: Filters are always AND-ed together

Example Usage

Filtering by Country

Suppose you want to export data for accounts located in the USA. You can use the Equals operator to filter by the country field:

{
  "field": "account.country",
  "operator": "Equals",
  "values": ["USA"]
}

Filtering by Multiple Criteria

You can apply multiple filters to refine your search further. For example, to export data for accounts in the USA within the technology industry, you would use:

[
  {
    "field": "account.country",
    "operator": "Equals",
    "values": ["USA"]
  },
  {
    "field": "account.industry",
    "operator": "Equals",
    "values": ["Technology"]
  }
]

Filtering by Date Range

To filter data within a specific date range, you can use the GreaterThanOrEquals and LessThanOrEquals operators. For example, to export activities from January 1, 2024, to January 31, 2024:

[
  {
    "field": "activity.date",
    "operator": "Greater Than Or Equal To",
    "values": ["2024-01-01"]
  },
  {
    "field": "activity.date",
    "operator": "Less Than Or Equal To",
    "values": ["2024-01-31"]
  }
]

Combining Filters with Different Operators

You can combine different operators to achieve more complex filtering. For example, to export data for accounts not in the USA and with more than 50 employees:

[
  {
    "field": "account.country",
    "operator": "Does Not Equal",
    "values": ["USA"]
  },
  {
    "field": "account.employeeCount",
    "operator": "Greater Than",
    "values": ["50"]
  }
]

Implementing Filters in Export Job

To use filters in an export job, include them in the filters field of your request body when you create an export job. Here's a complete example:

{
  "fields": ["account.name", "account.industry", "account.country", "account.employeeCount"],
  "fromDate": "2024-01-01",
  "toDate": "2024-01-31",
  "filters": [
    {
      "field": "account.country",
      "operator": "Equals",
      "values": ["USA"]
    },
    {
      "field": "account.industry",
      "operator": "Equals",
      "values": ["Technology"]
    }
  ],
  "format": "CSV"
}

Conclusion

Using filters in the Data Export API allows you to tailor your data exports to meet your specific needs. By understanding the structure of filters and the supported operators, you can effectively refine your data and ensure that your exports are both relevant and useful. Start applying filters to your export jobs today and take full advantage of the flexibility and power of the Data Export API.

For more detailed information on the available fields and operators, refer to the full API documentation or contact our support team for assistance.