|
| 1 | +# API-Notes |
| 2 | + |
| 3 | +Dead simple service for publishing notes via API. Markdown supported. |
| 4 | + |
| 5 | +The service exposes minimal API for upload markdown (with attachments) and render it as HTML. |
| 6 | + |
| 7 | +The generated link is 16-bytes randomly generated and can be shared relatively safely. |
| 8 | + |
| 9 | +The API-Notes is NOT serving notes - any reverse proxy must do it. With authorization if needed. |
| 10 | +See [docker-compose.yaml]. |
| 11 | + |
| 12 | +Supported markdown extensions: |
| 13 | + |
| 14 | +- GFM (GitHub Flavored Markdown) |
| 15 | +- Footnotes |
| 16 | +- Basic syntax highlighting |
| 17 | +- Mermaid |
| 18 | +- MathJax |
| 19 | +- Embedded youtube |
| 20 | + |
| 21 | +## Installation |
| 22 | + |
| 23 | +- Docker: `ghcr.io/reddec/api-notes:latest` |
| 24 | +- Go: `go install github.com/reddec/api-notes/cmd/...@latest` |
| 25 | + |
| 26 | +## Configuration |
| 27 | + |
| 28 | +| Environment variable | Default | Description | |
| 29 | +|----------------------|-------------------------|------------------------------| |
| 30 | +| `PUBLIC_URL` | `http://127.0.0.1:8080` | Public URL to where redirect | |
| 31 | +| `BIND` | `127.0.0.1:8080` | Binding address | |
| 32 | +| `DIR` | `notes` | Directory for notes | |
| 33 | + |
| 34 | +Differences in docker version |
| 35 | + |
| 36 | +| Environment variable | Default | Description | |
| 37 | +|----------------------|----------------|---------------------| |
| 38 | +| `BIND` | `0.0.0.0:8080` | Binding address | |
| 39 | +| `DIR` | `/data` | Directory for notes | |
| 40 | + |
| 41 | +## API |
| 42 | + |
| 43 | +Supported content type: |
| 44 | + |
| 45 | +- `application/json`: only `title` (string) and `text` (string) supported |
| 46 | +- `application/x-www-form-urlencoded`: only `title` and `text` field supported |
| 47 | +- `multipart/form-data`: `title`, `text` and any file(s) supported |
| 48 | + |
| 49 | +> Note: note ID should not be escaped |
| 50 | +
|
| 51 | +### Create note |
| 52 | + |
| 53 | + POST /note |
| 54 | + |
| 55 | +Returns `303 See Other` with public link in header `Location`, and ID in `X-Correlation-Id`. |
| 56 | + |
| 57 | +**Example** |
| 58 | + |
| 59 | +Create with basic form |
| 60 | + |
| 61 | + curl -v -d 'title=hello&text=this is text' http://127.0.0.1:8080/note |
| 62 | + |
| 63 | +Create with JSON |
| 64 | + |
| 65 | + curl -v -H 'Content-Type: application/json' --data-binary '{"title": "hello", "text": "this is text"}' http://127.0.0.1:8080/note |
| 66 | + |
| 67 | +Create with attachments |
| 68 | + |
| 69 | + curl -v -F title=hello -F text="this is text" -F file1=@file1 -F file2=@file2 http://127.0.0.1:8080/note |
| 70 | + |
| 71 | +### Update note |
| 72 | + |
| 73 | + PUT /note/{note ID} |
| 74 | + |
| 75 | +Returns `303 See Other` with public link (old) in header `Location`. |
| 76 | + |
| 77 | +**Example** |
| 78 | + |
| 79 | +Update note (id: `b6/22/7f/2ce9505bef907fa98075f852b6`) with basic form |
| 80 | + |
| 81 | + curl -X PUT -v -d 'title=hello&text=this is another text' http://127.0.0.1:8080/note/b6/22/7f/2ce9505bef907fa98075f852b6 |
| 82 | + |
| 83 | +### Delete note |
| 84 | + |
| 85 | + DELETE /note/{note ID} |
| 86 | + |
| 87 | +Returns `204 No Content` |
| 88 | + |
| 89 | +**Example** |
| 90 | + |
| 91 | +Delete note (id: `b6/22/7f/2ce9505bef907fa98075f852b6`) |
| 92 | + |
| 93 | + curl -X DELETE -v http://127.0.0.1:8080/note/b6/22/7f/2ce9505bef907fa98075f852b6 |
0 commit comments