Sparse Fieldsets

Our API supports a subset of the json:api spec, including sparse fieldsets.

As noted in the json:api spec:

Apps can request that an endpoint return only specific fields in the response on a per-type basis by including a fields[TYPE] parameter.

The value of the fields parameter MUST be a comma-separated (U+002C COMMA, ",") list that refers to the name(s) of the fields to be returned. An empty value indicates that no fields should be returned.

Available Field Types

fields[TYPE]Applies toExample fields
fields[variables]variables[] arrayid, name, value, dataType, format, valueFormatted
fields[adviceset]adviceset objectid, title, category, description

Example

GET /api/advice/{adviceSetId}?fields[variables]=id,value&fields[adviceset]=

This returns only the id and value properties for each variable:

{
  "variables": [
    {
      "id": "abcde123456",
      "value": true
    }
  ]
}

Note the request specified an empty list for the adviceset field. With this configuration, the API will not return any fields for that property nor the adviceset property itself.

🏇

Experience and Performance

Sparse fieldsets are useful for improving not only the developer experience (by shrinking the amount of data to look through) but also for improving performance by reducing the response payload size.