Build your personal knowledge base with Trilium Notes
Backend API
BackendApi
The api global available inside backend script notes (application/javascript;env=backend). Runs server-side: no DOM, no jQuery.
| Member | Description | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
startNoteoptional |
|
||||||||||
currentNote |
|
||||||||||
originEntityoptional |
|
||||||||||
req |
|
||||||||||
res |
|
||||||||||
pathParams |
|
||||||||||
dayjs |
|
||||||||||
xml2js |
|
||||||||||
htmlParser |
|
||||||||||
getInstanceName |
Instance name identifies particular Trilium instance. It can be useful for scripts if some action needs to happen on only one specific instance. |
||||||||||
getNote |
Returns a note by its ID, or null. |
||||||||||
getBranch |
Returns a branch by its ID, or null. |
||||||||||
getAttribute |
Returns an attribute by its ID, or null. |
||||||||||
getAttachment |
Returns an attachment by its ID, or null. |
||||||||||
getRevision |
Returns a revision by its ID, or null. |
||||||||||
getEtapiToken |
Returns an ETAPI token by its ID, or null. |
||||||||||
getEtapiTokens |
Returns all ETAPI tokens. |
||||||||||
getOption |
Returns an option by name, or null. |
||||||||||
getOptions |
Returns all options. |
||||||||||
searchForNotes |
This is a powerful search method - you can search by attributes and their values, e.g.: "#dateModified =* MONTH AND #log". See |
||||||||||
searchForNote |
This is a powerful search method - you can search by attributes and their values, e.g.: "#dateModified =* MONTH AND #log". See |
||||||||||
getNotesWithLabel |
Retrieves notes with given label name & value
|
||||||||||
getNoteWithLabel |
Retrieves first note with given label name & value
|
||||||||||
ensureNoteIsPresentInParent |
If there's no branch between note and parent note, create one. Otherwise, do nothing. Returns the new or existing branch.
|
||||||||||
ensureNoteIsAbsentFromParent |
If there's a branch between note and parent note, remove it. Otherwise, do nothing. |
||||||||||
toggleNoteInParent |
Based on the value, either create or remove branch between note and parent note.
|
||||||||||
createTextNote |
Create text note. See also createNewNote() for more options. |
||||||||||
createDataNote |
Create data note - data in this context means object serializable to JSON. Created note will be of type 'code' and JSON MIME type. See also createNewNote() for more options. |
||||||||||
createNewNote |
Returns |
||||||||||
logMessages |
|
||||||||||
logSpacedUpdates |
|
||||||||||
log |
Log given message to trilium logs and log pane in UI. Accepts multiple arguments which are joined with spaces, similar to |
||||||||||
getRootCalendarNote |
Returns root note of the calendar. |
||||||||||
getDayNote |
Returns day note for given date. If such note doesn't exist, it is created.
|
||||||||||
getTodayNote |
Returns today's day note. If such note doesn't exist, it is created.
|
||||||||||
getWeekFirstDayNote |
Returns note for the first date of the week of the given date.
|
||||||||||
getWeekNote |
Returns week note for given date. If such a note doesn't exist, it is created. If the calendar does not support week notes, this method will return `null`.
Returns |
||||||||||
getMonthNote |
Returns month note for given date. If such a note doesn't exist, it is created.
|
||||||||||
getQuarterNote |
Returns quarter note for given date. If such a note doesn't exist, it is created.
|
||||||||||
getYearNote |
Returns year note for given year. If such a note doesn't exist, it is created.
|
||||||||||
sortNotes |
Sort child notes of a given note. |
||||||||||
setNoteToParent |
This method finds note by its noteId and prefix and either sets it to the given parentNoteId or removes the branch (if parentNoteId is not given). This method looks similar to toggleNoteInParent() but differs because we're looking up branch by prefix. |
||||||||||
transactional |
This functions wraps code which is supposed to be running in transaction. If transaction already exists, then we'll use that transaction. Returns |
||||||||||
randomString |
Return randomly generated string of given length. This random string generation is NOT cryptographically secure.
Returns |
||||||||||
escapeHtml |
Returns |
||||||||||
unescapeHtml |
Returns |
||||||||||
htmlToMarkdown |
Converts the given HTML string to Markdown.
Returns |
||||||||||
markdownToHtml |
Converts the given Markdown string to HTML.
Returns |
||||||||||
sql |
|
||||||||||
getAppInfo |
Application info (version, build date, etc.). |
||||||||||
createOrUpdateLauncher |
Creates a new launcher to the launchbar. If the launcher (id) already exists, it will be updated. |
||||||||||
exportSubtreeToZipFile |
|
||||||||||
runOnFrontend |
Executes given anonymous function on the frontend(s). Internally, this serializes the anonymous function into string and sends it to frontend(s) via WebSocket. Note that there can be multiple connected frontend instances (e.g. in different tabs). In such case, all instances execute the given function.
Returns |
||||||||||
runOutsideOfSync |
Sync process can make data intermittently inconsistent. Scripts which require strong data consistency can use this function to wait for a possible sync process to finish and prevent new sync process from starting while it is running. Because this is an async process, the inner callback doesn't have automatic transaction handling, so in case you need to make some DB changes, you need to surround your call with api.transactional(...)
Returns |
||||||||||
backupNow |
Returns |
||||||||||
duplicateSubtree |
Enables the complete duplication of the specified original note and all its children into the specified parent note. The new note will be named the same as the original, with (Dup) added to the end of it.
Returns |
BNote
A note as seen by backend scripts (subset of trilium-core's BNote).
| Member | Description | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
noteId |
|
||||||||||
title |
|
||||||||||
type |
|
||||||||||
mime |
|
||||||||||
isProtected |
|
||||||||||
isArchived |
|
||||||||||
isDeleted |
|
||||||||||
shareId |
|
||||||||||
blobId |
|
||||||||||
dateCreated |
|
||||||||||
dateModified |
|
||||||||||
utcDateCreated |
|
||||||||||
utcDateModified |
|
||||||||||
getContent |
Returns the content of the note: a string for text-based notes (see |
||||||||||
setContent |
Replaces the content of the note and saves it immediately; there is no need to call The call throws an error when
|
||||||||||
getJsonContent |
Returns the note's content parsed as JSON. Returns |
||||||||||
getJsonContentSafely |
Returns the note's content parsed as JSON, like |
||||||||||
setJsonContent |
Serializes |
||||||||||
hasStringContent |
Returns whether |
||||||||||
getFileName |
Returns a file name for the note, as used when it is downloaded or exported: the title with characters invalid in file names removed ( |
||||||||||
getFlatText |
Returns a single line of text that Trilium searches when matching notes: the note ID, type, MIME type, branch prefixes, title and attributes (as |
||||||||||
getPojo |
Plain serialisable representation of the note (the real return type is |
||||||||||
getTitleOrProtected |
Returns the note's title, or the literal string |
||||||||||
getIcon |
Returns the CSS classes of the note's icon, for example |
||||||||||
parents |
|
||||||||||
children |
|
||||||||||
parentBranches |
|
||||||||||
parentCount |
|
||||||||||
childrenCount |
|
||||||||||
getParentNotes |
Returns the parent notes of this note, one per place the note appears in the tree. Parents that are not archived come first. The result is the |
||||||||||
getChildNotes |
Returns the child notes of this note, in their order in the tree. The result is the |
||||||||||
getVisibleChildNotes |
Returns the child notes that are shown in a shared note's navigation tree, in tree order. It leaves out system notes, whose IDs start with |
||||||||||
getParentBranches |
Returns the branches that place this note under each of its parents. The result is the |
||||||||||
getChildBranches |
Returns the branches that connect this note to each of its children, in their order in the tree. A branch holds the child's position and prefix. |
||||||||||
getVisibleChildBranches |
Returns the child branches whose notes are shown in a shared note's navigation tree, in tree order. It leaves out system notes, whose IDs start with |
||||||||||
getStrongParentBranches |
Returns the parent branches the user created, leaving out the automatic placements under the shared notes ( |
||||||||||
getFilteredChildBranches |
Returns the same branches as |
||||||||||
getBranches |
Returns the branches that place this note under each of its parents. |
||||||||||
hasChildren |
Returns whether the note has at least one child note, including hidden and system notes. |
||||||||||
hasVisibleChildren |
Returns whether |
||||||||||
getAncestors |
Returns every ancestor of the note across all of its paths in the tree, each note once, up to and including the root note. The note itself is not included. The order follows the parents: each parent comes first, followed by its own ancestors. |
||||||||||
getAncestorNoteIds |
Returns the IDs of the notes |
||||||||||
getDescendantNoteIds |
Returns the IDs of this note and all its descendants. |
||||||||||
getDistanceToAncestor |
Returns the number of levels between this note and the given ancestor along the shortest path:
|
||||||||||
hasAncestor |
Returns whether the given note is an ancestor of this note on any of its paths. It returns
|
||||||||||
isDescendantOfNote |
Returns whether the given note lies on at least one of this note's paths from the root. Unlike |
||||||||||
isRoot |
Returns whether this note is the root of the note tree, whose ID is |
||||||||||
getSubtree |
Returns the note and all its descendants, each note once, together with every parent-child relationship among them, including those of cloned notes. Returns |
||||||||||
getSubtreeNoteIds |
Returns the IDs of this note and all its descendants, each once. Takes the same options as |
||||||||||
getSubtreeNotesIncludingTemplated |
Returns the notes that this note's inheritable attributes reach: the note itself, its descendants, and every note that uses one of them as a |
||||||||||
getInheritingNotes |
Returns the notes that this note's non-inheritable attributes apply to: the note itself and every note that uses it as a |
||||||||||
getAllNotePaths |
Returns every path from the root note to this note, one per placement in the tree. Each path is an array of note IDs that starts with |
||||||||||
getBestNotePath |
Returns the best path from the root note to this note as an array of note IDs, ranked as in
|
||||||||||
getBestNotePathString |
Returns the best path from the root note to this note as a string of note IDs joined by
|
||||||||||
getSortedNotePathRecords |
Returns a record for every path from the root note to this note, best path first. Paths within the hoisted note's subtree come first, then paths without archived notes, then paths outside the hidden subtree, then shorter paths.
Returns |
||||||||||
areAllNotePathsArchived |
Returns whether every path to this note passes through an archived note. Unlike |
||||||||||
ownedAttributes |
|
||||||||||
targetRelations |
|
||||||||||
attributeCount |
|
||||||||||
ownedAttributeCount |
|
||||||||||
labelCount |
|
||||||||||
ownedLabelCount |
|
||||||||||
relationCount |
|
||||||||||
relationCountIncludingLinks |
|
||||||||||
ownedRelationCount |
|
||||||||||
ownedRelationCountIncludingLinks |
|
||||||||||
targetRelationCount |
|
||||||||||
targetRelationCountIncludingLinks |
|
||||||||||
getAttributes |
Returns the labels and relations of this note, inherited ones included, optionally filtered by type and name. Without a filter, the result is the note's own cached array; don't modify it.
|
||||||||||
getOwnedAttributes |
Returns the labels and relations defined directly on this note, optionally filtered by type and name. Without a filter, the result is the
|
||||||||||
getAttribute |
Returns the first attribute of the given type and name, inherited ones included, or
|
||||||||||
getOwnedAttribute |
Returns the first attribute of the given type and name defined directly on this note, or
|
||||||||||
getAttributeValue |
Returns the value of the first attribute of the given type and name, inherited ones included, or
|
||||||||||
getOwnedAttributeValue |
Returns the value of the first attribute of the given type and name defined directly on this note, or
|
||||||||||
getAttributeById |
Returns the attribute of this note with the given ID, inherited ones included, or |
||||||||||
getAttributeCaseInsensitive |
Returns the first attribute of the given type whose name, and optionally value, matches regardless of letter case, or
|
||||||||||
hasAttribute |
Returns
|
||||||||||
hasOwnedAttribute |
Returns whether the note has a label or relation of the given type and name defined directly on it. Inherited attributes don't count.
|
||||||||||
getLabelDefinitions |
Returns the attribute definitions on this note, inherited ones included. Currently returns the same |
||||||||||
getRelationDefinitions |
Returns the relation definitions on this note, inherited ones included: the |
||||||||||
getTargetRelations |
Returns the relations in other notes (or this one) that point to this note, the automatic link relations included. Same as |
||||||||||
getLabel |
Returns the first label with the given name, inherited ones included, or |
||||||||||
getOwnedLabel |
Returns the first label with the given name defined directly on this note, or |
||||||||||
getLabels |
Returns the labels of this note, inherited ones included. When |
||||||||||
getOwnedLabels |
Returns the labels with the given name defined directly on this note. |
||||||||||
getLabelValue |
Returns the value of the first label with the given name, inherited ones included, or |
||||||||||
getOwnedLabelValue |
Returns the value of the first label with the given name defined directly on this note, or |
||||||||||
getLabelValues |
Returns the values of all labels with the given name, inherited ones included, for labels that can occur more than once. |
||||||||||
getOwnedLabelValues |
Returns the values of all labels with the given name defined directly on this note. |
||||||||||
hasLabel |
Returns whether the note has a label with the given name, inherited ones included. |
||||||||||
hasOwnedLabel |
Returns whether the note has a label with the given name defined directly on it.
|
||||||||||
isLabelTruthy |
Returns whether the note has a label with the given name, inherited ones included, whose value is not |
||||||||||
hasInheritableArchivedLabel |
Returns |
||||||||||
getRelation |
Returns the first relation with the given name, inherited ones included, or |
||||||||||
getOwnedRelation |
Returns the first relation with the given name defined directly on this note, or |
||||||||||
getRelations |
Returns the relations of this note, inherited ones included. When |
||||||||||
getOwnedRelations |
Returns the relations defined directly on this note. When |
||||||||||
getRelationValue |
Returns the ID of the note that the first relation with the given name points to, inherited relations included, or |
||||||||||
getOwnedRelationValue |
Returns the ID of the note that the first relation with the given name defined directly on this note points to, or |
||||||||||
getRelationTarget |
Returns the note that the first relation with the given name points to, or |
||||||||||
hasRelation |
Returns whether the note has a relation with the given name, inherited ones included.
|
||||||||||
hasOwnedRelation |
Returns whether the note has a relation with the given name defined directly on it.
|
||||||||||
addLabel |
Adds a label to this note, saves it and returns it. It adds a new label even when the note already has one with that name; to change an existing label instead, use
|
||||||||||
addRelation |
Adds a relation from this note to another note, saves it and returns it. It adds a new relation even when the note already has one with that name; to change an existing relation instead, use
|
||||||||||
addAttribute |
Adds a label or relation to this note, saves it and returns it.
|
||||||||||
setLabel |
Sets the value of the first label with the given name defined directly on this note, or adds a non-inheritable label if the note has none of its own. Inherited labels are left alone. The change is saved immediately.
|
||||||||||
setRelation |
Points the first relation with the given name defined directly on this note to another note, or adds a non-inheritable relation if the note has none of its own. Inherited relations are left alone. The change is saved immediately.
|
||||||||||
setAttribute |
Sets the value of the first attribute of the given type and name defined directly on this note, or adds a non-inheritable one if the note has none of its own.
|
||||||||||
setAttributeValueById |
Sets the value of the attribute with the given ID, which must be defined directly on this note, and saves it. Throws an error if the note has no such attribute of its own.
|
||||||||||
toggleLabel |
Sets the label like |
||||||||||
toggleRelation |
Sets the relation like
|
||||||||||
toggleAttribute |
Sets the attribute like
|
||||||||||
removeLabel |
Removes every label with the given name defined directly on this note. Inherited labels are not affected.
|
||||||||||
removeRelation |
Removes every relation with the given name defined directly on this note. Inherited relations are not affected.
|
||||||||||
removeAttribute |
Removes every attribute of the given type and name defined directly on this note. Inherited attributes are not affected.
|
||||||||||
isInherited |
Returns |
||||||||||
revisionCount |
|
||||||||||
getRevisions |
Returns the saved revisions of this note, oldest first. |
||||||||||
saveRevision |
Saves a revision that snapshots the note's current title, content and attachments, and returns it. Afterwards, Trilium erases the oldest revisions beyond the number the revision settings keep.
|
||||||||||
getAttachments |
Returns the attachments of this note, ordered by position. Deleted attachments are excluded. |
||||||||||
getAttachmentById |
Returns the attachment of this note with the given ID. Returns |
||||||||||
getAttachmentByTitle |
Returns the first attachment of this note whose title matches exactly, or |
||||||||||
getAttachmentsByRole |
Returns the attachments of this note with the given role, such as |
||||||||||
saveAttachment |
Saves an attachment of this note and returns it. If an existing attachment matches, only its content is replaced; otherwise a new attachment is created from
|
||||||||||
convertToParentAttachment |
Converts this image note into an image attachment of its parent text note, points the parent's content at the attachment, deletes this note and returns the attachment. Returns
|
||||||||||
isEligibleForConversionToAttachment |
Returns
|
||||||||||
contentSize |
|
||||||||||
contentAndAttachmentsSize |
|
||||||||||
contentAndAttachmentsAndRevisionsSize |
|
||||||||||
cloneTo |
Places this note under another parent note as well, keeping its existing placements, and expands the new parent in the note tree. The result does not throw on failure; check
Returns |
||||||||||
deleteNote |
Deletes the note from every place in the tree, together with its descendants that have no other placement, and runs its
|
||||||||||
sortParents |
Reorders this note's |
||||||||||
sortChildren |
Reorders this note's |
||||||||||
searchNotesInSubtree |
Returns the notes that match a search query. Despite the name, the search covers the whole tree, not only this note's subtree, and leaves out archived and hidden notes; to limit it to this note's subtree, call |
||||||||||
searchNoteInSubtree |
Returns the first note that matches a search query, or |
||||||||||
getSearchResultNotes |
Runs the saved search of a search note and returns the notes it finds. Returns an empty array for other note types, and when the search fails (the error goes to the backend log). |
||||||||||
isFolder |
Returns |
||||||||||
isContentAvailable |
Returns |
||||||||||
isStringNote |
Returns whether |
||||||||||
isHtml |
Returns whether this is a code, file or render note with the MIME type |
||||||||||
isImage |
Returns whether this is an image note, or a file note with an |
||||||||||
isJavaScript |
Returns whether this is a code, file or launcher note with a JavaScript MIME type. |
||||||||||
isJsx |
Returns |
||||||||||
isJson |
Returns whether the note's MIME type is |
||||||||||
isMarkdown |
Returns whether this is a code note with a Markdown MIME type. |
||||||||||
isOptions |
Returns |
||||||||||
isLaunchBarConfig |
Returns |
||||||||||
isHiddenCompletely |
Returns whether every path to this note passes through the hidden subtree ( |
||||||||||
isInHiddenSubtree |
Returns |
||||||||||
getScriptEnv |
Returns where the note runs as a script: |
||||||||||
executeScript |
Runs this note as a backend script and returns the script's return value, which is a promise for an async script. The note must be a backend JavaScript code note; for any other note it runs nothing and returns |
BBranch
A branch (note→parent placement) as seen by backend scripts (subset of BBranch).
| Member | Description |
|---|---|
branchId |
|
noteId |
|
parentNoteId |
|
prefix |
|
notePosition |
|
isExpanded |
|
getNote |
Returns the child note this branch places in the tree. |
getParentNote |
Returns the parent note. The root note's branch has no parent note. |
Request
Minimal Express Request surface available to custom request handlers (a subset of Express's Request — re-declared here to keep this module self-contained). Only the commonly used members are typed; the real object is a full Express request.
| Member | Description |
|---|---|
params |
|
query |
|
body |
|
headers |
|
method |
|
url |
|
get |
Returns the value of the given (case-insensitive) header. |
Response
Minimal Express Response surface available to custom request handlers (a subset of Express's Response). Write the HTTP response through this object, e.g. api.res.status(200).json({ ok: true }).
| Member | Description |
|---|---|
status |
Sets the HTTP status code (chainable). |
send |
Sends the response body (string, Buffer, object, …) and ends the response. |
json |
Sends a JSON response and ends the response. |
setHeader |
Sets a response header (chainable). |
set |
Sets a response header (Express alias of |
redirect |
Redirects to the given URL. |
end |
Ends the response without further data. |
BAttachment
An attachment as seen by backend scripts (subset of trilium-core's BAttachment).
| Member | Description | ||||
|---|---|---|---|---|---|
attachmentIdoptional |
|
||||
ownerId |
|
||||
role |
|
||||
mime |
|
||||
title |
|
||||
positionoptional |
|
||||
isProtectedoptional |
|
||||
blobIdoptional |
|
||||
utcDateModifiedoptional |
|
||||
contentLengthoptional |
|
||||
getNote |
Returns the note the attachment belongs to, or |
||||
getContent |
Returns the content: a string for text-based content, a |
||||
setContent |
Replaces the content and saves it immediately. Throws an error for a protected attachment outside a protected session. |
||||
hasStringContent |
Returns whether the content is text rather than binary, judged by the MIME type. |
||||
isContentAvailable |
Returns whether the title and content can be read: the attachment is not protected, or a protected session is active. |
||||
getTitleOrProtected |
Returns the title, or |
||||
getFileName |
Returns the file name the attachment downloads under: its title with a fitting extension. |
||||
convertToNote |
Turns the attachment into a child note of its owner and deletes the attachment. In a text note, images and links that point to the attachment are rewritten to point to the new note. Throws an error for a revision's attachment, and for a protected one outside a protected session. |
||||
save |
Saves changes made to the attachment's properties, such as |
||||
markAsDeleted |
Deletes the attachment. Deleted attachments stay recoverable until they are erased.
|
BRevision
A note revision as seen by backend scripts (subset of trilium-core's BRevision).
| Member | Description |
|---|---|
revisionIdoptional |
|
noteId |
|
type |
|
mime |
|
title |
|
dateLastEditedoptional |
|
utcDateLastEditedoptional |
|
contentLengthoptional |
|
getContent |
Returns the content of the revision: a string for text-based note types, a |
getJsonContent |
Returns the revision's content parsed as JSON. Returns |
Sql
Direct access to Trilium's SQLite database (subset of trilium-core's SqlService). Queries mark parameters with ? and take their values in an array, in order. Changes made here bypass Trilium's own bookkeeping: they do not sync, and Trilium's in-memory copy of the notes does not see them until the next restart. Change notes through the note methods instead.
| Member | Description |
|---|---|
getRow |
Returns the first row of the result, as an object of column names to values, or |
getRowOrNull |
Returns the first row of the result, or |
getValue |
Returns the first column of the first row, such as the count of |
getRows |
Returns every row of the result, each as an object of column names to values. |
getColumn |
Returns the first column of every row of the result. |
getMap |
Returns an object that maps the first column of each row to its second column. |
iterateRows |
Returns the rows of the result one at a time, which keeps a large result out of memory. |
execute |
Runs a statement that changes data, such as Returns |
executeScript |
Runs several statements separated by semicolons, without parameters. |
transactional |
Calls Returns |
DayjsInstance
A date as day.js wraps it (subset).
| Member | Description | ||||||
|---|---|---|---|---|---|---|---|
format |
Formats the date, such as |
||||||
add |
Returns a new date,
|
||||||
subtract |
Returns a new date,
|
||||||
toDate |
Returns the date as a JavaScript |
Types
Attribute
A label or relation attached to a note.
| Property | Description |
|---|---|
attributeId |
string The ID of the attribute. |
type |
"label" | "relation" The type of the attribute: label or relation. |
name |
string The name of the attribute, without the # or ~ prefix. |
value |
string The value of the attribute. For a relation, it is the ID of the target note. For a label without a value, it is an empty string. |
isInheritable |
boolean Whether the note's descendants inherit the attribute. |
isOwned |
boolean Not set by Trilium: neither frontend nor backend attributes carry this property, so it reads undefined. |
Dayjs
Minimal day.js surface (the real API exposes the full day.js factory).
type Dayjs = (date?: string | number | Date) => DayjsInstance
Xml2js
The xml2js library, version 0.6, which converts between XML and JavaScript objects, such as with xml2js.parseStringPromise(xml).
HtmlParser
The node-html-parser library, version 9, which parses HTML into elements that can be queried, such as with htmlParser.parse(html).querySelectorAll("a").
BEtapiToken
An ETAPI token, which grants an external program access to the ETAPI (subset of trilium-core's BEtapiToken). The token itself is not available, only its hash, which this type leaves out.
| Property | Description |
|---|---|
etapiTokenId optional |
string The ID of the token. |
name |
string The name given to the token when it was created. |
utcDateCreated |
string The date and time, in UTC, that the token was created. |
utcDateModified optional |
string The date and time, in UTC, that the token was last changed, such as renamed. |
isDeleted |
boolean Whether the token has been deleted, which revokes it. |
BOption
An option, one of Trilium's settings (subset of trilium-core's BOption).
| Property | Description |
|---|---|
name |
string The name of the option, such as theme or locale. |
value |
string The value of the option. Every value is a string, numbers and booleans included. |
isSynced optional |
boolean Whether the option syncs to other devices; device-specific options do not. |
utcDateModified optional |
string The date and time, in UTC, that the option last changed. |
SearchParams
Options of api.searchForNotes() and api.searchForNote().
| Property | Description |
|---|---|
fastSearch optional |
boolean Whether to search only titles and attributes, leaving out note content, which is faster. Defaults to false. |
includeArchivedNotes optional |
boolean Whether to include archived notes. Defaults to true. |
includeHiddenNotes optional |
boolean Whether to include the hidden subtree's notes, such as settings and launchers. Defaults to false. |
ignoreHoistedNote optional |
boolean Whether to search the whole tree even while a note is hoisted. Defaults to true; with false and no ancestorNoteId, only the hoisted note's subtree is searched. |
ancestorNoteId optional |
string The ID of a note to search under: only its descendants are found. |
ancestorDepth optional |
string How deep under ancestorNoteId the found notes can lie: eq, gt or lt followed by a depth, such as eq1 for its children only or lt4 for less than four levels down. |
orderBy optional |
string What to order the results by: a note property such as title, dateCreated or dateModified, or relevancy, the default. |
orderDirection optional |
string asc or desc; the direction of orderBy. |
limit optional |
number | null The largest number of results to return. |
debug optional |
boolean Whether to write how the query was parsed to the backend log. |
fuzzyAttributeSearch optional |
boolean Whether attribute conditions match loosely: #status=done also matches values that contain done, and #stat matches attributes whose name starts with stat. Defaults to false. |
NoteAndBranch
Result of the backend note-creation helpers.
| Property | Description |
|---|---|
note |
BNote The new note. For duplicateSubtree(), it is the copy of the original note. |
branch |
BBranch The branch that places the new note under its parent. |
AppInfo
Information about the running Trilium, as api.getAppInfo() returns it.
| Property | Description |
|---|---|
appVersion |
string The version of Trilium, such as 0.106.0. |
dbVersion |
number The version of the database schema. |
nodeVersion optional |
string The version of Node.js; absent in the standalone and mobile apps, which have no Node.js. |
syncVersion |
number The version of the sync protocol, which both sides of a sync must share. |
buildDate |
string When this build of Trilium was made. |
buildRevision |
string The Git commit this build of Trilium was made from. |
dataDirectory optional |
string The directory that holds the database and the other data; absent in the standalone and mobile apps. |
clipperProtocolVersion |
string The version of the protocol the web clipper speaks with Trilium. |
utcDateTime |
string The date and time, in UTC, that Trilium started, in ISO 8601 form. |
SubtreeOpts
Options accepted by the subtree traversal helpers on BNote.
| Property | Description |
|---|---|
includeArchived optional |
boolean Whether to include archived notes and their descendants. Defaults to true. |
includeHidden optional |
boolean Whether to descend into the hidden subtree, _hidden, which holds Trilium's system notes. Defaults to false. |
resolveSearch optional |
boolean Whether to run each search note and include its results as its children. Defaults to false, which includes the search note but none of its results. |
SubtreeRelationship
A single parent→child link in a subtree (BNote.getSubtree).
| Property | Description |
|---|---|
parentNoteId |
string The ID of the parent note. With resolveSearch, it can be a search note and the child one of its results. |
childNoteId |
string The ID of the child note. With includeArchived: false, it can name an archived note that the list of notes leaves out. |
NotePathRecord
One resolved tree path to a note (subset of the client's NotePathRecord).
| Property | Description |
|---|---|
isArchived |
boolean Whether a note on the path, the note itself included, is archived, which means it has the #archived label, owned or inherited. |
isInHoistedSubTree |
boolean Whether the path passes through the hoisted note passed to getSortedNotePathRecords(). It is always true when the hoisted note is root. |
isSearch optional |
boolean Whether the note itself is a search note. Only frontend scripts get this property; backend records leave it out. |
notePath |
string[] The note IDs along the path, from root to the note itself. |
isHidden |
boolean Whether the path passes through the hidden subtree, _hidden, which holds Trilium's system notes. |
SaveAttachmentInput
Input accepted by BNote.saveAttachment.
| Property | Description |
|---|---|
attachmentId optional |
string The ID of the attachment to update. Omit it to create a new attachment, which gets an ID of its own. |
role |
string The purpose of the attachment, such as image or file. Used only when a new attachment is created. |
mime |
string The MIME type of the content, such as image/png. Used only when a new attachment is created. |
title |
string The title of the attachment, usually its file name. Used when a new attachment is created, and to find the attachment to update when matchBy is "title". |
content optional |
string | Uint8Array<ArrayBufferLike> The content of the attachment: a string, or bytes for binary content. Defaults to an empty string. |
position optional |
number The place of the attachment among the note's attachments, which getAttachments() lists by ascending position. Used only when a new attachment is created. |
CloneResponse
Result of a clone operation (BNote.cloneTo); mirrors CloneResponse.
| Property | Description |
|---|---|
success |
boolean Whether the note was cloned. |
message optional |
string Why the clone failed, such as the note already being in that parent. Present only when success is false. |
branchId optional |
string The ID of the new branch that places the note under the new parent. Present only when success is true. |
notePath optional |
string The path of the clone, as note IDs from root joined by /, ending in the note's ID. Present only when success is true. |