Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytrilium-1.0.4.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

pytrilium-1.0.4-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file pytrilium-1.0.4.tar.gz.

File metadata

  • Download URL: pytrilium-1.0.4.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

Hashes for pytrilium-1.0.4.tar.gz
Algorithm Hash digest
SHA256 e8e3972916f276a29d6698a27e7d1591557856e075c6235cc7aa85d768c0e016
MD5 6d3a42a380ec9769ec96031239d069d2
BLAKE2b-256 2665ad0f92697e8588bb74615789654af1a17977e7390c09ff95e61f0adee5a5

See more details on using hashes here.

File details

Details for the file pytrilium-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: pytrilium-1.0.4-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

Hashes for pytrilium-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7062aaad9ed948dab6fc6a48fab715b9917fc73dd0a8e345fdc008ba6b829331
MD5 41c7ab91a885317630bc0c36444bbbc8
BLAKE2b-256 dca6d754d415a46efa771362318195adcc0687d584016629dc566b40ab9e5299

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page