Query Objects

Queries

This function allows you to retrieve a list of objects matching specified criteria.
Relative URL
HTTP Request Method
/api/v4/app-instance-id/objects/model.json?query[field]=value
GET
/api/v4/app-instance-id/objects/model.json?q[field]=value
GET
/api/v4/app-instance-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 names of the fields in that model. The format for the values are 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:
Comparison
Syntax
Allowed 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

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:

http
GET https://run-testing-us.journeyapps.com/api/v4/533bda53027894f69b001055/objects/assets.json?q[serial_number]=123456
curl
curl "https://run-testing-us.journeyapps.com/api/v4/533bda53027894f69b001055/objects/assets.json?q[serial_number]=123456" \
-g -u "533bda53027894f69b001055:7Ajj5htRY1uzw7b4w23V"
ruby
require 'rest-client'
journey = RestClient::Resource.new "https://run-testing-us.journeyapps.com/api/v4", "533bda53027894f69b001055", "7Ajj5htRY1uzw7b4w23V"
journey["533bda53027894f69b001055/objects/assets.json"].get :params => {:q=>{:serial_number=>"123456"}}

Match multiple fields, including human-readable dates:

http
GET https://run-testing-us.journeyapps.com/api/v4/533bda53027894f69b001055/objects/assets.json?q[make]=Acme&q[registration_date]=2012-09-19
curl
curl "https://run-testing-us.journeyapps.com/api/v4/533bda53027894f69b001055/objects/assets.json?q[make]=Acme&q[registration_date]=2012-09-19" \
-g -u "533bda53027894f69b001055:7Ajj5htRY1uzw7b4w23V"
ruby
require 'rest-client'
journey = RestClient::Resource.new "https://run-testing-us.journeyapps.com/api/v4", "533bda53027894f69b001055", "7Ajj5htRY1uzw7b4w23V"
journey["533bda53027894f69b001055/objects/assets.json"].get :params => {:q=>{:make=>"Acme", :registration_date=>"2012-09-19"}}

Query with datetime in ISO8601 format:

http
GET https://run-testing-us.journeyapps.com/api/v4/533bda53027894f69b001055/objects/assets.json?q[updated_at]=2012-09-18T10%3A27%3A46Z
curl
curl "https://run-testing-us.journeyapps.com/api/v4/533bda53027894f69b001055/objects/assets.json?q[updated_at]=2012-09-18T10%3A27%3A46Z" \
-g -u "533bda53027894f69b001055:7Ajj5htRY1uzw7b4w23V"
ruby
require 'rest-client'
journey = RestClient::Resource.new "https://run-testing-us.journeyapps.com/api/v4", "533bda53027894f69b001055", "7Ajj5htRY1uzw7b4w23V"
journey["533bda53027894f69b001055/objects/assets.json"].get :params => {:q=>{:updated_at=>"2012-09-18T10:27:46Z"}}

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

http
GET https://run-testing-us.journeyapps.com/api/v4/533bda53027894f69b001055/objects/assets.json?q[make]=Acme&q[verified]=no
curl
curl "https://run-testing-us.journeyapps.com/api/v4/533bda53027894f69b001055/objects/assets.json?q[make]=Acme&q[verified]=no" \
-g -u "533bda53027894f69b001055:7Ajj5htRY1uzw7b4w23V"
ruby
require 'rest-client'
journey = RestClient::Resource.new "https://run-testing-us.journeyapps.com/api/v4", "533bda53027894f69b001055", "7Ajj5htRY1uzw7b4w23V"
journey["533bda53027894f69b001055/objects/assets.json"].get :params => {:q=>{:make=>"Acme", :verified=>"no"}}
http
GET https://run-testing-us.journeyapps.com/api/v4/533bda53027894f69b001055/objects/assets.json?q[room_id]=8af9f570-017b-11e2-84c8-b88d120322de
curl
curl "https://run-testing-us.journeyapps.com/api/v4/533bda53027894f69b001055/objects/assets.json?q[room_id]=8af9f570-017b-11e2-84c8-b88d120322de" \
-g -u "533bda53027894f69b001055:7Ajj5htRY1uzw7b4w23V"
ruby
require 'rest-client'
journey = RestClient::Resource.new "https://run-testing-us.journeyapps.com/api/v4", "533bda53027894f69b001055", "7Ajj5htRY1uzw7b4w23V"
journey["533bda53027894f69b001055/objects/assets.json"].get :params => {: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 URL
HTTP Request Method
/api/v4/app-instance-id/objects/model/search.json
POST

Parameters

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

Example

Search task objects for the text "First":

http
POST https://run-testing-us.journeyapps.com/api/v4/533bda53027894f69b001055/objects/tasks/search.json
query=First
curl
curl "https://run-testing-us.journeyapps.com/api/v4/533bda53027894f69b001055/objects/tasks/search.json" \
-u "533bda53027894f69b001055:7Ajj5htRY1uzw7b4w23V" \
-d "query=First"
ruby
journey = RestClient::Resource.new "https://run-testing-us.journeyapps.com/api/v4", "533bda53027894f69b001055", "7Ajj5htRY1uzw7b4w23V"
journey["533bda53027894f69b001055/objects/tasks/search.json"].post :query=>"First"

Response:

json
{
"objects": [
{
"id": "7b44dcf4-b02d-11e4-b450-001e6733fe3c",
"type": "task",
"updated_at": "2015-02-09T07:30:11Z",
"display": "My First Task",
"name": "My First Task",
"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": "My Second Task",
"name": "My Second Task",
"instructions": null,
"status": {
"key": 1,
"display": "Closed"
},
"category_id": null
},
],
"count": 2,
"total": 2,
"more": false
}
Copy link
On this page
Queries
Parameters
Response
Examples
Searching Across All Fields
Parameters
Example