Skip to content

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 ​

OperatorDescriptionExample
$eqEquals{"$eq": "exact match"}
$neNot equals{"$ne": "excluded"}
$likeSQL LIKE (case-sensitive){"$like": "%partial%"}
$ilikeSQL LIKE (case-insensitive){"$ilike": "%partial%"}
$reRegular expression{"$re": "^prefix.*"}
$gtGreater than{"$gt": "B"}
$gteGreater than or equal{"$gte": "B"}
$ltLess than{"$lt": "M"}
$lteLess than or equal{"$lte": "M"}
$inIn list{"$in": ["a", "b"]}
$ninNot in list{"$nin": ["x", "y"]}
$containsJSON contains{"$contains": "value"}
$containedJSON contained by{"$contained": "value"}
$fulltextFull-text search{"$fulltext": "search terms"}

Numeric Operators ​

OperatorDescriptionExample
$eqEquals{"$eq": 42}
$neNot equals{"$ne": 0}
$gtGreater than{"$gt": 100}
$gteGreater than or equal{"$gte": 1}
$ltLess than{"$lt": 50}
$lteLess than or equal{"$lte": 999}
$inIn list{"$in": [1, 2, 3]}
$ninNot 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 ​

EndpointSortable Fields
Booksname, sort, id
Chaptersname, sort, id
Issuesname, sort, id
Collectionname, sort, id, newdate, any field name

Pagination ​

ParameterDefaultMaximumDescription
limit10001000Maximum number of results
offset0—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:

ParameterTypeDefaultDescription
depthnumber1How many levels of referenced contributions are resolved in relation fields (0–3).
schemabooleanfalseReturn JSON Schema describing the response shape instead of data.
typestring—Set to "ts" to return TypeScript type definitions instead of JSON Schema (requires schema: true).
metabooleanfalseReturn metadata only (omit field values for faster response).
referencedboolean / objectfalseInclude the contributions referencing each result: true or {"depth": n, "limit": n}. See Referenced.
fieldsarrayallRestrict which fields to include (by name or index).
whereBoolstring$andLogical 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:

SettingDefaultDescription
depth1How deep the referencing contributions are rendered (0–3). Independent of the request's depth, which only applies to the relation fields of the results.
limitrequest limitMaximum 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, name and sort only (fields is 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"}}'