Skip to content

Query

uHeadless has a flexible query API that allows to access any content that matches a specific query.

This resource has these properties

 PropertyDefault Type Description
breadcrumbfalsebooleanInclude the breadcrumb property in the document result.
depth2numberThe depth of relations to include in the response.
domainstringScope the results to a specified hostname define under “Culture and hostnames” in Umbraco.
excludeArray<string>Define the fields that you want to exclude in the response. You can’t use both exclude and include. If so, include will take precedence over exclude.
includeArray<string>Define the fields that you want to include in the response.
limit10numberThe amount of document to return form the query.
localecurrent or default languagestringSet the locale of the content you wan’t to query for. By default it uses the currentPage if middleware is enabled. Otherwise the language defined as default in Umbraco.
queryuHeadlessQueryQuery the results. See queries sections to learn more.
skipnumberThe amount to skip before starting the paginated result.
sortasc or descThe direction you want to sort in.
sortBystringThe property that you want to sort by, e.g. createdAt or propterties.publishDate.

The query API is used as query parameters in the url under the query scope.

const url = new URL('https://api.uheadless.com')
url.searchParams.set('token', UHEADLESS_API_KEY)
// Has to belong to the culture and hostname "example.com"
url.searchParams.set('query[domain]', 'example.com')
// Has contentTypeAlis "article"
url.searchParams.set('query[contentTypeAlias]', 'article')
// Has parent "1023"
url.searchParams.set('query[parent]', '1023')
// Has a property "tag" with value "tagA"
url.searchParams.set('query[properties.tag]', 'tagA')
// Only return "nodeName" and "properties.description"
url.searchParams.set('include', ['nodeName', 'properties.description'].join('|'))
// Limit to 10 items
url.searchParams.set('limit', '10')
const request = new Request(url)
const docs = await fetch(request).then(res => res.json())