Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

JSON:API Include

3,249 sites Security covered
View on drupal.org

This module simplifies parsing related entity data from JSON:API responses. It merges relationship data directly into the parent entity's fields, making it easier to work with referenced entities without needing to make separate requests.

INTRODUCTION
------------

JSON:API Include merges relationship data from JSON:API.

Use cases:

- Easily parse entity references returned by JSON:API (the data of referenced entities will be flattened into the relevant field of the parent entity instead of in a JSON:API relationship).
- Use relationship data directly to import content with Migrate.

REQUIREMENTS
------------

This module requires no modules outside of Drupal core's JSON:API module.

RECOMMENDED MODULES
-------------------

JSON:API Extras: Use the JSON:API Extras module to customize JSON:API responses by specifying automatic includes. For example, if you have a node with a taxonomy term entity reference, you can specify that as an automatic include, which will then be parsed by the JSON:API Include module.

INSTALLATION
------------

Install the module as you would normally install a contributed Drupal
module. Visit https://www.drupal.org/node/1897420 for further information.

CONFIGURATION
--------------

By default, this module automatically parses all responses. JSON:API includes are flattened to make it easy to parse entity reference data.

Want to opt-in to flattening instead? There's a configuration option for that!

1. Navigate to Administration>Configuration>Web services>JSON:API>JSON:API Include.
2. Enable "Use jsonapi_include query in url".
3. Toggle JSON:API include by adding jsonapi_include=1 when you want to use this module's parsing.

For example: https://www.example.com/jsonapi/node/article?include=field_tags&jsonapi_include=1

When the **Use jsonapi_include query in url** setting is enabled, this module will only parse the response if `jsonapi_include=1` was specified.

If this setting is disabled, all responses will be parsed.

FAQ
--------------

What does this module do?

If you request an entity with included relationships through JSON:API, the output will be a JSON array containing the entity and the contents of the entity's referenced entities. This module adds an additional step before the response is delivered (see `JsonapiParse`). In this step, the module merges the content of the referenced entities into the respective field entries of the original entity. This makes it easier to parse entity references.

How can I add a custom parse function?

This module uses the service `jsonapi_include.parse` to parse JSON:API data. If you want to use a custom parsing function, override the class `JsonapiParse`.
Reference: Altering existing services (Core docs)

Supporting this Module

All contributions are welcome. Please submit MRs, not patches, so that the CI tests are run. Please add tests if possible.

If you post an issue and do not receive a response, feel free to contact me by private message in the Drupal Slack (ptmkenny) or via my Drupal.org contact form.

Activity

Total releases
1
First release
Jul 2025
Latest release
11 months ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Slowing

Releases

Version Type Release date
2.0.0 Stable Jul 24, 2025