Version 2 (v2)
Filtering
The Administrate API provides a set of filters which are useful for requesting a restricted set of results to avoid further processing and reduce bandwidth. This allows the possiblity to return records between a set of dates, for example, or all those records that belong to a list of ids.
Available Filters
Name | Operator | Usage |
---|---|---|
Less than | __lt | attribute__lt=[value] |
Less than or equal to | __lte | attribute__lte=[value] |
Greater than | __gt | attribute__gt=[value] |
Greater than or equal to | __gte | attribute__gte=[value] |
Equals | __eq | attribute__eq=[value] |
Belongs to | __in | attribute__in=value_1[,value_2]* |
Does not belong to | __notin | attribute__notin=value_1[,value_2]* |
Date time filtering
Date time fields are required to be ISO compliant. Most fields are not time zone aware and hence need to be provided without an offset. Contrarily, time zone aware fields are required to have an offset. An example of both forms can be found below:
Date time ISO formats examples
Type | Example |
---|---|
ISO datetime without offset | 2017-12-20T18:00:00 |
ISO datetime with offset | 2017-12-20T18:00:00+01:00 |
Ordering
You can order the results by using a query parameter of ‘_order=field’. To order by multiple fields, simply comma separate them: ‘_order=field1,field2’. To order in descending order, place a dash in front of the field name: ‘_order=-field1,field2’.
Example
curl -k -u <username>:<password> \
https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/accounts?_order=first_name
Limiting
You can limit the results by using a query parameter of ‘_limit=N’ where N is an integer.
Example
curl -k -u <username>:<password> \
https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/accounts?_limit=10
Pagination
You can paginate through large sets of data by making multiple requests and combining a ‘__gt’ filter, ‘_order’, and ‘_limit’. On the first request, you would request records where id > 0, ordering by id, and returning 100 records:
First request
curl -k -u <username>:<password> \
https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/accounts?id__gt=0&_order=id&_limit=100
The next request would use the last id from the previous request as the ‘__gt’ filter:
Second request
curl -k -u <username>:<password> \
https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/crm/accounts?id__gt=100&_order=id&_limit=100
You would continue this until 0 results are returned.