API v3 advanced filter examples

With API v3 you have an option to use advanced search. Let us give you few examples on how to use it.

General search

By default you can search for values simply by searching for a specific column with a value:

{column:value, …}

As you can see, you can also combine more conditions into one request, e.g. searching for all men in a company ID:

_filters={"gender":"M","company_id":"abcdefgh"}

With general search you can not look for specific dates or a contact with a specific value in a custom field. That is what advanced search is for.

Advanced search

With advanced search, the format of the request is slightly different - instead of two values you will need three:

[[column,operator,value], …]

As you can see an 'operand' is used here. With it you can search for tickets resolved today or tickets with specific subject:

_filters=[["date_resolved","DP","T"]]
_filters=[["subject","E","Notification"]]

Constants

In all filters in REST calls you can use constants. Here's a list of it:

// Boolean comparison
const LIKE = "L";
const NOT_LIKE = "NL";
const EQUALS = "E";
const NOT_EQUALS = "NE";
const IS_IN = "IN";
const NOT_IN = "NI";
const MATCHES = "PM";
const IS_EMPTY = "IE";
const IS_NOT_EMPTY = "INE";

// value comparison
const NUMBER_EQUALS = "=";
const NUMBER_GREATER = ">";
const NUMBER_LOWER = "<";
const NUMBER_EQUALS_GREATER = ">=";
const NUMBER_EQUALS_LOWER = "<=";

// date and time comparison
const DATE_EQUALS = "D=";
const DATE_GREATER = "D>";
const DATE_LOWER = "D<";
const DATE_EQUALS_GREATER = "D>=";
const DATE_EQUALS_LOWER = "D<=";
const DATERANGE_IS = "DP";
const TIME_EQUALS = "T=";
const TIME_GREATER = "T>";
const TIME_LOWER = "T<";
const TIME_EQUALS_GREATER = "T>=";
const TIME_EQUALS_LOWER = "T<=";

// date and time range constants
const RANGE_TODAY = 'T';
const RANGE_YESTERDAY = 'Y';
const RANGE_LAST_7_DAYS = 'L7D';
const RANGE_LAST_30_DAYS = 'L30D';
const RANGE_LAST_90_DAYS = 'L90D';
const RANGE_THIS_WEEK = 'TW';
const RANGE_LAST_WEEK = 'LW';
const RANGE_LAST_2WEEKS = 'L2W';
const RANGE_LAST_WORKING_WEEK = 'LWW';
const RANGE_THIS_MONTH = 'TM';
const RANGE_LAST_MONTH = 'LM';
const RANGE_THIS_YEAR = 'TY';
const RANGE_LAST_YEAR = 'LY';

Ready to try LiveAgent?

It's free for the first 14 days! No credit card required.

Get Started
We work well with others...
Magento Joomla Wordpress Mailchimp
Contact us

support@liveagent.com

+1-800-811-6590 (Toll Free in USA & Canada)

+421 2 33 456 826 (European Union & Worldwide)

Quality Unit, LLC 616 Corporate Way, Suite 2-3278 Valley Cottage, NY 10989

Stay in touch
Blog Google+
© 2004-2020 LiveAgent.com, All rights reserved