Python client for ETAPI of Trilium Note.
Project description
trilium-py
Python client for ETAPI of Trilium Note.
Installation
python3 -m pip install trilium-py --user
Usage
Down below are some simple example code to use this package.
initialize
If you have a ETAPI token, change the server_url
and token
to yours.
from trilium_py.client import ETAPI
server_url = 'http://localhost:8080'
token = 'YOUR_TOKEN'
ea = ETAPI(server_url, token)
If you haven't created ETAPI token, you can create one with your password. Please note, you can only see this token once, please save it if you want to reuse the token.
from trilium_py.client import ETAPI
server_url = 'http://localhost:8080'
password = '1234'
ea = ETAPI(server_url)
token = ea.login(password)
print(token)
After initialization, you can use Trilium ETAPI with python now. The following are some examples.
Search note
Search note with keyword.
res = ea.search_note(
search="python",
)
for x in res['results']:
print(x['noteId'], x['title'])
Create Note
You can create a simple note like this.
res = ea.create_note(
parentNoteId="root",
title="Simple note 1",
type="text",
content="Simple note example",
noteId="note1"
)
The noteId
is not mandatory, if not provided, Trilium will generate a random one. You can retrieve it in the return.
noteId = res['note']['noteId']
Get note
To retrieve the note's content.
ea.get_note_content("note1")
You can get a note metadata by its id.
ea.get_note(note_id)
Update note
Update note content
ea.update_note_content("note1", "updated by python")
Modify note title
ea.patch_note(
noteId="note1",
title="Python client moded",
)
Delete note
Simply delete a note by id.
ea.delete_note("note1")
Develop
Install with pip egg link to make package change without reinstall.
python -m pip install --user -e .
Original OpenAPI Documentation
The original OpenAPI document is here. You can open it with swagger editor.
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 Distributions
Built Distribution
File details
Details for the file trilium_py-0.5.2-py3-none-any.whl
.
File metadata
- Download URL: trilium_py-0.5.2-py3-none-any.whl
- Upload date:
- Size: 17.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.8.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 302f355ab7c1a7c4a21d9a2d92b7d50a7419102ba00b287e70c7089d9cc0f8d9 |
|
MD5 | 904020c89dbe3116d994a67a7f37d5dd |
|
BLAKE2b-256 | ab2563fd86197b1d069905d3d7ab3bb225649e8a83c60b9947aa32eff32fc1d9 |