API: List all zettel, but in different encoding formats

00001012051400 · Info · (manual) · #api #manual #zettelstore

You can add a query parameter _format=FORMAT to select the encoding format when retrieving all zettel. Probably some formats are not very useful and may not make sense. Currently implemented are the formats json (default), djson, and html.

The format json will be selected, if no _format is specified. djson will return a JSON object with some more detailed information. For example, the Zettelmarkup structure will be returned and tags are returned as a list of strings. html will return an HTML encoding of the zettel list, using a HTML unnumbered list.

# curl 'http://127.0.0.1:23123/z?_format=djson'
{"list":[{"id":"00001012051400","url":"/z/00001012051400?_format=djson","meta":{"title":[{"t":"Text","s":"API:"},{"t":"Space"},{"t":"Text","s":"List"},{"t":"Space"},{"t":"Text","s":"all"},{"t":"Space"},{"t":"Text","s":"zettel,"},{"t":"Space"},{"t":"Text","s":"but"},{"t":"Space"},{"t":"Text","s":"in"},{"t":"Space"},{"t":"Text","s":"different"},{"t":"Space"},{"t":"Text","s":"encoding"},{"t":"Space"},{"t":"Text","s":"formats"}],"tags":["#api","#manual","#zettelstore"],"syntax":"zmk","role":"manual"}}, ...

Or reformatted:

{
  "list": [
    {
      "id": "00001012051400",
      "url": "/z/00001012051400?_format=djson",
      "meta": {
        "title": [
          {
            "t": "Text",
            "s": "API:"
          },
          {
            "t": "Space"
          },
          {
            "t": "Text",
            "s": "List"
          },
          {
            "t": "Space"
          },
          {
            "t": "Text",
            "s": "all"
          },
          {
            "t": "Space"
          },
          {
            "t": "Text",
            "s": "zettel,"
          },
...

`sh # curl 'http://127.0.0.1:23123/z?_format=html' <html lang="en"> <body> <ul> <li><a href="/z/00001012051400?_format=html">API: List all zettel, but in different encoding formats</a></li> <li><a href="/z/00001012051200?_format=html">API: List metadata of all zettel</a></li> <li><a href="/z/00001012050600?_format=html">API: Provide an access token</a></li> <li><a href="/z/00001012050400?_format=html">API: Renew an access token</a></li> <li><a href="/z/00001012050200?_format=html">API: Authenticate a client</a></li> <li><a href="/z/00001012000000?_format=html">API</a></li> </ul> </body> </html>`

If you request a JSON-based encoding format, you can request additional parts of a zettel.

HTTP Status codes

200
Retrieval was successful, the body contains an appropriate JSON object.
400
Request was not valid. There are several reasons for this. Maybe you provided a wrong value for _format.
501
Encoding format is not yet implemented, but will be in the future.
Additional links to this zettel