The Query API for Craft CMS
Craft Query API makes Craft's query builder accessible across any frontend, allowing you to dynamically build queries via URL parameters for flexible, real-time data access in headless or traditional setups.
Flexible API Queries
Fetch content via URL parameters for dynamic data retrieval.
Unified Content Access
Retrieve addresses, assets, entries, and users with one API.
Image Transforms
Detects and configures ImagerX transforms for optimized images.
Features
- Dynamic URL-Based Queries: Easily build and execute queries directly from URL parameters, enabling flexible, real-time data retrieval across any frontend or platform.
- Get Only the Data You Need: Avoid overfetching by using a custom function in the query builder to select only the fields you require.
- Pretty Json: Json Transformer are in place to prettify the response.
- Native and Custom Field Detection: Recognizes both native Craft fields and custom fields across all element types, ensuring effortless compatibility with any data model.
- Comprehensive Content API: Supports querying of all main element types, including addresses, assets, entries, and users, building a complete API for versatile content needs.
- Prerendering Support: Provides an endpoint to fetch all active page URLs, perfect for prerendering, static site generation, and enhanced site performance.
- Optimized Data Retrieval: Built for high-performance content access, with smart caching strategies in place.
ImagerX Support
The Craft Query API Plugin automatically detects named transforms and widths defined in your ImagerX configuration. When querying images, it applies these pre-defined transformations, returning an optimized srcset for each image.
Frontend Integrations
The Craft Query API Plugin is designed to be highly adaptable, with dedicated npm packages available for Vue, Nuxt, and TypeScript to make integration as seamless as possible. These packages allow developers to easily use the query builder in frontend projects, enabling dynamic data fetching with minimal configuration.
This could look like that (in Nuxt):
const queryUrl = useCraftQuery('entries')
.id(1)
.status('active')
.siteId(1)
.one()
Currently Available Integrations
- Js Craft CMS API: The core package, you can build wrappers around it to support your framework. If you want to build a wrapper around it for your framework -> Hit me up :)
- Vue Craft CMS: A package to use the query builder in Vue.
- Nuxt Craft CMS: A package to use the query builder in Nuxt.