Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Usage Milestone: Google Analytics Module google_analytics crossed 1,000 active installs. Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Release: GraphQL Compose Codegen 1.1.2 Minor update available for module graphql_compose_codegen (1.1.2). Release: Mapy.com 1.1.3 Minor update available for module mapycom (1.1.3). Release: Ckeditor5 entity browser 3.0.3 Minor update available for module ckeditor5_entity_browser (3.0.3). Release: Ckeditor5 entity browser 3.0.1 Minor update available for module ckeditor5_entity_browser (3.0.1). Release: Ckeditor5 entity browser 3.0.2 Minor update available for module ckeditor5_entity_browser (3.0.2). Release: Teamleader Integration 4.0.2 Minor update available for module teamleader (4.0.2). Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

JSON:API Include

3,201 sites Security covered Drupal 11 · not 10
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.

Depends on

Dependencies of the latest stable release

  • jsonapi Drupal core
  • user Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Oct 2024
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 2
Maintenance
Active

Releases

Version Type Core Release date
2.0.0 Stable 11 Jul 24, 2025
2.0.x-dev Dev 11 Oct 26, 2024