Data integration
News & product updates

Got insights from this post? Give it a boost by sharing with others!

Applying Filters to Queries

Windsor.ai provides flexible filtering and date selection options that allow you to retrieve precisely the data you need from any supported connector. This guide explains how to apply date ranges and data filters using the latest API syntax and best practices.

Introduction

You can control the data returned by the API in two main ways:

  1. Date filtering: define the time range for the data.

  2. Data filtering: apply conditions to fields such as campaign, spend, clicks, or impressions.

Both options are applied using URL query parameters and can be combined in a single request.

Date filtering

You can specify date ranges using either presets or explicit dates.

Option 1: Date presets

Date presets are the easiest way to request commonly used time ranges.

Example:

https://connectors.windsor.ai/facebook?fields=date,spend&date_preset=last_30d

Simple presets:

  • last_7d – last 7 days

  • last_30d – last 30 days

  • last_90d – last 90 days

  • last_year – previous calendar year

Dynamic presets (general format):

  • last_Xd – last X days

  • last_XdT – last X days, including today

  • last_Xw – last X weeks

  • last_Xm – last X months

  • last_Xy – last X years

Year-based presets:

  • last_year – previous calendar year

  • last_yearT – previous calendar year, including today

  • last_2years – last two years

  • last_2yearsT – last two years, including today

Current period presets:

  • this_month – current month

  • this_monthT – current month, including today

  • this_year – current year

  • this_yearT – current year, including today

Option 2: Explicit date range

You can also define an exact start and end date.

Example:

https://connectors.windsor.ai/facebook?fields=date,spend&date_from=2023-01-01&date_to=2023-01-31&api_key={your_api_key}

⚠️ Note: If date_to is not specified, the API defaults to today and returns the most recent available data.

Data filtering

Data filters allow you to include or exclude rows based on field values. Filters use a JSON array format, which improves readability and supports grouping and nesting.

Filter structure

Each condition follows this format:

[field, operator, value]

Conditions can be combined using:

  • "and"

  • "or"

Nested arrays can be used to create complex logic.

Supported filter operators

The filtering functionality supports several filter operators that can be used to define different types of criteria. These operators are used in combination with the field name and the desired value to create a filter.

The following filter operators are available:

OperatorDescriptionExample
eqEquals["campaign","eq","Summer Sale"]
neqNot equals["campaign","neq","Winter Sale"]
gtGreater than["spend","gt",100]
gteGreater or equal["spend","gte",100]
ltLess than["spend","lt",100]
lteLess or equal["spend","lte",100]
containsContains substring["campaign","contains","Sale"]
ncontainsDoes not contain the substring["campaign","ncontains","Test"]
nullField is null["clicks","null",null]
notnullField is not null["clicks","notnull",null]
  • eq (Equals): Matches records where the field value is equal to the specified value.
  • neq (Not Equals): Matches records where the field value is not equal to the specified value.
  • gt (Greater Than): Matches records where the field value is greater than the specified value.
  • gte (Greater Than or Equal To): Matches records where the field value is greater than or equal to the specified value.
  • lt (Less Than): Matches records where the field value is less than the specified value.
  • lte (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.
  • ncontains: Matches records where the field value does not contain the specified value.

Filter examples

⚠️ Important: For real API requests, the filter parameter must be URL-encoded. The examples below are shown in plain JSON for readability.

Single filter

https://connectors.windsor.ai/facebook?fields=date,campaign,spend&filter=[["campaign","eq","Summer Sale"]]&api_key={your_api_key}

Check for null values

https://connectors.windsor.ai/facebook?fields=date,campaign,clicks&filter=[["clicks","null",null]]&api_key={your_api_key}

Multiple conditions (AND)

https://connectors.windsor.ai/facebook?fields=date,spend&filter=[["spend","gt",100],"and",["campaign","contains","Sale"]]&api_key={your_api_key}

Nested conditions (AND + OR)

https://connectors.windsor.ai/facebook?fields=date,campaign,spend&filter=[[["campaign","eq","foobar"],"or",["spend","eq",10]],"and",["campaign","eq","abc (us)"]]&api_key={your_api_key}

Conclusion

Windsor.ai’s filtering system gives you precise control over both time ranges and data conditions. By combining flexible date presets with structured JSON-based filters, you can build powerful queries that return exactly the data you need, whether for dashboards, reporting, or advanced analytics.

🚀 Try it in your analytics workflow right now: https://onboard.windsor.ai/.

Tired of juggling fragmented data? Get started with Windsor.ai today to create a single source of truth

Let us help you automate data integration and AI-driven insights, so you can focus on what matters—growth strategy.
g logo
fb logo
big query data
youtube logo
power logo
looker logo