Query Objects

Queries

This function allows you to retrieve a list of objects matching specified criteria.

Relative URLHTTP Request Method

/api/v4/backend-deployment-id/objects/model.json?query[field]=value

GET

/api/v4/backend-deployment-id/objects/model.json?q[field]=value

GET

/api/v4/backend-deployment-id/objects/model.json?query[field]=value1&query[other_field]=value2

GET

  • Replace model with the type of object that you wish to retrieve (as defined in your app's Data Model), for example person, job or asset.

  • Multiple query criteria can be specified.

  • Certain "hidden" fields are prefixed with an underscore, for example: to query on the updated_at hidden field, use _updated_at.

Parameters

Query parameters are specified as a URL-encoded query or q hash. Valid keys for this hash are the names of the fields in that model. The format for the values is the same as for creating objects. Please refer to the same section at Creating a New Object.

You can specify your criteria with logic such as 'equals', 'not equal to', 'greater than', 'less than', etc. as follows:

ComparisonSyntaxAllowed Values

Equals

query[field]=value

is Not Equal To

query[field.ne]=value

is Less Than

query[field.lt]=value

is Less Than or Equal To

query[field.lte]=value

is Greater Than

query[field.gt]=value

is Greater Than or Equal To

query[field.gte]=value

Contains

query[field.contains]=value

is Null (or Not Null)

query[field.null]=value

Specify true for the value to check for "Is Null" or false to check for "Is Not Null"

The contains operator is case-sensitive.

Response

The response includes a list of all the objects of the given type which match all of the query criteria. The format of the objects is the same as for listing all objects (please refer to the Retrieve All Objects section.)

Examples

BASE-URL

The below examples contain a BASE-URL placeholder. Please refer to the HTTP Endpoints section to get the base URL relevant to your deployment.

When using curl with queries you have to either escape the square brackets with a backslash \ or add the -g option to turn off curl's globbing functionality.

Match a text field:

GET BASE-URL/api/v4/533bda53027894f69b001055/objects/assets.json?q[serial_number]=123456

Match multiple fields, including human-readable dates:

GET BASE-URL/api/v4/533bda53027894f69b001055/objects/assets.json?q[make]=Acme&q[registration_date]=2012-09-19

Query with datetime in ISO8601 format:

GET BASE-URL/api/v4/533bda53027894f69b001055/objects/assets.json?q[updated_at]=2012-09-18T10%3A27%3A46Z

Match a value (as a string) from a single-choice field:

GET BASE-URL/api/v4/533bda53027894f69b001055/objects/assets.json?q[make]=Acme&q[verified]=no
GET BASE-URL/api/v4/533bda53027894f69b001055/objects/assets.json?q[room_id]=8af9f570-017b-11e2-84c8-b88d120322de

Searching Across All Fields

You can also search through all the fields of all objects of a given type for a partial text match. This can be useful for implementing basic search functions.

Relative URLHTTP Request Method

/api/v4/backend-deployment-id/objects/model/search.json

POST

Parameters

The search text must be specified as a URL-encoded parameter named query.

Example

BASE-URL

The below examples contain a BASE-URL placeholder. Please refer to the HTTP Endpoints section to get the base URL relevant to your deployment.

Search task objects for the text "site":

POST BASE-URL/api/v4/533bda53027894f69b001055/objects/tasks/search.json
query=site

Response:

json
{
    "objects": [
      {
          "id": "7b44dcf4-b02d-11e4-b450-001e6733fe3c",
          "type": "task",
          "updated_at": "2015-02-09T07:30:11Z",
          "display": "Confirm that site rules are documented and distributed",
          "name": "Confirm that site rules are documented and distributed",
          "instructions": null,
          "status": {
            "key": 1,
            "display": "Closed"
          },
          "category_id": null
        },
        {
          "id": "fd3b75e2-b02d-11e4-a034-001e6733fe3c",
          "type": "task",
          "updated_at": "2015-02-09T07:33:49Z",
          "display": "Confirm that supervisor is on site",
          "name": "Confirm that supervisor is on site",
          "instructions": null,
          "status": {
            "key": 1,
            "display": "Closed"
          },
          "category_id": null
        },
    ],
    "count": 2,
    "total": 2,
    "more": false
}

Last updated