A Python wrapper for the Trilium Notes API
Project description
Pytrilium
Python SDK (wrapper, whatever you want to call it) for interacting with Trilium's ETAPI. The exact OpenAPI spec definition file that I'm trying to match can be found here.
Installation
pip install pytrilium
Examples
Basic Use Case
This will just print out the contents of a note, as one large string. Trilium's API returns it in the HTML format.
from PyTrilium.PyTrilium import PyTrilium
pytrilium_client = PyTrilium("https://trilium.example.com", "TTDaTeG3sadffy2_eOtgqvZoI6xHvga/6vhz61ezke1RpoX47vPI93zs5qs=")
print(pytrilium_client.get_note_content_by_id("MLDQ3EGWsU8e"))
Export a note to a file
from PyTrilium.PyTrilium import PyTrilium
test_client = PyTrilium("https://trilium.example.com", "TTDaTeG3sadffy2_eOtgqvZoI6xHvga/6vhz61ezke1RpoX47vPI93zs5qs=")
print(test_client.get_note_content_by_id("MLDQ3EGWsU8e"))
test_client.export_note_by_id("MLDQ3EGWsU8e", "./test.zip")
More Advanced
If I'm braindead or this just doesn't do what you want it to, you can still use the underlying requests.Session
that I've set up so that you can still interact with the API. This way you can still make manual requests if you would like to, and do whatever you would like with them.
To print out a Note's content without using other helpers -
from PyTrilium.PyTrilium import PyTrilium
pytrilium_client = PyTrilium("https://trilium.example.com", "TTDaTeG3sadffy2_eOtgqvZoI6xHvga/6vhz61ezke1RpoX47vPI93zs5qs=")
resp = pytrilium_client.make_request('notes/<noteid>/content')
print(resp.text)
Misc
To get a quick list of currently available paths from the OpenAPI spec (doesn't always mean what's in this package or not):
curl https://raw.githubusercontent.com/zadam/trilium/master/src/etapi/etapi.openapi.yaml 2>/dev/null | yq -e ".paths | keys"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pytrilium-1.0.1.tar.gz
.
File metadata
- Download URL: pytrilium-1.0.1.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2110ad0f54968191130cf53c04746c2720e7815f32d14e76572deb88bd4e3978 |
|
MD5 | 91f335c38588a63698901ec019324096 |
|
BLAKE2b-256 | c93d96a478b92c1faea2b92da4e9e648e61186dc9b6367d4215ae0a5b694a5c1 |
File details
Details for the file pytrilium-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: pytrilium-1.0.1-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92c1329c9f1bffedfdbd19bad4d7a8fdaab2f702091d76b6a43144dd7446cd76 |
|
MD5 | 151ae3992221e4775eb15ba33541210c |
|
BLAKE2b-256 | 3098a352c2f671d53817513ce0899f6920c0be31c62fb9a875f252b47b64a6b6 |