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.
You can use either your password or an ETAPI token to authenticate to the Trilium instance.
🖥 Installation
pip install pytrilium
Examples
🔐 Authenticating (via ETAPI token or password)
Token:
from pytrilium.PyTrilium import PyTrilium
pytrilium_client = PyTrilium("https://trilium.example.com", token="TTDaTeG3sadffy2_eOtgqvZoI6xHvga/6vhz61ezke1RpoX47vPI93zs5qs=")
print(pytrilium_client.get_note_content_by_id("MLDQ3EGWsU8e"))
Password:
from pytrilium.PyTrilium import PyTrilium
pytrilium_client = PyTrilium("https://trilium.example.com", password="thisisabadpassword1")
print(pytrilium_client.get_note_content_by_id("MLDQ3EGWsU8e"))
📒 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", token="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", token="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", token="TTDaTeG3sadffy2_eOtgqvZoI6xHvga/6vhz61ezke1RpoX47vPI93zs5qs=")
resp = pytrilium_client.make_request('notes/<noteid>/content')
print(resp.text)
Currently implemented functions
attempt_basic_call
auth_login
auth_logout
clean_url
create_note
create_note_revision
delete_branch_by_id
delete_note_by_id
export_note_by_id
get_attribute_by_id
get_branch_by_id
get_days_note
get_inbox_note
get_months_note
get_note_by_id
get_note_content_by_id
get_weeks_note
get_year_note
make_request
make_requests_session
patch_branch_by_id
patch_note_by_id
post_attribute
post_branch
print_custom_functions
put_note_content_by_id
refresh_note_ordering
set_session_auth
valid_response_codes
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.2.4.tar.gz
.
File metadata
- Download URL: pytrilium-1.2.4.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31aa9ef8fb2c91c9273979e4986663f6516cc34dd4d05a1613ea27b558653aef |
|
MD5 | 2137d0f4f22d22f45de8d76a2c0782be |
|
BLAKE2b-256 | 60cb97e441a788daf73c98d743f7638e67b12c5c508e479b45884d68100a008e |
File details
Details for the file pytrilium-1.2.4-py3-none-any.whl
.
File metadata
- Download URL: pytrilium-1.2.4-py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48c6d7325db6a2fa1f5eb93a38dfffb11f4625d843304b9c5ac75299d2dd05ee |
|
MD5 | ab95edacc96c7bfe3dae16c11fee6500 |
|
BLAKE2b-256 | 123554f40bd0df55c77e430ffd48e829035aeed85c01b11fa59aec7e4f6d4562 |