Created
April 14, 2025 17:03
-
-
Save FliegendeWurst/03fa7c5afd778557804a14474e5a7a50 to your computer and use it in GitHub Desktop.
for progenitor PR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"openapi": "3.0.3", | |
"info": { | |
"title": "Trilium Notes - Sync server API", | |
"version": "0.96.6", | |
"description": "This is the internal sync server API used by Trilium Notes / TriliumNext Notes.\n\n_If you're looking for the officially supported External Trilium API, see [here](https://triliumnext.github.io/Docs/Wiki/etapi.html)._\n\nThis page does not yet list all routes. For a full list, see the [route controller](https://github.com/TriliumNext/Notes/blob/v0.91.6/src/routes/routes.ts).", | |
"contact": { | |
"name": "TriliumNext issue tracker", | |
"url": "https://github.com/TriliumNext/Notes/issues" | |
}, | |
"license": { | |
"name": "GNU Free Documentation License 1.3 (or later)", | |
"url": "https://www.gnu.org/licenses/fdl-1.3" | |
} | |
}, | |
"paths": { | |
"/api/setup/sync-seed": { | |
"get": { | |
"tags": [ | |
"auth" | |
], | |
"summary": "Sync documentSecret value", | |
"description": "First step to logging in.", | |
"operationId": "setup-sync-seed", | |
"responses": { | |
"200": { | |
"description": "Successful operation", | |
"content": { | |
"application/json": { | |
"schema": { | |
"type": "object", | |
"properties": { | |
"syncVersion": { | |
"type": "integer", | |
"example": 34 | |
}, | |
"options": { | |
"type": "object", | |
"properties": { | |
"documentSecret": { | |
"type": "string" | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
}, | |
"security": [ | |
{ | |
"user-password": [] | |
} | |
] | |
} | |
}, | |
"/api/app-info": { | |
"get": { | |
"summary": "Get installation info", | |
"operationId": "app-info", | |
"externalDocs": { | |
"description": "Server implementation", | |
"url": "https://github.com/TriliumNext/Notes/blob/v0.91.6/src/services/app_info.ts" | |
}, | |
"responses": { | |
"200": { | |
"description": "Installation info", | |
"content": { | |
"application/json": { | |
"schema": { | |
"type": "object", | |
"properties": { | |
"appVersion": { | |
"type": "string", | |
"example": "0.91.6" | |
}, | |
"dbVersion": { | |
"type": "integer", | |
"example": 228 | |
}, | |
"nodeVersion": { | |
"type": "string", | |
"description": "value of process.version" | |
}, | |
"syncVersion": { | |
"type": "integer", | |
"example": 34 | |
}, | |
"buildDate": { | |
"type": "string", | |
"example": "2024-09-07T18:36:34Z" | |
}, | |
"buildRevision": { | |
"type": "string", | |
"example": "7c0d6930fa8f20d269dcfbcbc8f636a25f6bb9a7" | |
}, | |
"dataDirectory": { | |
"type": "string", | |
"example": "/var/lib/trilium" | |
}, | |
"clipperProtocolVersion": { | |
"type": "string", | |
"example": "1.0" | |
}, | |
"utcDateTime": { | |
"$ref": "#/components/schemas/UtcDateTime" | |
} | |
} | |
} | |
} | |
} | |
} | |
}, | |
"security": [ | |
{ | |
"session": [] | |
} | |
] | |
} | |
}, | |
"/api/branches/{branchId}": { | |
"delete": { | |
"summary": "Delete branch (note clone)", | |
"operationId": "branches-delete", | |
"parameters": [ | |
{ | |
"name": "branchId", | |
"in": "path", | |
"required": true, | |
"schema": { | |
"$ref": "#/components/schemas/BranchId" | |
} | |
}, | |
{ | |
"name": "taskId", | |
"in": "query", | |
"required": true, | |
"schema": { | |
"type": "string" | |
}, | |
"description": "Task group identifier" | |
}, | |
{ | |
"name": "eraseNotes", | |
"in": "query", | |
"schema": { | |
"type": "boolean" | |
}, | |
"required": false, | |
"description": "Whether to erase the note immediately" | |
}, | |
{ | |
"name": "last", | |
"in": "query", | |
"schema": { | |
"type": "boolean" | |
}, | |
"required": true, | |
"description": "Whether this is the last request of this task group" | |
} | |
], | |
"responses": { | |
"200": { | |
"description": "Branch successfully deleted", | |
"content": { | |
"application/json": { | |
"schema": { | |
"type": "object", | |
"properties": { | |
"noteDeleted": { | |
"type": "boolean", | |
"description": "Whether the last note clone was deleted" | |
} | |
} | |
} | |
} | |
} | |
} | |
}, | |
"security": [ | |
{ | |
"session": [] | |
} | |
], | |
"tags": [ | |
"data" | |
] | |
} | |
}, | |
"/api/login/sync": { | |
"post": { | |
"tags": [ | |
"auth" | |
], | |
"summary": "Log in using documentSecret", | |
"description": "The `hash` parameter is computed using a HMAC of the `documentSecret` and `timestamp`.", | |
"operationId": "login-sync", | |
"externalDocs": { | |
"description": "HMAC calculation", | |
"url": "https://github.com/TriliumNext/Notes/blob/v0.91.6/src/services/utils.ts#L62-L66" | |
}, | |
"requestBody": { | |
"content": { | |
"application/json": { | |
"schema": { | |
"type": "object", | |
"properties": { | |
"timestamp": { | |
"$ref": "#/components/schemas/UtcDateTime" | |
}, | |
"hash": { | |
"type": "string" | |
}, | |
"syncVersion": { | |
"type": "integer", | |
"example": 34 | |
} | |
} | |
} | |
} | |
} | |
}, | |
"responses": { | |
"200": { | |
"description": "Successful operation", | |
"content": { | |
"application/json": { | |
"schema": { | |
"type": "object", | |
"properties": { | |
"syncVersion": { | |
"type": "integer", | |
"example": 34 | |
}, | |
"options": { | |
"type": "object", | |
"properties": { | |
"documentSecret": { | |
"type": "string" | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
}, | |
"400": { | |
"description": "Sync version / document secret mismatch", | |
"content": { | |
"application/json": { | |
"schema": { | |
"type": "object", | |
"properties": { | |
"message": { | |
"type": "string", | |
"example": "Non-matching sync versions, local is version ${server syncVersion}, remote is ${requested syncVersion}. It is recommended to run same version of Trilium on both sides of sync" | |
} | |
} | |
} | |
} | |
} | |
}, | |
"401": { | |
"description": "Timestamp mismatch", | |
"content": { | |
"application/json": { | |
"schema": { | |
"type": "object", | |
"properties": { | |
"message": { | |
"type": "string", | |
"example": "Auth request time is out of sync, please check that both client and server have correct time. The difference between clocks has to be smaller than 5 minutes" | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
}, | |
"/api/notes/{noteId}": { | |
"get": { | |
"summary": "Retrieve note metadata", | |
"operationId": "notes-get", | |
"parameters": [ | |
{ | |
"name": "noteId", | |
"in": "path", | |
"required": true, | |
"schema": { | |
"$ref": "#/components/schemas/NoteId" | |
} | |
} | |
], | |
"responses": { | |
"200": { | |
"description": "Note metadata", | |
"content": { | |
"application/json": { | |
"schema": { | |
"allOf": [ | |
{ | |
"$ref": "#/components/schemas/Note" | |
}, | |
{ | |
"$ref": "#/components/schemas/Timestamps" | |
} | |
] | |
} | |
} | |
} | |
} | |
}, | |
"security": [ | |
{ | |
"session": [] | |
} | |
], | |
"tags": [ | |
"data" | |
] | |
}, | |
"delete": { | |
"summary": "Delete note", | |
"operationId": "notes-delete", | |
"parameters": [ | |
{ | |
"name": "noteId", | |
"in": "path", | |
"required": true, | |
"schema": { | |
"$ref": "#/components/schemas/NoteId" | |
} | |
}, | |
{ | |
"name": "taskId", | |
"in": "query", | |
"required": true, | |
"schema": { | |
"type": "string" | |
}, | |
"description": "Task group identifier" | |
}, | |
{ | |
"name": "eraseNotes", | |
"in": "query", | |
"schema": { | |
"type": "boolean" | |
}, | |
"required": false, | |
"description": "Whether to erase the note immediately" | |
}, | |
{ | |
"name": "last", | |
"in": "query", | |
"schema": { | |
"type": "boolean" | |
}, | |
"required": true, | |
"description": "Whether this is the last request of this task group" | |
} | |
], | |
"responses": { | |
"200": { | |
"description": "Note successfully deleted" | |
} | |
}, | |
"security": [ | |
{ | |
"session": [] | |
} | |
], | |
"tags": [ | |
"data" | |
] | |
} | |
}, | |
"/api/notes/{noteId}/blob": { | |
"get": { | |
"summary": "Retrieve note content", | |
"operationId": "notes-blob", | |
"parameters": [ | |
{ | |
"name": "noteId", | |
"in": "path", | |
"required": true, | |
"schema": { | |
"$ref": "#/components/schemas/NoteId" | |
} | |
} | |
], | |
"responses": { | |
"304": { | |
"description": "Note content", | |
"content": { | |
"application/json": { | |
"schema": { | |
"$ref": "#/components/schemas/Blob" | |
} | |
} | |
} | |
} | |
}, | |
"security": [ | |
{ | |
"session": [] | |
} | |
], | |
"tags": [ | |
"data" | |
] | |
} | |
}, | |
"/api/notes/{noteId}/metadata": { | |
"get": { | |
"summary": "Retrieve note metadata (limited to timestamps)", | |
"operationId": "notes-metadata", | |
"parameters": [ | |
{ | |
"name": "noteId", | |
"in": "path", | |
"required": true, | |
"schema": { | |
"$ref": "#/components/schemas/NoteId" | |
} | |
} | |
], | |
"responses": { | |
"200": { | |
"description": "Note metadata", | |
"content": { | |
"application/json": { | |
"schema": { | |
"$ref": "#/components/schemas/Timestamps" | |
} | |
} | |
} | |
} | |
}, | |
"security": [ | |
{ | |
"session": [] | |
} | |
], | |
"tags": [ | |
"data" | |
] | |
} | |
}, | |
"/api/sync/changed": { | |
"get": { | |
"summary": "Pull sync changes", | |
"operationId": "sync-changed", | |
"externalDocs": { | |
"description": "Server implementation", | |
"url": "https://github.com/TriliumNext/Notes/blob/v0.91.6/src/routes/api/sync.ts" | |
}, | |
"parameters": [ | |
{ | |
"in": "query", | |
"name": "instanceId", | |
"required": true, | |
"schema": { | |
"type": "string" | |
}, | |
"description": "Local instance ID" | |
}, | |
{ | |
"in": "query", | |
"name": "lastEntityChangeId", | |
"required": true, | |
"schema": { | |
"type": "integer" | |
}, | |
"description": "Last locally present change ID" | |
}, | |
{ | |
"in": "query", | |
"name": "logMarkerId", | |
"required": true, | |
"schema": { | |
"type": "string" | |
}, | |
"description": "Marker to identify this request in server log" | |
} | |
], | |
"responses": { | |
"200": { | |
"description": "Sync changes, limited to approximately one megabyte.", | |
"content": { | |
"application/json": { | |
"schema": { | |
"type": "object", | |
"properties": { | |
"entityChanges": { | |
"type": "array", | |
"items": { | |
"$ref": "#/components/schemas/EntityChange" | |
} | |
}, | |
"lastEntityChangeId": { | |
"type": "integer", | |
"description": "If `outstandingPullCount > 0`, pass this as parameter in your next request to continue." | |
}, | |
"outstandingPullCount": { | |
"type": "integer", | |
"example": 42, | |
"description": "Number of changes not yet returned by the remote." | |
} | |
} | |
} | |
} | |
} | |
} | |
}, | |
"security": [ | |
{ | |
"session": [] | |
} | |
], | |
"tags": [ | |
"sync" | |
] | |
} | |
}, | |
"/api/sync/update": { | |
"put": { | |
"summary": "Push sync changes", | |
"description": "Basic usage: set `pageCount = 1`, `pageIndex = 0`, and omit `requestId`. Supply your entity changes in the request body.", | |
"operationId": "sync-update", | |
"externalDocs": { | |
"description": "Server implementation", | |
"url": "https://github.com/TriliumNext/Notes/blob/v0.91.6/src/routes/api/sync.ts" | |
}, | |
"parameters": [ | |
{ | |
"in": "header", | |
"name": "pageCount", | |
"required": true, | |
"schema": { | |
"type": "integer" | |
} | |
}, | |
{ | |
"in": "header", | |
"name": "pageIndex", | |
"required": true, | |
"schema": { | |
"type": "integer" | |
} | |
}, | |
{ | |
"in": "header", | |
"name": "requestId", | |
"schema": { | |
"type": "string", | |
"description": "ID to identify paginated requests" | |
} | |
}, | |
{ | |
"in": "query", | |
"name": "logMarkerId", | |
"required": true, | |
"schema": { | |
"type": "string" | |
}, | |
"description": "Marker to identify this request in server log" | |
} | |
], | |
"requestBody": { | |
"content": { | |
"application/json": { | |
"schema": { | |
"type": "object", | |
"properties": { | |
"instanceId": { | |
"type": "string", | |
"description": "Local instance ID" | |
}, | |
"entities": { | |
"type": "array", | |
"items": { | |
"$ref": "#/components/schemas/EntityChange" | |
} | |
} | |
} | |
} | |
} | |
} | |
}, | |
"responses": { | |
"200": { | |
"description": "Changes processed successfully" | |
} | |
}, | |
"security": [ | |
{ | |
"session": [] | |
} | |
], | |
"tags": [ | |
"sync" | |
] | |
} | |
}, | |
"/api/tree": { | |
"get": { | |
"summary": "Retrieve tree data", | |
"operationId": "tree", | |
"externalDocs": { | |
"description": "Server implementation", | |
"url": "https://github.com/TriliumNext/Notes/blob/v0.91.6/src/routes/api/tree.ts" | |
}, | |
"parameters": [ | |
{ | |
"in": "query", | |
"name": "subTreeNoteId", | |
"required": false, | |
"schema": { | |
"type": "string" | |
}, | |
"description": "Limit tree data to this note and descendants" | |
} | |
], | |
"responses": { | |
"200": { | |
"description": "Notes, branches and attributes", | |
"content": { | |
"application/json": { | |
"schema": { | |
"type": "object", | |
"properties": { | |
"branches": { | |
"type": "array", | |
"items": { | |
"$ref": "#/components/schemas/Branch" | |
} | |
}, | |
"notes": { | |
"type": "array", | |
"items": { | |
"$ref": "#/components/schemas/Note" | |
} | |
}, | |
"attributes": { | |
"type": "array", | |
"items": { | |
"$ref": "#/components/schemas/Attribute" | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
}, | |
"security": [ | |
{ | |
"session": [] | |
} | |
], | |
"tags": [ | |
"data" | |
] | |
} | |
} | |
}, | |
"components": { | |
"schemas": { | |
"Attribute": { | |
"type": "object", | |
"properties": { | |
"attributeId": { | |
"type": "string", | |
"example": "4G1DPrI58PAb" | |
}, | |
"noteId": { | |
"$ref": "#/components/schemas/NoteId" | |
}, | |
"type": { | |
"type": "string", | |
"enum": [ | |
"attribute", | |
"relation" | |
] | |
}, | |
"name": { | |
"type": "string", | |
"example": "internalLink" | |
}, | |
"value": { | |
"type": "string", | |
"example": "hA8aHSpTRdZ6", | |
"description": "If type = \"relation\", a note ID. Otherwise, the attribute content." | |
}, | |
"position": { | |
"type": "integer", | |
"example": 20 | |
}, | |
"isInheritable": { | |
"type": "boolean" | |
} | |
} | |
}, | |
"Blob": { | |
"type": "object", | |
"properties": { | |
"blobId": { | |
"type": "string", | |
"example": "8iqMIB8eiY1tPYmElfjm" | |
}, | |
"content": { | |
"type": "string", | |
"description": "`null` if not text.", | |
"nullable": true | |
}, | |
"contentLength": { | |
"type": "integer" | |
}, | |
"dateModified": { | |
"$ref": "#/components/schemas/DateTime" | |
}, | |
"utcDateModified": { | |
"$ref": "#/components/schemas/UtcDateTime" | |
} | |
} | |
}, | |
"Branch": { | |
"type": "object", | |
"properties": { | |
"branchId": { | |
"$ref": "#/components/schemas/BranchId" | |
}, | |
"noteId": { | |
"$ref": "#/components/schemas/NoteId" | |
}, | |
"parentNoteId": { | |
"$ref": "#/components/schemas/NoteId" | |
}, | |
"notePosition": { | |
"type": "integer", | |
"example": 20 | |
}, | |
"prefix": { | |
"type": "string", | |
"nullable": true | |
}, | |
"isExpanded": { | |
"type": "boolean" | |
} | |
} | |
}, | |
"BranchId": { | |
"type": "string", | |
"example": "WUjhaGp4EKah_ur11rSfHkzeV", | |
"description": "Equal to `{parentNoteId}_{noteId}`" | |
}, | |
"DateTime": { | |
"type": "string", | |
"example": "2025-02-14 08:19:59.203+0100" | |
}, | |
"EntityChange": { | |
"type": "object", | |
"properties": { | |
"entityChange": { | |
"type": "object", | |
"properties": { | |
"entityName": { | |
"type": "string", | |
"example": "notes", | |
"description": "Database table for this entity." | |
}, | |
"changeId": { | |
"type": "string", | |
"example": "changeId9630", | |
"description": "ID, referenced in `entity_changes` table." | |
} | |
} | |
}, | |
"entity": { | |
"type": "object", | |
"description": "Encoded entity data. Object has one property for each database column." | |
} | |
} | |
}, | |
"Note": { | |
"type": "object", | |
"properties": { | |
"noteId": { | |
"$ref": "#/components/schemas/NoteId" | |
}, | |
"title": { | |
"type": "string" | |
}, | |
"isProtected": { | |
"type": "boolean" | |
}, | |
"type": { | |
"type": "string", | |
"example": "text", | |
"enum": [ | |
"text", | |
"code", | |
"render", | |
"file", | |
"image", | |
"search", | |
"relationMap", | |
"book", | |
"noteMap", | |
"mermaid", | |
"canvas", | |
"webView", | |
"launcher", | |
"doc", | |
"contentWidget", | |
"mindMap", | |
"geoMap" | |
], | |
"description": "[Reference list](https://github.com/TriliumNext/Notes/blob/v0.91.6/src/services/note_types.ts)" | |
}, | |
"mime": { | |
"type": "string", | |
"example": "text/html" | |
}, | |
"blobId": { | |
"type": "string", | |
"example": "z4PhNX7vuL3xVChQ1m2A" | |
} | |
} | |
}, | |
"NoteId": { | |
"type": "string", | |
"example": "ur11rSfHkzeV", | |
"description": "12-character note ID. Special values: \"none\"`, `\"root\"." | |
}, | |
"Timestamps": { | |
"type": "object", | |
"properties": { | |
"dateCreated": { | |
"$ref": "#/components/schemas/DateTime" | |
}, | |
"dateModified": { | |
"$ref": "#/components/schemas/DateTime" | |
}, | |
"utcDateCreated": { | |
"$ref": "#/components/schemas/UtcDateTime" | |
}, | |
"utcDateModified": { | |
"$ref": "#/components/schemas/UtcDateTime" | |
} | |
} | |
}, | |
"UtcDateTime": { | |
"type": "string", | |
"example": "2025-02-13T07:42:47.698Z", | |
"description": "Result of `new Date().toISOString().replace('T', ' ')`" | |
} | |
}, | |
"securitySchemes": { | |
"user-password": { | |
"type": "apiKey", | |
"name": "trilium-cred", | |
"in": "header", | |
"description": "Username and password, formatted as `user:password`" | |
}, | |
"session": { | |
"type": "apiKey", | |
"in": "cookie", | |
"name": "trilium.sid" | |
} | |
} | |
}, | |
"tags": [ | |
{ | |
"name": "auth", | |
"description": "Authentication" | |
}, | |
{ | |
"name": "sync", | |
"description": "Synchronization" | |
}, | |
{ | |
"name": "data" | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment