Skip to content

Drupal JSON:API

Comprehensive guide for working with Drupal's JSON:API module (core) and JSON:API Extras (contrib). Covers spec-compliant REST API with filtering, includes, pagination, and customization.

I need to...

Get Started

I need to... Guide Summary
Understand what JSON:API is and when to use it What is JSON:API Understanding JSON:API's purpose helps determine if it fits your project requirements. JSON:API is a spec-compliant implementation built into Drupal core since 8.7.
Decide between JSON:API vs REST vs GraphQL JSON:API vs REST vs GraphQL Choose the right API approach based on your project's requirements and constraints.
Understand the core architecture and components Core Architecture Understanding the architecture is essential when customizing JSON:API behavior, debugging issues, or extending functionality.

Work with Resources

I need to... Guide Summary
Understand URL structure and resource types URL Structure & Resource Types Understanding URL patterns and resource type naming is fundamental for all API operations.
Fetch data with GET requests Fetching Resources (GET) Retrieving entity data from Drupal. Applies to collections (multiple entities) and individual entities.
Filter results by field values, operators, or groups Filtering Narrow down collection results based on field values. Essential for search, listing published content, filtering by author, date ranges, and complex queries.
Include related resources and limit response fields Includes & Sparse Fieldsets Includes: Fetch related entities in a single request (compound documents). Reduces HTTP round trips.
Sort results and paginate collections Sorting & Pagination Sorting: Control result order. Essential for chronological listings, alphabetical lists, and custom ordering.

Modify Data

I need to... Guide
Create resources with POST requests Creating Resources (POST)
Update resources with PATCH requests Updating Resources (PATCH)
Delete resources Deleting Resources (DELETE)
Upload files (images, documents) File Uploads

Secure and Customize

I need to... Guide
Set up authentication (Basic, Cookie, OAuth2, JWT) Authentication Patterns
Apply security best practices for production Security Best Practices
Customize resource names, URLs, and field visibility JSON:API Extras Customization
Transform field values with enhancers Field Enhancers

Optimize and Extend

I need to... Guide
Improve API performance (caching, CDN, sparse fields) Performance Optimization
Work with revisions and translations Revisions & Translations
Find key source code files for debugging Code Reference Map
Test and debug JSON:API implementations Testing & Debugging

Reference

I need to... Guide
Check guide sources and maintenance info Sources & Maintenance