description:search query string as described in https://github.com/zadam/trilium/wiki/Search
schema:
type:string
examples:
fulltext:
summary:Fulltext search for keywords (not exact match)
value:'towers tolkien'
fulltextExactMatch:
summary:Fulltext search for exact match (notice the double quotes)
value:'"Two Towers"'
fulltextWithLabel:
summary:Fulltext search for keyword AND matching label
value:'towers #book'
- name:fastSearch
in:query
required:false
description:enable fast search (fulltext doesn't look into content)
schema:
type:boolean
default:false
- name:includeArchivedNotes
in:query
required:false
description:search by default ignores archived notes. Set to 'true' to includes archived notes into search results.
schema:
type:boolean
default:false
- name:ancestorNoteId
in:query
required:false
description:search only in a subtree identified by the subtree noteId. By default whole tree is searched.
schema:
$ref:'#/components/schemas/EntityId'
- name:ancestorDepth
in:query
required:false
description:define how deep in the tree should the notes be searched
schema:
type:string
examples:
directChildren:
summary:depth of exactly 1 (direct children) to the ancestor (root if not set)
value:eq1
grandGrandChildren:
summary:depth of exactly 3 to the ancestor (root if not set)
value:eq3
lessThan4:
summary:depth less than 4 (so 1, 2, 3) to the ancestor (root if not set)
value:lt4
greaterThan2:
summary:depth greater than 2 (so 3, 4, 5, 6...) to the ancestor (root if not set)
value:gt4
- name:orderBy
in:query
required:false
description:name of the property/label to order search results by
schema:
type:string
example:
- title
- '#publicationDate'
- isProtected
- isArchived
- dateCreated
- dateModified
- utcDateCreated
- utcDateModified
- parentCount
- childrenCount
- attributeCount
- labelCount
- ownedLabelCount
- relationCount
- ownedRelationCount
- relationCountIncludingLinks
- ownedRelationCountIncludingLinks
- targetRelationCount
- targetRelationCountIncludingLinks
- contentSize
- noteSize
- revisionCount
- name:orderDirection
in:query
required:false
description:order direction, ascending or descending
schema:
type:string
default:asc
enum:
- asc
- desc
- name:limit
in:query
required:false
description:limit the number of results you want to receive
schema:
type:integer
example:10
- name:debug
in:query
required:false
description:set to true to get debug information in the response (search query parsing)
schema:
type:boolean
default:false
responses:
'200':
description:search response
content:
application/json:
schema:
$ref:'#/components/schemas/SearchResponse'
default:
description:unexpected error
content:
application/json:
schema:
$ref:'#/components/schemas/Error'
/notes/{noteId}:
parameters:
- name:noteId
in:path
required:true
schema:
$ref:'#/components/schemas/EntityId'
get:
description:Returns a note identified by its ID
operationId:getNoteById
responses:
'200':
description:note response
@ -69,12 +197,6 @@ paths:
patch:
description:patch a note identified by the noteId with changes in the body
operationId:patchNoteById
parameters:
- name:noteId
in:path
required:true
schema:
$ref:'#/components/schemas/EntityId'
requestBody:
required:true
content:
@ -97,13 +219,6 @@ paths:
delete:
description:deletes a single note based on the noteId supplied
operationId:deleteNoteById
parameters:
- name:noteId
in:path
description:noteId of note to delete
required:true
schema:
$ref:'#/components/schemas/EntityId'
responses:
'204':
description:note deleted
@ -114,15 +229,15 @@ paths:
schema:
$ref:'#/components/schemas/Error'
/branches/{branchId}:
parameters:
- name:branchId
in:path
required:true
schema:
$ref:'#/components/schemas/EntityId'
get:
description:Returns a branch identified by its ID
operationId:getBranchById
parameters:
- name:branchId
in:path
required:true
schema:
$ref:'#/components/schemas/EntityId'
responses:
'200':
description:branch response
@ -161,12 +276,6 @@ paths:
patch:
description:patch a branch identified by the branchId with changes in the body
operationId:patchBranchById
parameters:
- name:branchId
in:path
required:true
schema:
$ref:'#/components/schemas/EntityId'
requestBody:
required:true
content:
@ -187,15 +296,10 @@ paths:
schema:
$ref:'#/components/schemas/Error'
delete:
description:deletes a branch based on the branchId supplied. If this is the last branch of the (child) note, then the note is deleted as well.
description:>
deletes a branch based on the branchId supplied. If this is the last branch of the (child) note,
then the note is deleted as well.
operationId:deleteBranchById
parameters:
- name:branchId
in:path
description:branchId of note to delete
required:true
schema:
$ref:'#/components/schemas/EntityId'
responses:
'204':
description:branch deleted
@ -206,15 +310,15 @@ paths:
schema:
$ref:'#/components/schemas/Error'
/attributes/{attributeId}:
parameters:
- name:attributeId
in:path
required:true
schema:
$ref:'#/components/schemas/EntityId'
get:
description:Returns an attribute identified by its ID
operationId:getAttributeById
parameters:
- name:attributeId
in:path
required:true
schema:
$ref:'#/components/schemas/EntityId'
responses:
'200':
description:attribute response
@ -253,12 +357,6 @@ paths:
patch:
description:patch a attribute identified by the attributeId with changes in the body
operationId:patchAttributeById
parameters:
- name:attributeId
in:path
required:true
schema:
$ref:'#/components/schemas/EntityId'
requestBody:
required:true
content:
@ -281,13 +379,6 @@ paths:
delete:
description:deletes a attribute based on the attributeId supplied.
operationId:deleteAttributeById
parameters:
- name:attributeId
in:path
description:attributeId of attribute to delete
required:true
schema:
$ref:'#/components/schemas/EntityId'
responses:
'204':
description:attribute deleted
@ -298,8 +389,17 @@ paths:
schema:
$ref:'#/components/schemas/Error'
/refresh-note-ordering/{parentNoteId}:
parameters:
- name:parentNoteId
in:path
required:true
schema:
$ref:'#/components/schemas/EntityId'
post:
description:notePositions in branches are not automatically pushed to connected clients and need a specific instruction. If you want your changes to be in effect immediately, call this service after setting branches' notePosition. Note that you need to supply "parentNoteId" of branch(es) with changed positions.
description:>
notePositions in branches are not automatically pushed to connected clients and need a specific instruction.
If you want your changes to be in effect immediately, call this service after setting branches' notePosition.
Note that you need to supply "parentNoteId" of branch(es) with changed positions.
operationId:postRefreshNoteOrdering
responses:
'204':
@ -310,29 +410,230 @@ paths:
application/json:
schema:
$ref:'#/components/schemas/Error'
/inbox/{date}:
get:
description:>
returns an "inbox" note, into which note can be created. Date will be used depending on whether the inbox
is a fixed note (identified with#inbox label) or a day note in a journal.
operationId:getInboxNote
parameters:
- name:date
in:path
required:true
schema:
type:string
format:date
example:2022-02-22
responses:
'200':
description:inbox note
content:
application/json:
schema:
$ref:'#/components/schemas/Note'
default:
description:unexpected error
content:
application/json:
schema:
$ref:'#/components/schemas/Error'
/calendar/days/{date}:
get:
description:returns a day note for a given date. Gets created if doesn't exist.
operationId:getDayNote
parameters:
- name:date
in:path
required:true
schema:
type:string
format:date
example:2022-02-22
responses:
'200':
description:day note
content:
application/json:
schema:
$ref:'#/components/schemas/Note'
default:
description:unexpected error
content:
application/json:
schema:
$ref:'#/components/schemas/Error'
/calendar/weeks/{date}:
get:
description:returns a week note for a given date. Gets created if doesn't exist.
operationId:getWeekNote
parameters:
- name:date
in:path
required:true
schema:
type:string
format:date
example:2022-02-22
responses:
'200':
description:week note
content:
application/json:
schema:
$ref:'#/components/schemas/Note'
default:
description:unexpected error
content:
application/json:
schema:
$ref:'#/components/schemas/Error'
/calendar/months/{month}:
get:
description:returns a week note for a given date. Gets created if doesn't exist.
operationId:getMonthNote
parameters:
- name:month
in:path
required:true
schema:
type:string
pattern:'[0-9]{4}-[0-9]{2}'
example:2022-02
responses:
'200':
description:month note
content:
application/json:
schema:
$ref:'#/components/schemas/Note'
default:
description:unexpected error
content:
application/json:
schema:
$ref:'#/components/schemas/Error'
/calendar/years/{year}:
get:
description:returns a week note for a given date. Gets created if doesn't exist.
operationId:getYearNote
parameters:
- name:year
in:path
required:true
schema:
type:string
pattern:'[0-9]{4}-[0-9]{2}'
example:2022-02
responses:
'200':
description:year note
content:
application/json:
schema:
$ref:'#/components/schemas/Note'
default:
description:unexpected error
content:
application/json:
schema:
$ref:'#/components/schemas/Error'
/auth/login:
post:
description:get an ETAPI token based on password for further use with ETAPI
operationId:login
security:[]# no token based auth for login endpoint
requestBody:
required:true
content:
application/json:
schema:
properties:
password:
type:string
description:user's password used to e.g. login to Trilium server and/or protect notes
@ -121,12 +129,11 @@ function validateAndPatch(entity, props, allowedProperties) {
module.exports={
EtapiError,
sendError,
checkEtapiAuth,
route,
NOT_AUTHENTICATED_ROUTE,
GENERIC_CODE,
validateAndPatch,
getAndCheckNote,
getAndCheckBranch,
getAndCheckAttribute,
getNotAllowedPatchPropertyError:(propertyName,allowedProperties)=>newEtapiError(400,"PROPERTY_NOT_ALLOWED_FOR_PATCH",`Property '${propertyName}' is not allowed to be patched, allowed properties are ${allowedProperties}.`),