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
Secure and Customize
Optimize and Extend
Reference