Skip to content

ptmorris1/TriliumNext-Powershell-Module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

48 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Trilium PowerShell Module

PowerShell Gallery Version Downloads PSGallery Quality
Trilium Notes
License: MIT

Manage your Trilium Notes instance via PowerShell using the ETAPI


🦾 Description

Trilium is a PowerShell module that enables you to interact with your Trilium server programmatically. It provides functions to:

  • Authenticate and manage sessions
  • Search and manage notes
  • Export and import notes
  • Manage note attributes and branches
  • And more!

πŸ›  Requirements

  • PowerShell 7 or higher
  • Trilium instance with ETAPI enabled
  • HTTP(S) access to your Trilium server

πŸ“¦ Installation

Install from the PowerShell Gallery:

Install-PSResource -Name Trilium -Scope CurrentUser

πŸ” Authentication

All functions require 1 time authentication 1st. Use a PSCredential object to store the password or ETAPI token. Username does not matter but required for Get-Credential. We only use the stored password.

πŸ” Authenticate with Password

Authenticate using your Trilium username and password:

Tip

Since Trilium doesn't need a username, anything will do.

$creds = Get-Credential -UserName 'admin'
Connect-TriliumAuth -BaseUrl "https://trilium.myDomain.net" -Password $creds
appVersion             : 0.96.0
dbVersion              : 232
nodeVersion            : v22.17.0
syncVersion            : 36
buildDate              : 6/7/2025 9:45:40 AM
buildRevision          : 7cbff47078012e32279c110c49b904bd24dcecb3
dataDirectory          : /home/node/trilium-data
clipperProtocolVersion : 1.0
utcDateTime            : 7/4/2025 4:07:48 AM

Tip

This output confirms successful connection and shows server environment details.

πŸ” Authenticate with ETAPI Token

Authenticate using your ETAPI token (enter token as password):

Tip

Since Trilium doesn't need a username, anything will do.

$token = Get-Credential -UserName 'admin' # Enter your ETAPI token as the password
Connect-TriliumAuth -BaseUrl "https://trilium.myDomain.net" -EtapiToken $token

⚠️ Skip Certificate Check (Self-Signed Certs)

If your Trilium instance uses a self-signed certificate, you can skip certificate validation with any cmdlet using -SkipCertCheck:

Connect-TriliumAuth -BaseUrl "https://trilium.myDomain.net" -Password $creds -SkipCertCheck

Tip

All Trilium module cmdlets support the -SkipCertCheck parameter for self-signed certificates.

Warning

Ensure your BaseUrl is correct and accessible. Use -SkipCertCheck only if you trust the server.


πŸ—‚οΈ API Endpoints and Functions

Method Endpoint Function Notes
POST /create-note New-TriliumNote Create a new note
GET /notes Find-TriliumNote Search for notes
GET /notes/{noteId} Get-TriliumNoteDetails Get note details
PATCH /notes/{noteId} Set-TriliumNoteDetails Update note details (PATCH)
DELETE /notes/{noteId} Remove-TriliumNote Delete a note
GET /notes/{noteId}/content Get-TriliumNoteContent Get note content
PUT /notes/{noteId}/content Set-TriliumNoteContent Update note content
GET /notes/{noteId}/export Export-TriliumNote Export note(s) as zip (HTML/Markdown)
POST /notes/{noteId}/import Import-TriliumNoteZip Import notes from ZIP
POST /notes/{noteId}/revision New-TriliumNoteRevision Create a new note revision
POST /branches Copy-TriliumNote Copy a note to a new branch
GET /branches/{branchId} Get-TriliumBranch Get branch details
PATCH /branches/{branchId} Set-TriliumBranch Update branch prefix and/or note position (PATCH)
DELETE /branches/{branchId} Remove-TriliumBranch Delete a branch
POST /attachments New-TriliumAttachment Create a new attachment for a note
GET /attachments/{attachmentId} Get-TriliumAttachment Get attachment metadata
PATCH /attachments/{attachmentId} Set-TriliumAttachment Update attachment properties (role, mime, title, position)
DELETE /attachments/{attachmentId} Remove-TriliumAttachment Delete an attachment
GET /attachments/{attachmentId}/content Get-TriliumAttachmentContent Download attachment content
PUT /attachments/{attachmentId}/content New-TriliumNoteFile Create a new note from a local file (uploads file content)
N/A N/A Format-TriliumHtml Helper function to beautify HTML content with improved header spacing and code block formatting
POST /attributes Create-TriliumAttribute Create a new attribute
GET /attributes/{attributeId} Get-TriliumAttribute Get attribute details
PATCH /attributes/{attributeId}
DELETE /attributes/{attributeId} Remove-TriliumAttribute Delete an attribute
POST /refresh-note-ordering/{parentNoteId} Update-TriliumNoteOrder Refresh note ordering
GET /inbox/{date} Get-TriliumInbox Get or create inbox note for a date
GET /calendar/days/{date} Get-TriliumDayNote Get or create day note for a date
GET /calendar/weeks/{date} Get-TriliumWeekNote (Broken: appears to be a bug in Trilium)
GET /calendar/months/{month} Get-TriliumMonthNote Get or create month note for a month
GET /calendar/years/{year} Get-TriliumYearNote Get or create year note for a year
POST /auth/login Connect-TriliumAuth Authenticate to Trilium (now uses 'Bearer' for ETAPI)
POST /auth/logout Disconnect-TriliumAuth Logout from Trilium
GET /app-info Get-TriliumInfo Get Trilium server info
PUT /backup/{backupName} New-TriliumBackup Create a new backup
GET /notes/root Get-TriliumRootNote Get root note details (requires Connect-TriliumAuth, no params; every root note has id 'root').
GET /notes/{noteId}/attachments Get-TriliumNoteAttachment Retrieves attachments for a specific note (Undocumented API)

πŸ“– Getting Help in PowerShell

You can view detailed help for any function in this module directly from PowerShell using the Get-Help cmdlet. This displays usage, parameters, examples, and notes for each function.

Examples:

Get-Help Connect-TriliumAuth -Full
Get-Help New-TriliumNote -Examples
Get-Help Get-TriliumAttachment

Read the docs


🧩 Notable Dependencies & Inspiration

  • πŸ“ Markdig: Used for converting Markdown to HTML in this module.
  • 🐍 trilium-py: Python library for Trilium ETAPI, used for some inspiration.

πŸ“£ Contributions & Issues

Feel free to open issues, submit pull requests, or suggest features!


πŸ“„ License

This project is licensed under the MIT License.


πŸ“… Changelog

See CHANGELOG.md for release history.


πŸ”— Resources


🧠 Made with ❀️ for scripting your notes.

About

A Powershell module interfacing with the TriliumNext API

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors