API - Filtering and Pagination

Important Options below are only available on collection resources


Pagination options

By default, collection resources will only contain the first 25 items.

Field Type Description
results integer or "all" Number of items to retrieve (default 25)
startIndex integer Start index of the items to retrieve (default 0)

Important If you wish to retrieve all items in a single request, you can pass all instead of an integer. This is not recommended if the collection can become very large (for fiches or vevents resources).

Example :

GET /api/v1/groups/:group_id/calendars?results=all&apikey=xxxxxx

Sorting options

Field Type Description
sort string Field to sort items by (none by default)
dir string Sorting direction, "asc" or "desc" (sort must be specified.)

Example: Get the calendars, newest first :

GET /api/v1/groups/:group_id/calendars?sort=created_at&dir=desc&apikey=xxxxxx

Field Type Description
search string Perform a search from a string. The search method depends on the resource on which it is called.

Example :

GET /api/v1/groups/:group_id/fiches?search=doe&apikey=xxxxxx

Filtering

The API provide parameters to query items with conditions :

Field Type Description
conditions array List of conditions. If multiple conditions are provided, the results will match ALL conditions.

Each condition must be a hash, with the following 3 attributes :

Field Type Description
field string Condition field
op string Operateur: =, >, >=, <, <=, !=", "like", "not like", "in", "not in". Note : Charaters "<", "=" and ">" must be encoded in the URL : "%3C", "%3D" and "%3E".
value any For "in" / "not in", the format of value should be "...,....,..." (value separated by a comma)



Examples :

  • Contacts updated after february, 1st 2010 :

Condition : updated_at >= 2010-02-01 00:00:00

GET https://sandbox.clicrdv.com/api/v1/groups/:group_id/fiches?apikey=xxxxxx&\
                 conditions[0][field]=updated_at&\
                 conditions[0][op]=%3E%3D&\
                 conditions[0][value]=2010-02-01 00:00:00

  • Get appointments only (appointments are vevents which intervention_id is greater than 0)

Condition : intervention_id > 0

GET https://sandbox.clicrdv.com/api/v1/groups/:group_id/vevents?calendar_id=:calendar_id?apikey=xxxxxx&\
                   conditions[0][field]=intervention_id&\
                   conditions[0][op]=%3E&\
                   conditions[0][value]=0&\

  • Get appointments modified since february, 1st 2010 :

Condition : intervention_id > 0 && updated_at >= 2010-02-01 00:00:00

GET https://sandbox.clicrdv.com/api/v1/groups/:group_id/vevents?calendar_id=:calendar_id?apikey=xxxxx&\
                 conditions[0][field]=intervention_id&\
                 conditions[0][op]=%3E&\
                 conditions[0][value]=0&\
                 conditions[1][field]=updated_at&\
                 conditions[1][op]=%3E%3D&\
                 conditions[1][value]=2010-02-01 00:00:00