Appearance
Query Syntax
List endpoints accept a query URL parameter containing a JSON-encoded object for filtering, sorting, and pagination.
Basic Format
GET /api/collection?query=<JSON>The JSON object structure:
json
{
"where": { ... },
"limit": 100,
"offset": 0,
"sort": "name"
}URL-encode the JSON when using it in a URL:
bash
curl -G http://localhost:8080/api/books \
--data-urlencode 'query={"where":{"name":{"$like":"%test%"}},"limit":10}'Where Clause
The where object filters results by field values. Each field can be a direct value or an operator expression.
Direct Value
json
{"where": {"name": "My Book"}}Operator Expression
json
{"where": {"name": {"$like": "%draft%"}}}String Operators
| Operator | Description | Example |
|---|---|---|
$eq | Equals | {"$eq": "exact match"} |
$ne | Not equals | {"$ne": "excluded"} |
$like | SQL LIKE (case-sensitive) | {"$like": "%partial%"} |
$ilike | SQL LIKE (case-insensitive) | {"$ilike": "%partial%"} |
$re | Regular expression | {"$re": "^prefix.*"} |
$gt | Greater than | {"$gt": "B"} |
$gte | Greater than or equal | {"$gte": "B"} |
$lt | Less than | {"$lt": "M"} |
$lte | Less than or equal | {"$lte": "M"} |
$in | In list | {"$in": ["a", "b"]} |
$nin | Not in list | {"$nin": ["x", "y"]} |
$contains | JSON contains | {"$contains": "value"} |
$contained | JSON contained by | {"$contained": "value"} |
$fulltext | Full-text search | {"$fulltext": "search terms"} |
Numeric Operators
| Operator | Description | Example |
|---|---|---|
$eq | Equals | {"$eq": 42} |
$ne | Not equals | {"$ne": 0} |
$gt | Greater than | {"$gt": 100} |
$gte | Greater than or equal | {"$gte": 1} |
$lt | Less than | {"$lt": 50} |
$lte | Less than or equal | {"$lte": 999} |
$in | In list | {"$in": [1, 2, 3]} |
$nin | Not in list | {"$nin": [0]} |
Logical Operators
Combine multiple conditions with $and or $or:
json
{
"where": {
"name": {
"$and": [
{"$like": "%draft%"},
{"$ne": "old draft"}
]
}
}
}json
{
"where": {
"name": {
"$or": [
{"$like": "%news%"},
{"$like": "%article%"}
]
}
}
}Multiple Where Fields
When filtering on multiple fields, conditions are combined with AND by default. Use the whereBool parameter (collection only) to switch to OR:
json
{
"where": {
"name": {"$like": "%test%"},
"status": "Open"
},
"whereBool": "$or"
}Sorting
Simple Sort (ascending)
json
{"sort": "name"}Multiple Fields
json
{"sort": ["name", "id"]}With Direction
json
{"sort": {"name": "DESC"}}json
{"sort": [{"name": "ASC"}, {"id": "DESC"}]}Available directions: ASC, DESC, ASC_NULLS_LAST, ASC_NULLS_FIRST, DESC_NULLS_LAST, DESC_NULLS_FIRST.
Sortable Fields by Endpoint
| Endpoint | Sortable Fields |
|---|---|
| Books | name, sort, id |
| Chapters | name, sort, id |
| Issues | name, sort, id |
| Collection | name, sort, id, newdate, any field name |
Pagination
| Parameter | Default | Maximum | Description |
|---|---|---|---|
limit | 1000 | 1000 | Maximum number of results |
offset | 0 | — | Number of results to skip |
json
{"limit": 20, "offset": 40}The response includes pagination metadata:
json
{
"items": [...],
"_count": 150,
"_limit": 20,
"_offset": 40
}Collection-Specific Parameters
The /api/collection endpoint supports additional parameters in the query object:
| Parameter | Type | Default | Description |
|---|---|---|---|
depth | number | 1 | How many levels of referenced contributions are resolved in relation fields (0–3). |
schema | boolean | false | Return JSON Schema describing the response shape instead of data. |
type | string | — | Set to "ts" to return TypeScript type definitions instead of JSON Schema (requires schema: true). |
meta | boolean | false | Return metadata only (omit field values for faster response). |
referenced | boolean / object | false | Include the contributions referencing each result: true or {"depth": n, "limit": n}. See Referenced. |
fields | array | all | Restrict which fields to include (by name or index). |
whereBool | string | $and | Logical operator for combining where conditions ($and or $or). |
Depth
Controls how many levels of references are resolved in relation fields (TypologySelect, TypologyKeyword):
- depth: 0 — Relation fields are not resolved (empty lists)
- depth: 1 (default) — Referenced contributions are included with their fields; their own relation fields are not resolved
- depth: 2 — One more level: the relation fields of the referenced contributions are resolved as well
- depth: 3 — Maximum depth, three levels of nesting
Book, chapter, issue and template of a contribution are added by meta: true, independent of depth. depth does not apply to referenced, which has a depth of its own.
Referenced
referenced adds the contributions referencing each result (the reverse of relation fields) as referenced, plus their total number as referencedCount:
json
{
"id": 5,
"name": "Out of Print",
"referencedCount": 598,
"referenced": [
{"via": {"field": "Status", "id": 15}, "item": {"id": 705, "name": "Luxon V.B.", "sort": 0, "fields": {}}}
],
"fields": {"Value": "Out of Print"}
}via names the field of the referencing contribution that holds the reference. Entries are ordered by the referencing contribution, then by field. Both properties are left out when nothing references the contribution.
referenced is either true or an object with these optional settings:
| Setting | Default | Description |
|---|---|---|
depth | 1 | How deep the referencing contributions are rendered (0–3). Independent of the request's depth, which only applies to the relation fields of the results. |
limit | request limit | Maximum number of referencing contributions per result (1–1000). Without it, the request's limit applies (on /api/item, the limit sent with the request), else 1000. |
A referencing contribution is one level away from the result, so it is rendered like a referenced one in a relation field:
- depth: 0 —
id,nameandsortonly (fieldsis empty). The cheapest way to list who references a contribution. - depth: 1 (default, also for
referenced: true) — with their fields; their relation fields are not resolved - depth: 2, 3 — their relation fields are resolved one or two levels deep
A contribution used by many others (a status value, a category, a country) can be referenced hundreds of times; every referencing contribution is rendered, so set limit and use depth: 0 where the fields are not needed. referencedCount tells whether the list was cut off.
json
{"where": {"template": "Category"}, "limit": 20, "referenced": {"depth": 0, "limit": 5}}Field Selection
Restrict the response to specific fields by name:
json
{
"where": {"template": "Article"},
"fields": ["Title", "Summary"]
}Filtering by Field Content
Use the fields key in the where clause to filter by field data values. This is a key-value map where keys are field names:
json
{
"where": {
"fields": {
"Title": {"$like": "%breaking%"},
"Category": {"$eq": "News"}
}
}
}Schema Mode
Returns a JSON Schema describing the response structure instead of actual data:
json
{"where": {"template": "Article"}, "schema": true}TypeScript Type Output
Add "type": "ts" to the query object to receive TypeScript type definitions instead of JSON Schema:
json
{"where": {"template": "Article"}, "schema": true, "type": "ts"}bash
curl -G http://localhost:8080/api/collection \
-H "Authorization: Bearer API_KEY" \
--data-urlencode 'query={"where":{"template":"Article"},"schema":true,"type":"ts"}'This works on both /api/collection and /api/item endpoints. The same conversion is also available on the /api/schema endpoints via the ?type=ts URL parameter.
Complete Examples
List all open articles, sorted by date
bash
curl -G http://localhost:8080/api/collection \
--data-urlencode 'query={"where":{"template":"Article","status":"Open"},"sort":{"newdate":"DESC"},"limit":20}'Full-text search across field content
bash
curl -G http://localhost:8080/api/collection \
--data-urlencode 'query={"where":{"fields":{"Title":{"$fulltext":"climate change"}}},"limit":50}'Paginated books filtered by name
bash
curl -G http://localhost:8080/api/books \
--data-urlencode 'query={"where":{"name":{"$like":"%annual%"}},"limit":10,"offset":0,"sort":"name"}'Get contributions with nested references
bash
curl -G http://localhost:8080/api/collection \
--data-urlencode 'query={"where":{"book":"Publications"},"depth":2,"referenced":{"depth":1,"limit":10},"limit":5}'Filter issues by book and status
bash
curl -G http://localhost:8080/api/issues \
--data-urlencode 'query={"where":{"forbook":1,"status":"Open"},"sort":{"name":"ASC"}}'