What is KQL?
INFO
The KQL documentation is the full introduction.
The Kirby Query Language API takes a JSON object in a POST request and returns the fields its select asks for.
The official KQL endpoint is /api/query. An example request:
json
{
"query": "page('photography').children",
"select": {
"url": true,
"title": true,
"text": "page.text.markdown",
"images": {
"query": "page.images",
"select": {
"url": true
}
}
},
"pagination": {
"limit": 10
}
}Response:
json
{
"code": 200,
"status": "ok",
"result": {
"data": [
{
"url": "https://example.com/photography/trees",
"title": "Trees",
"text": "Lorem <strong>ipsum</strong> …",
"images": [
{ "url": "https://example.com/media/pages/photography/trees/1353177920-1579007734/cheesy-autumn.jpg" },
{ "url": "https://example.com/media/pages/photography/trees/1940579124-1579007734/last-tree-standing.jpg" },
{ "url": "https://example.com/media/pages/photography/trees/3506294441-1579007734/monster-trees-in-the-fog.jpg" }
]
},
{
"url": "https://example.com/photography/sky",
"title": "Sky",
"text": "<h1>Dolor sit amet</h1> …",
"images": [
{ "url": "https://example.com/media/pages/photography/sky/183363500-1579007734/blood-moon.jpg" },
{ "url": "https://example.com/media/pages/photography/sky/3904851178-1579007734/coconut-milkyway.jpg" }
]
}
],
"pagination": {
"page": 1,
"pages": 1,
"offset": 0,
"limit": 10,
"total": 2
}
}
}TIP
The Kirby Headless plugin adds a KQL endpoint at /api/kql that accepts a bearer token. See Authentication.