kjgcoop / trilium-notes-api
A package to make changes to a Trilium Notes instance
Requires
- php: ^8.0
- guzzlehttp/guzzle: ^7.0
- michelf/php-markdown: ^2.0
- psr/log: ^1.1 || ^2.0 || ^3.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-16 04:58:22 UTC
README
Simple API to talk to a Trilium Notes instance. This is php-trilium-next-api with a facelift.
Usage
No config file needed - construct the client directly with your endpoint and API key:
use Kjgcoop\TriliumNotesApi\TriliumNotesApi; $api = new TriliumNotesApi( 'https://your-trilium-domain/etapi/', 'your-etapi-key' );
The endpoint must use https:// - the API key is sent as a plain Authorization header, so the constructor rejects an http:// endpoint.
Logging
Pass a PSR-3 LoggerInterface as the third constructor argument to capture request failures. Without one, failures are only raised as exceptions.
$api = new TriliumNotesApi($endpoint, $apiKey, $logger);
Custom HTTP client
A fourth, optional argument accepts a Guzzle ClientInterface, useful for tests or custom HTTP configuration (proxies, custom timeouts, etc.). If omitted, a default client with a 10-second timeout is used.
$api = new TriliumNotesApi($endpoint, $apiKey, $logger, $httpClient);