customQuery
Learn how to use the customQuery API endpoint.
The customQuery endpoint allows you to query addresses, assets, entries, and users directly via URL parameters. It returns a JSON response for easy consumption.
To use it, simply send a GET request to: ${PRIMARY_SITE_URL}/v1/api/queryApi/customQuery with some query params. This could look like that
/v1/api/queryApi/customQuery?elementType=entries§ion=home&one=1.
A full example with an access token might look like this:
curl --request GET \
--url 'https://your-site.ddev.site/v1/api/queryApi/customQuery?elementType=entries§ion=home&one=1' \
--header 'authorization: Bearer your-access-token'
GET Params
Each element type has its own set of available GET parameters. This ensures precise control over the query and enhances security. Internally, these parameters are filtered to prevent potential exploits.
Special Parameters
Below is a list of special GET parameters that are available in all element types.
The following parameters are required: elementType and either one or all.
fields
The fields param is a simple filter, to minify the response returned to the client.
You can use a * in combination with fieldhandle.nestedFieldHandle, to filter out stuff that is not important.
includeAllEntry
The includeAllEntry defines how entry relations from an Entries field are returned.
If enabled, the customQuery endpoint will include full entry objects, otherwise only minimal data (title, URI, ID, slug) is returned.
To enable this setting globally you can use the includeAllEntry setting
If you use the includeAllEntry param, be sure that you don't have circular entry relations. This would end up in an endless loop.
Addresses
Below is a list of all available GET parameters for the addresses element type:
Assets
Below is a list of all available GET parameters for the assets element type:
Entries
Below is a list of all available GET parameters for the entries element type:
Users
Below is a list of all available GET parameters for the users element type: