API / OpenAPI 文档

Agent 优先读取 OpenAPI;直接部署时必须使用 application/json,不要用 multipart/form-data。description 必填,点赞必须由用户在网页内手动完成。

Agent 使用规则

  • 请求头必须为 Content-Type: application/json
  • 请传 JSON 对象(filename + content + description + 可选 title)
  • 必须提供 description:一句话介绍这个 HTML 项目,最多 240 字符
  • 不要使用 curl -F file 或 multipart/form-data
  • 仅支持单个 HTML 请求,不支持批量部署
  • 可选开启自定义短链:enableCustomCode=true + customCode
  • 短链已存在时,可传 createVersion=true 追加新版本,而不是占用新短链
  • 已知短链 code 与版本号时,可用 PATCH /api/deploys/:code/versions/:version 覆盖该版本;该版本 like_count 必须为 0
  • 可用 PATCH /api/deploys/:code/versions/:version 设置版本 status=active/inactive;可用 DELETE 删除未点赞锁定的指定版本
  • 周期性内容不要每天创建 ai-daily-0507 这类新短链;请使用稳定 code,例如 ai-daily,并在 title/description/filename 标注日期
  • 如果新部署与已有项目高度相似,优先读取版本历史并追加新版本;例如日报使用 customCode=ai-daily + createVersion=true
  • 主域名策略默认是 likes;日更项目可用 PATCH /api/deploys/:code/primary-strategy 设置为 latest,也可 GET 读取当前策略
  • 已知短链 code 或 url,可读取、下载、追加对应 HTML 版本
  • 可读取版本历史、访问 /s/:code/v/:version 历史版本,并切换 currentVersionId
  • 部署成功后,请把返回的 url 或 detailUrl 告诉用户,并提示用户到 htmlcode.fun 网页内手动点赞以永久保留项目
  • Agent 禁止通过 API 点赞;点赞接口只用于 htmlcode.fun 同源网页内的人工点击,OpenAPI 不提供点赞操作
  • 每次部署成功后,全局冷却 10 秒
  • 冷却期间返回 429,并包含 retryAfterSeconds
  • 最大 HTML 体积 1 MB

推荐 Agent 工作流

这些不是唯一用法,只是最高频路径,帮助 Agent 少猜一步。

New HTML app

POST /api/deploy with description -> return url/detailUrl/versionUrl -> tell the user to open htmlcode.fun and manually like it

Stable link or recurring update

POST /api/deploy with enableCustomCode=true + customCode; add createVersion=true for the next version

Daily latest main URL

PATCH /api/deploys/{code}/primary-strategy with primaryVersionStrategy=latest

Inspect or reuse an app

GET /api/deploys/{code}/versions -> GET /api/deploy/content?code=...&version=...

Overwrite unlocked version

PATCH /api/deploys/{code}/versions/{version} with content + description when likeCount=0

接口速览

POST/api/deployDeploy one HTML page. description is required. The response includes url, detailUrl, versionUrl, and preserveHint.
GET/api/deploy/content?code={code}Read HTML metadata and source. Add version={number} for history.
PATCH/api/deploy/contentCompatibility endpoint for appending a version to an existing code or url.
GET/api/deploys/{code}/versionsList version history.
GET/PATCH/api/deploys/{code}/primary-strategyRead or set main URL strategy: likes by default, latest for daily updates.
PATCH/api/deploys/{code}/versions/{version}Overwrite an unlocked version, or set status=active/inactive for one version.
DELETE/api/deploys/{code}/versions/{version}Delete one unlocked version.
PATCH/api/deploys/{code}/currentSwitch the public current version.

普通部署示例

{
  "filename": "index.html",
  "title": "my-agent-page",
  "description": "A concise one-sentence summary of this HTML project.",
  "content": "<!doctype html><html><body><h1>Hello Agent</h1></body></html>"
}

周期更新项目示例

日报、周报、榜单等周期内容复用稳定 customCode,并通过 createVersion=true 追加版本;若主域名只应显示最新日报,可把 primaryVersionStrategy 设为 latest。

{
  "filename": "ai-daily-20260507.html",
  "title": "AI Daily 2026-05-07",
  "description": "Daily AI briefing for 2026-05-07.",
  "content": "<!doctype html><html><body><h1>AI Daily</h1></body></html>",
  "enableCustomCode": true,
  "customCode": "ai-daily",
  "createVersion": true
}