Memories Serves
Memories ServesAPI Reference

API Reference

接口参考

所有接口均返回 JSON。管理类接口需要管理员 token,公开读取和写入接口不需要认证。

GET/health

健康检查接口,用于部署平台探活。

curl http://127.0.0.1:3000/health
{ "ok": true }
POST/images

写入单条图片 URL,并返回自增 ID 与上传时间戳。

字段类型必填说明
urlstring必须是 http 或 https URL
curl -X POST http://127.0.0.1:3000/images \
  -H 'content-type: application/json' \
  -d '{"url":"https://example.com/a.jpg"}'
{
  "id": 1,
  "url": "https://example.com/a.jpg",
  "uploaded_at": 1782864000000
}
GET/images?after_id=0

读取图片列表,每页最多 20 条。传入上一页返回的 next_after_id 继续读取。

curl 'http://127.0.0.1:3000/images?after_id=0'
{
  "data": [
    { "id": 1, "url": "https://example.com/a.jpg", "uploaded_at": 1782864000000 }
  ],
  "next_after_id": null,
  "limit": 20
}
GET/admin/token?key=...

获取管理员 token。首次请求会设置管理员 key,后续必须使用同一个 key。

  • token 有效期 10 分钟。
  • 有效期内重复请求返回当前 token。
  • 过期后使用正确 key 自动生成新 token。
curl 'http://127.0.0.1:3000/admin/token?key=your-secret-key'
{
  "token": "ADMIN_TOKEN",
  "expires_at": 1782864600000,
  "ttl_seconds": 600
}
POST/admin/images/delete

推荐删除方式,在 body 中携带 token 和目标 ID。

curl -X POST http://127.0.0.1:3000/admin/images/delete \
  -H 'content-type: application/json' \
  -d '{"token":"ADMIN_TOKEN","id":1}'
{ "deleted": true, "id": 1 }
DELETE/images/:id
curl -X DELETE http://127.0.0.1:3000/images/1 \
  -H 'authorization: Bearer ADMIN_TOKEN'
POST/admin/backup

配置 WebDAV 自动备份。关闭备份时只需传入 token 和 enabled=false。

curl -X POST http://127.0.0.1:3000/admin/backup \
  -H 'content-type: application/json' \
  -d '{
    "token":"ADMIN_TOKEN",
    "enabled":true,
    "webdav_url":"https://dav.example.com/backups/",
    "username":"user",
    "password":"pass"
  }'
{ "ok": true, "enabled": true }