JSON:API module

The Drupal core JSON:API module implements the JSON:API spec for Drupal entities. It provides a zero-configuration required, opinionated, way to allow RESTful CRUD for a Drupal site's content.

It is closely coupled to Drupal's Entity and Field APIs, response caching, and authentication and authorization systems. Because it follows the shared JSON:API conventions it can help increase productivity and allow you to take advantage of non-Drupal specific tooling.

Read more about the architecture of the module.

This guide covers:

  • Installing and configuring the JSON:API module
  • Using the provided API features

There are more docs available in the Contenta CMS's knowledge hub.

JSON:API

The JSON:API module is a fully compliant implementation of the JSON:API Specification.

Glossary of Terms

Common JSON:API terms and their meanings

API Overview

The API that the JSON:API module makes available is centered around the Drupal's entity types and bundles. Every bundle receives its own,

Core Concepts

JSON:API has many concepts in the specification, not all of which are documented here. However, users of the module do not need to

Filtering

Filters let you limit your collections to just the entities you need.

Includes

Use includes to eliminate HTTP requests by embedding related resource objects in a single response.

Pagination

Learn how to handle collections which require multiple requests

Sorting

JSON:API makes it possible to retrieve multiple resources in a single request, these routes are called "collection" routes. One can fetch a

Revisions

Fetching non-default entity revisions

Translations

Basic functionality; JSON:API does not support advanced use cases

GET, POST, PATCH and DELETE

This section contains examples and information per request type.

Fetching resources (GET)

This page shows examples of various GET requests for the JSON:API module.

Creating new resources (POST)

This page shows examples of various POST requests for the JSON:API module.

Removing existing resources (DELETE)

This page shows examples of DELETE requests for the JSON:API module.

Updating existing resources (PATCH)

This page shows examples of PATCH requests for the JSON:API module.

Customizing Resources

Using events to disable or rename resources and resource fields.

File Uploads

Uploading and downloading files

JSON:API vs. core's REST module

What are the differences between the JSON:API module and core's REST module? When to use which?

What JSON:API DOESN'T do

Business rules like creating an account, login and requesting a new password are not part of JSON:API.

JSON:API Extras

For altering JSON:API configuration use JSON:API Extras.

Security considerations

How bugs in Entity/Field/Typed Data API can lead to security vulnerabilities, importance of stable modules, and about read-only mode.

Guide maintainers

bbrala's picture
gabesullice's picture
e0ipso's picture
Wim Leers's picture
clemens.tolboom's picture