Skip to content

Count parameter

The count parameter includes the total number of items matching the current query.

It is commonly used in combination with pagination to display the total number of available results.

Note

When combined with parameters such as filter, the count reflects the number of results after filtering.

count=value: Boolean
count(value: Boolean)

Usage

In this example, the response includes a total count of the number of matching results.

This count reflects the total number of items matching the current query. It does not necessarily equal the number of items returned in the response, especially when using parameters such as limit or filter.

To retrieve subsets of results along with the total count, see pagination.

GET https://api.play.funql.io/v1beta1/sets?count=true
HTTP/1.1 200 OK
Content-Type: application/json
Total-Count: 70

[
  {
    "name": "LEGO Star Wars Millennium Falcon",
    "setNumber": 75192,
    "price": 849.99,
    "launchTime": "2017-10-01T14:15:30.500Z"
  },
  {
    "name": "LEGO Star Wars R2-D2",
    "setNumber": 10225,
    "price": 179.99,
    "launchTime": "2012-05-01T14:15:30.500Z"
  }
]

Note

In REST responses, the total count is included in the Total-Count header.

Try

POST https://api.play.funql.io/funql
Content-Type: text/plain

listSets(
  count(true)
)
HTTP/1.1 200 OK
Content-Type: application/json

{
  "data": [
    {
      "name": "LEGO Star Wars Millennium Falcon",
      "setNumber": 75192,
      "price": 849.99,
      "launchTime": "2017-10-01T14:15:30.500Z"
    },
    {
      "name": "LEGO Star Wars R2-D2",
      "setNumber": 10225,
      "price": 179.99,
      "launchTime": "2012-05-01T14:15:30.500Z"
    }
  ],
  "metadata": {
    "totalCount": 70
  }
}

Note

In QL responses, the total count is included in the metadata.totalCount property.