nyxxworks / docs /API.md
Kazzze's picture
Update to current version
e94c49d verified
|
Raw History Blame Contribute Delete
5.09 kB
# HTTP routes
Everything is under `/nyxxworks` on the host's address, the same on both hosts. The table is `routes()` in `nyxxworks/web.py`; each route is answered by a plain function of `Works` that returns `(status, body)`.
- A `GET` takes its values from the query, a `POST` from a JSON body, unless the table says the body is a file.
- JSON answers are sent with `Cache-Control: no-store`. An error is `{"error": "..."}` with a 4xx status, in words meant for the user.
- There is no authentication of its own: the page is as open as the host is.
## The page
| Route | What it gives |
|---|---|
| `GET /ui` | The page |
| `GET /static/...` | The built files of the page, from `ui/dist` |
## What the host has
| Route | What it gives |
|---|---|
| `GET /options` | `host`, `names` (which names of ComfyUI are a sampler or a schedule the A1111 family calls otherwise), `model`, `models`, `loras`, `samplers`, `schedulers`, `upscalers`, `modelDefaults`, `defaults` and `settings` (the form as new and as it was last), `finish`, `limits`, `variation`, `detail`, `repaint`, `axes` |
## Jobs
| Route | Body | What it does |
|---|---|---|
| `GET /jobs` | | `jobs`: each with `id`, `kind`, `state`, `total`, `done`, `progress`, `error`, `pictures`, `sheet`; and `model`, the checkpoint the host has loaded now |
| `POST /jobs/cancel` | `job` | A waiting job is dropped; a running one ends after the picture being made |
| `POST /sheet` | `request`; or `like`: `{id, strength, count}` | Ask for a sheet. A seed of -1 is settled here. With `like`, a sheet of pictures like that one |
| `POST /matrix` | `request`, `x`, `y` | Ask for a sheet varied along axes. `y` may be left out |
| `POST /finish` | `ids`, `how` | Finish picked pictures: enlarge, go over, then the details |
A `request` has `prompt`, `negative`, `width`, `height`, `steps`, `cfg`, `sampler`, `scheduler`, `seed`, `count`, `model`, `cards` (each `{source, name}`) and `refs` (each `{id, kind, weight}`).
## The library
| Route | Body | What it does |
|---|---|---|
| `GET /library` | | `sheets` with their pictures, and `tray`: the picked pictures |
| `POST /mark` | `id`, and any of `picked`, `rejected`, `station` | Pick or reject a picture, or move it to a station |
| `GET /image/{id}/{size}` | | A picture; `size` is `thumb` or `full`. Never changes, so the browser may keep it |
| `POST /import?name=` | a PNG file | Take a picture in as a sheet of one; answers with the request its parameters give |
## Cards
| Route | Body or query | What it does |
|---|---|---|
| `GET /cards` | | `packs` with their categories, and `total` |
| `GET /cards/find` | `source`, `category`, `q`, `offset` | Cards of a pack and a category that match a search; each may be left out. They come grouped by pack and, in a pack, by category; `groups` names every group of the whole answer with its count |
| `POST /cards/compose` | `prompt`, `negative`, `cards` | What a text and cards give together, to show before a sheet is asked for |
## Reference pictures
| Route | Body or query | What it does |
|---|---|---|
| `GET /references` | `model` | `cards`, and `ways`: what this host can follow with that model (the loaded one when none is named), each `{kind, with}` |
| `POST /references/add?name=` | an image file | Keep a picture from outside as a reference card |
| `POST /references/from` | `id` | Keep a picture of the library as a reference card |
| `POST /references/delete` | `id` | |
| `GET /reference/{id}/{size}` | | A reference picture; `thumb` or `full` |
## Fix
| Route | Body | What it does |
|---|---|---|
| `POST /fix/repaint` | `id`, `strokes`, `prompt`, `count`, `strength` | Repaint a spot of a picked picture as several variants. None of them replaces the picture yet |
| `POST /fix/promote` | `id`, `variant` | A variant becomes the newest version of the picked picture |
| `POST /fix/keep` | `tool`, `session`, `id` | Keep what the anatomy tool, the text tool or the Letter station made of a picture |
The copied tools keep their own routes under their own prefixes: `/nyxxworks/anatomy/...`, `/nyxxworks/text/...` and `/nyxxworks/letter/...`. Each is answered by the tool's own code; the tools' repositories describe them.
## Recipes and statistics
| Route | Body | What it does |
|---|---|---|
| `GET /recipes` | | `recipes` |
| `POST /recipes/save` | `name`, `note`, `request`, `finish`, `axes` | Keep the way of working the forms hold now |
| `POST /recipes/from` | `id` | Keep how a picture was made, its seed included |
| `POST /recipes/use` | `id` | The recipe made ready for this host: the request, the finishing, the axes, and `notes` on what was replaced. Changes and makes nothing |
| `POST /recipes/rename` | `id`, `name`, `note` | |
| `POST /recipes/delete` | `id` | |
| `GET /recipes/{id}/file` | | The recipe as a `.nyxx.json` download |
| `POST /recipes/import` | a recipe file | Take a recipe file in |
| `GET /stats` | | How often each card and each value of a setting was used, picked and rejected |