Documentation

How to Filter Data

WealthTech API supports both simple and complex filtering. A simple filter is a key-value pair. A complex filter is a structured json object that allows you to join multiple conditions together using one of the several operators.

All resources that support complex filtering have a .../filter endpoint where you can deliver a json body in a POST request.

Using Simple Filters

Simple filters are key-value pairs that can be provided as a query string parameters. For example:

GET .../api-section/resource-name?field=value

Or as a json payload:

POST .../api-section/resource-name

{
	"field": "value"
}

Request Examples

  1. Here's how you can filter on Accounts that are tax deferred using query string parameters:
curl --request GET \
--url 'https://api.bridgeft.com/v2/account-management/accounts?is_tax_deferred=true' \
--header 'Authorization: Bearer {YOUR_TOKEN}'

And as a json payload to the filter endpoint:

curl --request POST \
--url 'https://api.bridgeft.com/v2/account-management/accounts/filter' \
--header 'Authorization: Bearer {YOUR_TOKEN}' \
--header 'Content-Type: application/json' \
--data '
{
  "is_tax_deferred": true
}
'
  1. Another example is how to get an Account with the name "Jane Smith"
curl --request POST \
--url 'https://api.bridgeft.com/v2/account-management/accounts/filter' \
--header 'Authorization: Bearer {YOUR_TOKEN}' \
--header 'Content-Type: application/json' \
--data '
{
  "name": "Jane Smith"
}
'

A key-value expression is sufficient in these cases because the field being filtered can only take on two values: true or false; or we are filtering by the exact match. However more complex use cases arise from other types of data. You might want to filter a string field for the inclusion of a value, or whether it starts or ends with a value. Likewise you might want to filter numeric data for being within a certain range or above / below a certain value. These use cases are supported by complex filters described in the next section.

Complex Filters

Complex filters enable multiple conditions and comparison operators. These filters are expressed as json and must be provided as a POST request to the .../filter endpoint of a resource. If you find that there is no .../filter endpoint for the resource (you can check that out from the API Reference page), that means this API doesn't support the complex filtering.

The typical payload structure is:

{
  "field_name": {
    "any_or_all": "all", // required only if more than 1 condition is provided
    "conditions": [{
      "value": <value1>,
      "op": <comparison operator>
    }, {
      "value": <value2>,
      "op": <comparison operator>,
    }, {
      ...
    }]
  }
}

Comparison operators depend on the data type of field_name:

"Op" ValueDescriptionSupported Data Types
eqEquals
Case sensitive for strings
String, Integer, Float, Date/time
neqNot equals
Case sensitive for strings
String, Integer, Float, Date/time
iexactCase insensitive matchString
containsContains provided value, case sensitiveString
icontainsContains provided value, case insensitiveString
startswithStarts with provided value, case sensitiveString
istartswithStarts with provided value, case insensitiveString
endswithEnds with provided value, case sensitiveString
iendswithEnds with provided value, case insensitiveString
ltLess than provided valueInteger, Float, Date/time
lteLess than or equal to provided valueInteger, Float, Date/time
gtGreater than provided valueInteger, Float, Date/time
gteGreater than or equal to provided valueInteger, Float, Date/time

Request Example

Following request will return all Accounts those name is ending with "Smith":

curl --request POST \
--url 'https://api.bridgeft.com/v2/account-management/accounts/filter' \
--header 'Authorization: Bearer {YOUR_TOKEN}' \
--header 'Content-Type: application/json' \
--data '
{
  "name": {
    "conditions": [{
      "value": "Smith",
      "op": "endswith"
    }]
  }
}
'

Joining Conditions

The any_or_all field is optional when specifying a single condition. It's required when multiple conditions are provided and, as the name suggests, can take on the value of all or any, interpreted as:

  • all will AND the conditions together when querying the database. All the provided conditions must be true among the results.
  • any will OR the conditions together when querying the database. Any of the conditions must be true among the results.

Mixing with Simple Filters

A complex filter is a superset of a simple filter. Instead of field_name providing the filter json object above it can simply provide a value:

{
  "field_name": <value>
}

Here field_name will be consumed as a simple filter, requiring an exact match to the data in the database to be true. This way you can mix simple with complex filters:

{
  "field_1": "simple value",
  "field_2": {
    "conditions": [{
      "value": 5,
      "op": "gte"
    }]
  }
}

Request Example

The following request with combined filters can be used to get positions with reported realized gains/losses of at least $50 for the given advisor and a security:

curl --request POST \
     --url 'https://api.bridgeft.com/v2/data/source/positions/filter?pager.limit=100&pager.page=1' \
     --header 'Authorization: Bearer {YOUR_TOKEN}' \
     --header 'Content-Type: application/json' \
     --data '
{
  "reported_date": "2023-06-21",
  "advisor_code": "1234",
  "security_id": 5678,
  "reported_unrealized_gain_loss": [{
    "value": 50,
    "op": "gte"
    }] 
}
'

Filtering with Range of Values

You can use complex filters to query the data within the range of values. For example, the following query will find all objects whose field_name is between 5 and 150, inclusive of those values:

{
  "field_name": {
    "any_or_all": "all",
    "conditions": [{
      "value": 5,
      "op": "gte",
    }, {
      "value": 150,
      "op": "lte"
    }]
  }
}

Request Example

Getting all Account Balances which are in between $1,000 and $10,000

curl --request POST \
--url 'https://api.bridgeft.com/v2/data/source/account-balances/filter' \
--header 'Authorization: Bearer {YOUR_TOKEN}' \
--header 'Content-Type: application/json' \
--data '
{
	"beginning_period_value": {
		"any_or_all": "all",
		"conditions": [{
      "value": 1000,
      "op": "gte"
    }, {
    	"value": 10000,
    	"op": "lte"	
	}]
}
'