# Queries

To increase performance when requesting a significant batch of data, all API resources support the query object, which contains attributes to build SQL-like queries.

JSON object

The query parameter is a JSON object and cannot be passed as a URL parameter.

 

# Supported query attributes

  • select
  • where
  • distinct
  • min
  • max
  • count
  • sum
  • order_by
  • group_by

SQL

Most query attributes work the same way as the standard SQL clause of the same name, except the following.

# Responses

The result of a query is returned in a data object. There will be all attributes but they might not be filled with the actual value.

# Example queries

# Count the number of feed intake records of a sow

{
	"query": {
		"count": "gestal_id",
		"where": "gestal_id=1085494690191"
	}
}

# Result

{
  "data": [
    {
      "cloud_id": null,
      "fed_at": null,
      "created_at": null,
      "updated_at": null,
      "gestal_id": 149,
      "parity": null,
      "quantity": 0,
      "target_quantity": 0,
      "percent": 0,
      "curve": null,
      "schedule": null,
      "feed": null,
      "group": null,
      "section": null,
      "location": null,
      "batch": null,
      "day": null
    }
  ]
}

# Fetch every day on which every sow did not eat

{
	"query": {
		"distinct": "gestal_id,fed_at",
		"where": "quantity=0",
		"order_by": "gestal_id,fed_at desc"
	}
}

# Example response

When using queries, expect

{
  "data": [
    {
      "cloud_id": null,
      "fed_at": "2019-11-14",
      "created_at": null,
      "updated_at": null,
      "gestal_id": 1085494690191,
      "parity": null,
      "quantity": 0,
      "target_quantity": 0,
      "percent": 0,
      "curve": null,
      "schedule": null,
      "feed": null,
      "group": null,
      "section": null,
      "location": null,
      "batch": null,
      "day": null
    },
    {
      "cloud_id": null,
      "fed_at": "2019-12-12",
      "created_at": null,
      "updated_at": null,
      "gestal_id": 1085494690602,
      "parity": null,
      "quantity": 0,
      "target_quantity": 0,
      "percent": 0,
      "curve": null,
      "schedule": null,
      "feed": null,
      "group": null,
      "section": null,
      "location": null,
      "batch": null,
      "day": null
    },
    [...]
Last Updated: 8/27/2025, 2:40:38 PM