From 447d9bc1d80bc792129e80eb685d8d12670c6cf1 Mon Sep 17 00:00:00 2001 From: Erik Michelson Date: Sun, 13 Oct 2019 01:34:09 +0200 Subject: Added API-doc as markdown file Signed-off-by: Erik Michelson --- docs/dev/api.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 docs/dev/api.md (limited to 'docs/dev/api.md') diff --git a/docs/dev/api.md b/docs/dev/api.md new file mode 100644 index 00000000..43bc9143 --- /dev/null +++ b/docs/dev/api.md @@ -0,0 +1,43 @@ +# API documentation +Several tasks of CodiMD can be automated through HTTP requests. +The available endpoints for this api are described in this document. +For code-autogeneration there is an OpenAPIv3-compatible description available [here](openapi.yml). + +## Notes +These endpoints create notes, return information about them or export them. +You have to replace _\_ with either the alias or id of a note you want to work on. + +| Endpoint | HTTP-Method | Description | +|---|---|---| +| `/new` | `GET` | **Creates a new note.**
A random id will be assigned and the content will equal to the template (blank by default). After note creation a redirect is issued to the created note. | +| `/new` | `POST` | **Imports some markdown data into a new note.**
A random id will be assigned and the content will equal to the body of the received HTTP-request. The `Content-Type: text/markdown` header should be set on this request. | +| `/new/` | `POST` | **Imports some markdown data into a new note with a given alias.**
This endpoint equals to the above one except that the alias from the url will be assigned to the note if [FreeURL-mode](../configuration-env-vars.md#users-and-privileges) is enabled. | +| `//download` or `/s//download` | `GET` | **Returns the raw markdown content of a note.** | +| `//pdf` | `GET` | **Returns a generated pdf version of the note.**
If pdf-support is disabled, a HTTP 403 will be returned.
_Please note: Currently pdf export is disabled generally because of a security problem with it._ | +| `//publish` | `GET` | **Redirects to the published version of the note.** | +| `//slide` | `GET` | **Redirects to the slide-presentation of the note.**
This is only useful on notes which are designed to be slides. | +| `//info` | `GET` | **Returns metadata about the note.**
This includes the title and description of the note as well as the creation date and viewcount.The data is returned as a JSON object. | +| `//revision` | `GET` | **Returns a list of the available note revisions.**
The list is returned as a JSON object with an array of revision-id and length associations. The revision-id equals to the timestamp when the revision was saved. | +| `//revision/` | `GET` | **Returns the revision of the note with some metadata.**
The revision is returned as a JSON object with the content of the note and the authorship. | +| `//gist` | `GET` | **Creates a new GitHub Gist with the note's content.**
If [GitHub integration](../configuration-env-vars.md#github-login) is configured, the user will be redirected to GitHub and a new Gist with the content of the note will be created. | + +## User / History +These endpoints return information about the current logged-in user and it's note history. If no user is logged-in, the most of this requests will fail with either a HTTP 403 or a JSON object containing `{"status":"forbidden"}`. + +| Endpoint | HTTP-Method | Description | +|---|---|---| +| `/me` | `GET` | **Returns the profile data of the current logged-in user.**
The data is returned as a JSON object containing the user-id, the user's name and a url to the profile picture. | +| `/me/export` | `GET` | **Exports a zip-archive with all notes of the current user.** | +| `/history` | `GET` | **Returns a list of the last viewed notes.**
The list is returned as a JSON object with an array containing for each entry it's id, title, tags, last visit time and pinned status. | +| `/history` | `POST` | **Replace user's history with a new one.**
The body must be form-encoded and contain a field `history` with a JSON-encoded array like its returned from the server when exporting the history. | +| `/history` | `DELETE` | **Deletes the user's history.** | +| `/history/` | `POST` | **Toggles the pinned status in the history for a note.**
The body must be form-encoded and contain a field `pinned` that is either `true` or `false`. +| `/history/` | `DELETE` | **Deletes a note from the user's history.** | + + +## CodiMD-server +These endpoints return information about the running CodiMD instance. + +| Endpoint | HTTP-Method | Description | +|---|---|---| +| `/status` | `GET` | **Returns the current status of the CodiMD instance.**
The data is returned as a JSON object containing the number of notes stored on the server, (distinct) online users and more. | -- cgit v1.2.3 From 93ca037a759ea34c40ef069a78d29505d0ac300d Mon Sep 17 00:00:00 2001 From: Erik Michelson Date: Tue, 15 Oct 2019 00:58:40 +0200 Subject: WIP: Adding openapi doc Signed-off-by: Erik Michelson --- docs/dev/api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs/dev/api.md') diff --git a/docs/dev/api.md b/docs/dev/api.md index 43bc9143..4c1365b5 100644 --- a/docs/dev/api.md +++ b/docs/dev/api.md @@ -16,7 +16,7 @@ You have to replace _\_ with either the alias or id of a note you want to | `//pdf` | `GET` | **Returns a generated pdf version of the note.**
If pdf-support is disabled, a HTTP 403 will be returned.
_Please note: Currently pdf export is disabled generally because of a security problem with it._ | | `//publish` | `GET` | **Redirects to the published version of the note.** | | `//slide` | `GET` | **Redirects to the slide-presentation of the note.**
This is only useful on notes which are designed to be slides. | -| `//info` | `GET` | **Returns metadata about the note.**
This includes the title and description of the note as well as the creation date and viewcount.The data is returned as a JSON object. | +| `//info` | `GET` | **Returns metadata about the note.**
This includes the title and description of the note as well as the creation date and viewcount. The data is returned as a JSON object. | | `//revision` | `GET` | **Returns a list of the available note revisions.**
The list is returned as a JSON object with an array of revision-id and length associations. The revision-id equals to the timestamp when the revision was saved. | | `//revision/` | `GET` | **Returns the revision of the note with some metadata.**
The revision is returned as a JSON object with the content of the note and the authorship. | | `//gist` | `GET` | **Creates a new GitHub Gist with the note's content.**
If [GitHub integration](../configuration-env-vars.md#github-login) is configured, the user will be redirected to GitHub and a new Gist with the content of the note will be created. | -- cgit v1.2.3