From fcf1ec4c914c44d9a4ff39636aef8f1307adccab Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Thu, 24 Mar 2022 00:25:41 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=8F=90=E4=BE=9B=E8=AF=BB=E5=86=99?= =?UTF-8?q?=E6=96=87=E4=BB=B6=20API=20Fix=20https://github.com/siyuan-note?= =?UTF-8?q?/siyuan/issues/4343?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- API.md | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/API.md b/API.md index 0730d2fcc..4d15bc941 100644 --- a/API.md +++ b/API.md @@ -34,6 +34,9 @@ * [Execute SQL query](#Execute-SQL-query) * [Templates](#Templates) * [Render a template](#Render-a-template) +* [File](#File) + * [Get File](#Get-file) + * [Put File](#Put-file) * [Export](#Export) * [Export Markdown](#Export-Markdown) * [System](#System) @@ -50,7 +53,8 @@ * Endpoint: `http://127.0.0.1:6806` * Both are POST methods -* An interface with parameters is required, the parameter is a JSON string, placed in the body, and the header Content-Type is `application/json` +* An interface with parameters is required, the parameter is a JSON string, placed in the body, and the header + Content-Type is `application/json` * Return value ````json @@ -61,9 +65,9 @@ } ```` - * `code`: non-zero for exceptions - * `msg`: an empty string under normal circumstances, an error text will be returned under abnormal conditions - * `data`: may be `{}`, `[]` or `NULL`, depending on the interface + * `code`: non-zero for exceptions + * `msg`: an empty string under normal circumstances, an error text will be returned under abnormal conditions + * `data`: may be `{}`, `[]` or `NULL`, depending on the interface ### Authentication @@ -305,7 +309,8 @@ View API token in Settings - About, request header: `Authorization: T ``` * `notebook`: Notebook ID - * `path`: Document path, which needs to start with / and separate levels with / (path here corresponds to the database hpath field) + * `path`: Document path, which needs to start with / and separate levels with / (path here corresponds to the + database hpath field) * `markdown`: GFM Markdown content * Return value @@ -318,7 +323,8 @@ View API token in Settings - About, request header: `Authorization: T ``` * `data`: Created document ID - * If you use the same `path` to call this interface repeatedly, the existing document will not be overwritten, but a new document ending with a random number will be created + * If you use the same `path` to call this interface repeatedly, the existing document will not be overwritten, but a + new document ending with a random number will be created ### Rename a document @@ -432,7 +438,7 @@ View API token in Settings - About, request header: `Authorization: T } ``` - * `id`:Block ID + * `id`:Block ID * Return value ```json @@ -474,7 +480,9 @@ View API token in Settings - About, request header: `Authorization: T ``` * `errFiles`: List of filenames with errors in upload processing - * `succMap`: For successfully processed files, the key is the file name when uploading, and the value is assets/foo-id.png, which is used to replace the asset link address in the existing Markdown content with the uploaded address + * `succMap`: For successfully processed files, the key is the file name when uploading, and the value is + assets/foo-id.png, which is used to replace the asset link address in the existing Markdown content with the + uploaded address ## Blocks @@ -780,12 +788,11 @@ View API token in Settings - About, request header: `Authorization: T * `/api/file/getFile` * Parameters - ``json - { - "path": "/data/20210808180117-6v0mkxr/20200923234011-ieuun1p.sy" - } - `` - * `path`: the file path under the workspace path + ``json { + "path": "/data/20210808180117-6v0mkxr/20200923234011-ieuun1p.sy" + } + `` + * `path`: the file path under the workspace path * Return value File content @@ -795,10 +802,10 @@ View API token in Settings - About, request header: `Authorization: T * `/api/file/putFile` * The parameter is an HTTP Multipart form - * `path`: the file path under the workspace path - * `isDir`: whether to create a folder, when `true` only create a folder, ignore `file` - * `modTime`: last access and modification time, Unix time - * `file`: the uploaded file + * `path`: the file path under the workspace path + * `isDir`: whether to create a folder, when `true` only create a folder, ignore `file` + * `modTime`: last access and modification time, Unix time + * `file`: the uploaded file * return value ```json