From 0503c1e72efd468528e43f9e0d754fca39c1dc0d Mon Sep 17 00:00:00 2001 From: yaoresugi Date: Mon, 20 Oct 2025 23:40:31 +0900 Subject: [PATCH] =?UTF-8?q?API=E3=81=AE=E3=83=89=E3=82=AD=E3=83=A5?= =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=83=88=E5=A4=89=E6=9B=B4=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/API.md | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/docs/API.md b/docs/API.md index a8d95ca..c43c905 100644 --- a/docs/API.md +++ b/docs/API.md @@ -1,64 +1,68 @@ ## API ```http -GET /api/all +GET {BASE_PATH}/api/all ``` Returns all hosts in `json`. ```http -GET /api/history +GET {BASE_PATH}/api/history ``` Returns all History. Not recommended, the output can be a lot. ```http -GET /api/history/:mac/:date +GET {BASE_PATH}/api/history/:mac/:date ``` Returns only history of a device with this `mac` filtered by `date`. `date` format can be anything from `2` to `2025-07` to `2025-07-26`. ```http -GET /api/history/:mac?num=20 +GET {BASE_PATH}/api/history/:mac?num=20 ``` Returns only last 20 lines of history of a device with this `mac`. ```http -GET /api/host/:id +GET {BASE_PATH}/api/host/:id ``` Returns host with this `id` in `json`. ```http -GET /api/port/:addr/:port +GET {BASE_PATH}/api/port/:addr/:port ``` Gets state of one `port` of `addr`. Returns `true` if port is open or `false` otherwise.
Request example ```bash -curl http://0.0.0.0:8840/api/port/192.168.2.2/8844 +# No base path +curl "http://0.0.0.0:8840/api/port/192.168.2.2/8844" + +# Generic form +curl "http://0.0.0.0:8840{BASE_PATH}/api/port/192.168.2.2/8844" ```

```http -GET /api/edit/:id/:name/*known +GET {BASE_PATH}/api/edit/:id/:name/*known ``` Edit host with ID `id`. Can change `name`. `known` is optional, when set to `toggle` will change Known state. ```http -GET /api/host/del/:id +GET {BASE_PATH}/api/host/del/:id ``` Remove host with ID `id`. ```http -GET /api/notify_test +GET {BASE_PATH}/api/notify_test ``` Send test notification. ```http -GET /api/status/*iface +GET {BASE_PATH}/api/status/*iface ``` -Show status (Total number of hosts, online/offline, known/unknown). The `iface` parameter is optional and shows status for one interface only. For all interfaces just call `/api/status/`. \ No newline at end of file +Show status (Total number of hosts, online/offline, known/unknown). The `iface` parameter is optional and shows status for one interface only. For all interfaces just call `{BASE_PATH}/api/status/`. \ No newline at end of file