-
-
Notifications
You must be signed in to change notification settings - Fork 18
Accessing Tiddlyhost data as JSON
Simon Baird edited this page Oct 26, 2022
·
2 revisions
It's possible to access Tiddler data in a Tiddlyhost site in JSON format.
Here are some example urls to show how it works. To use these with your site, replace "simon" with your real site name.
-
https://simon.tiddlyhost.com/tiddlers.json
All non-system tiddlers as JSON. -
https://simon.tiddlyhost.com/tiddlers.json?pretty=1
Thepretty
param add line breaks and indentation for readability. -
https://simon.tiddlyhost.com/tiddlers.json?pretty=1&skinny=1
Theskinny
param means exclude the tiddlers' text, which is useful if you just want a list of the tiddlers and don't need the full content. -
https://simon.tiddlyhost.com/tiddlers.json?pretty=1&skinny=1&include_system=1
Add theinclude_system
param if you do want system tiddlers to be included. Beware that$:/core
will show up in this list and it is extremely large. -
https://simon.tiddlyhost.com/tiddlers.json?title=Hello&pretty=1
Thetitle
param lets you specify one single tiddler -
https://simon.tiddlyhost.com/tiddlers.json?title[]=Hello&title[]=About%20Tiddlyhost&pretty=1
It's possible to specify more than one title using this specially formattedtitle
param.
The url params can be combined as required to pick out the data you want.
You can also access tiddlers by their name in ".tid" format, which is a text format sometimes used to represent Tiddlers. For example:
- https://simon.tiddlyhost.com/text/Hello.tid
- https://simon.tiddlyhost.com/text/About%20Tiddlyhost.tid
Using curl
and jq
you can extract just the fields you want, for example this lists the titles of all tiddlers tagged with (just) "Hello":
$ curl -s https://simon.tiddlyhost.com/tiddlers.json | jq '.[] | select(.tags=="Hello") | .title'
"About Tiddlyhost"
"Experiments & demos"
"The original site #1"