(zettel (meta (back "00001006000000 00001012000000 00001012053200 00001012054200 00001012054400") (backward "00001006000000 00001012000000 00001012053200 00001012054200 00001012054400 00001012920000") (box-number "1") (created "20211004093206") (forward "00001006050000 00001010040100 00001012050200 00001012053400 00001012920000 00001012920800 00001012921200 00001012930500") (modified "20230807170259") (published "20230807170259") (role "manual") (syntax "zmk") (tags "#api #manual #zettelstore") (title "API: Retrieve metadata and content of an existing zettel")) (rights 4) (encoding "") (content "The [[endpoint|00001012920000]] to work with metadata and content of a specific zettel is ''/z/{ID}'', where ''{ID}'' is a placeholder for the [[zettel identifier|00001006050000]].\n\nFor example, to retrieve some data about this zettel you are currently viewing, just send a HTTP GET request to the endpoint ''/z/00001012053300''[^If [[authentication is enabled|00001010040100]], you must include the a valid [[access token|00001012050200]] in the ''Authorization'' header].\n\n````sh\n# curl 'http://127.0.0.1:23123/z/00001012053300'\nThe [[endpoint|00001012920000]] to work with metadata and content of a specific zettel is ''/z/{ID}'', where ''{ID}'' is a placeholder for the [[zettel identifier|00001006050000]].\n\nFor example, to retrieve some data about this zettel you are currently viewing, just send a HTTP GET request to the endpoint ''/z/00001012053300''[^If [[authentication is enabled|00001010040100]], you must include the a valid [[access token|00001012050200]] in the ''Authorization'' header].\n\n```sh\n...\n````\n\nOptionally, you may provide which parts of the zettel you are requesting.\nIn this case, add an additional query parameter ''part=PART''.\nValid values for [[''PART''|00001012920800]] are \"\"zettel\"\", \"\"[[meta|00001012053400]]\"\", and \"\"content\"\" (the default value).\n\n\n````sh\n# curl 'http://127.0.0.1:23123/z/00001012053300?part=zettel'\ntitle: API: Retrieve metadata and content of an existing zettel\nrole: manual\ntags: #api #manual #zettelstore\nsyntax: zmk\n\nThe [[endpoint|00001012920000]] to work with metadata and content of a specific zettel is ''/z/{ID}'', where ''{ID}'' is a placeholder for the [[zettel identifier|00001006050000]].\n\nFor example, to retrieve some data about this zettel you are currently viewing, just send a HTTP GET request to the endpoint\n...\n````\n\n=== Data output\n\nAlternatively, you may retrieve the zettel as a parseable object / a [[symbolic expression|00001012930500]] by providing the query parameter ''enc=data'':\n\n```sh\n# curl 'http://127.0.0.1:23123/z/00001012053300?enc=data&part=zettel'\n(zettel (meta (back \"00001006000000 00001012000000 00001012053200 00001012054400\") (backward \"00001006000000 00001012000000 00001012053200 00001012054400 00001012920000\") (box-number \"1\") (created \"20211004093206\") (forward \"00001006020000 00001006050000 00001010040100 00001012050200 00001012053400 00001012920000 00001012920800 00001012921200 00001012930500\") (modified \"20230703174152\") (published \"20230703174152\") (role \"manual\") (syntax \"zmk\") (tags \"#api #manual #zettelstore\") (title \"API: Retrieve metadata and content of an existing zettel\")) (rights 62) (encoding \"\") (content \"The [[endpoint|00001012920000]] to work with metadata and content of a specific zettel is ''/z/{ID}'', where ''{ID}'' is a placeholder for the [[zettel identifier|00001006050000]].\\n\\nFor example, ...\n```\n\nIf you print the result a little bit nicer, you will see its structure:\n```\n(zettel (meta (back \"00001006000000 00001012000000 00001012053200 00001012054400\")\n (backward \"00001006000000 00001012000000 00001012053200 00001012054400 00001012920000\")\n (box-number \"1\")\n (created \"20211004093206\")\n (forward \"00001006020000 00001006050000 00001010040100 00001012050200 00001012053400 00001012920000 00001012920800 00001012921200 00001012930500\")\n (modified \"20230703174152\")\n (published \"20230703174152\")\n (role \"manual\")\n (syntax \"zmk\")\n (tags \"#api #manual #zettelstore\")\n (title \"API: Retrieve metadata and content of an existing zettel\"))\n (rights 62)\n (encoding \"\")\n (content \"The [[endpoint|00001012920000]] to work with metadata and content of a specific zettel is ''/z/{ID}'', where ''{ID}'' is a placeholder for the [[zettel identifier|00001006050000]].\\n\\nFor example, ...\n```\n\n* The result is a list, starting with the symbol ''zettel''.\n* Then, some key/value pairs are following, also nested.\n* Nested in ''meta'' are the metadata, each as a key/value pair.\n* ''rights'' specifies the [[access rights|00001012921200]] the user has for this zettel.\n* ''\"encoding\"'' states how the content is encoded.\n Currently, only two values are allowed: the empty string (''\"\"'') that specifies an empty encoding, and the string ''\"base64\"'' that specifies the [[standard Base64 encoding|https://www.rfc-editor.org/rfc/rfc4648.txt]].\n* The zettel contents is stored as a value of the key ''content''.\n Typically, text content is not encoded, and binary content is encoded via Base64.\n\n=== HTTP Status codes\n; ''200''\n: Retrieval was successful, the body contains an appropriate data value.\n; ''204''\n: Request was valid, but there is no data to be returned.\n Most likely, you specified the query parameter ''part=content'', but the zettel does not contain any content.\n; ''400''\n: Request was not valid. \n There are several reasons for this.\n Maybe the [[zettel identifier|00001006050000]] did not consists of exactly 14 digits.\n; ''403''\n: You are not allowed to retrieve data of the given zettel.\n; ''404''\n: Zettel not found.\n You probably used a zettel identifier that is not used in the Zettelstore."))