API Reference
Shirone-Admin's backend is a local Fastify service, and the admin UI itself works entirely through this set of APIs. You can also call them directly, treating the Admin as a programmable gateway to your content repository—bulk scripts, external editor integration, and automation pipelines are all viable.
This section is written for readers familiar with HTTP and the layout of the content repository. Endpoints are grouped by backend module; each one documents its purpose, parameters, return value, and a minimal runnable example.
Base Conventions
| Item | Value |
|---|---|
| Base URL | http://127.0.0.1:5175 (changeable via ADMIN_PORT; bound to loopback only) |
| Path prefix | /api |
| Auth | None. A local single-machine tool that is not exposed to the LAN—do not reverse-proxy it to the public internet |
| Request body | JSON (bodyLimit 2MB); file uploads use multipart (≤30MB per file, one file at a time) |
| CORS | Fully open (origin: true), handy for debugging from any local page |
Error Format
Every error returns a JSON body with the single field message (in Chinese), paired with an appropriate HTTP status code:
{ "message": "文件不存在" }| Status | Source |
|---|---|
400 | Business validation failure (ApiError) or a zod request validation failure—message looks like body.title: 标题不能为空, assembled as "field: reason" |
404 | Path does not exist, or the requested post/file target is missing (ENOENT) |
413 | Uploaded file exceeds 30MB |
500 | Unexpected error; message carries the raw error text |
Static Asset Mounts
Three read-only static routes serve content repository files directly (the content repository wins on a hit, otherwise it falls back to the same-named path in the theme repository); this is how the admin UI's image previews work:
| Prefix | Served directory | Purpose |
|---|---|---|
/content-assets/* | content repository assets/ (falls back to theme src/assets/) | Preview of build-time assets such as avatars and banners |
/content-public/* | content repository public/ (falls back to theme public/) | Preview of Moment images, music, and anime covers |
/content-posts/* | content repository content/posts/ | Post images (direct links for ./images/… relative references) |
All paths go through resolve validation and cannot escape the root directory (directory-traversal safe).
Endpoint Index
| Group | Contents |
|---|---|
| System & Preview | Connection status probing; start/stop/status of the live site preview processes |
| Posts | Post CRUD, slug suggestions, bulk category/tag rename |
| Moments | Moments CRUD |
| Media Upload | Post images, Moment images, site images, data covers, music audio |
| Site Settings | Read/write of the four config domains (site/profile/navbar/footer) |
| Structured Data | Read/write of the eight data/*.ts types, anime entry search and cover import |
| Publish & Validation | Publish preview, remote probing, one-click publish, dry-run validation |
| AI Services | Provider configuration, chat/rewrite (including SSE streaming), and the various AI workflows |
| Jianshu Import | Export-archive sessions, background import jobs, single-post paste |
Common Behaviors
- Write target: apart from AI settings (
server/data/ai-settings.json), every write lands in the content repository pointed to byCONTENT_DIR - Path parameters: parameters referring to post/Moment paths are POSIX-style paths relative to the content repository (e.g.
hello/index.md), always/-separated - Date formats: post
publishedisYYYY-MM-DD;publishedAtisYYYY-MM-DDTHH:mm:ss+08:00; MomentpublishedisYYYY-MM-DD HH:mm:ss
Quick Check
With the service running, one command confirms connectivity:
curl http://127.0.0.1:5175/api/statusIf it returns the content/theme repository paths, connection status, and a git summary, the API is ready.