Sparse Fieldsets

You can control which fields are returned from the JSON:API content delivery API by providing the fields parameter.

The following example will retrieve a specific book, ensuring that only the title,publishedData and author fields are returned.

GET /book?fields[book]=title,publishedDate,author
curl https://{SPACE_ID}.spaces.lexascms.com/delivery/jsonapi/book?fields[book]=title,publishedDate,author \
     -H 'Content-Type: application/vnd.api+json'

Relationship Fields

If you want to control the fields that are returned by a relationship, you must configure sparse fieldsets for the resource type that will be returned by the relationship.

The below example extends the previous one, by configuring sparse fieldsets for the author resource type. This ensures that only an authors name is returned as part of the author relationship.

GET /book?fields[book]=title,publishedDate,author,author.name
curl https://{SPACE_ID}.spaces.lexascms.com/delivery/jsonapi/book?fields[book]=title,publishedDate,author&fields[author]=name \
     -H 'Content-Type: application/vnd.api+json'
Integrates with your favourite tools and frameworks

© 2022 Status200 Ltd.