Sparse Fieldsets

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

From 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
    }
  ]
}

The request above passed an empty list for the adviceset field. With that, the API omits the adviceset property entirely.

👍

When to use sparse fieldsets

Sparse fieldsets shrink the response payload, which speeds up requests and makes responses easier to scan during development.