API文档
最近更新: 2026-07-05
通过hdply API,脚本和AI代理可以以编程方式管理你的网站:列出项目、读取HTML、发布更新、创建新网站。这是一个小巧、可预测的REST API——会用curl就会用hdply。
身份验证
在控制台仪表盘的"API密钥"卡片中创建你的个人API密钥。每个请求都以Bearer令牌形式发送:
Authorization: Bearer hdply_sk_…
密钥仅在创建时显示一次;重新生成会替换旧密钥,删除则立即失效。请妥善保密——它可以访问你的所有项目。
基础URL
https://api.app.hdply.com
端点
GET /v1/projects— 列出你的项目。POST /v1/projects— 创建项目。JSON请求体:{"name": "可选", "html": "可选"}。提供html时网站立即上线;名称缺省时使用HTML的<title>。子域名由服务器随机分配。GET /v1/projects/{id}— 查询单个项目。{id}接受数字id或子域名(如k3v9x2m7q1)。GET /v1/projects/{id}/html— 当前在线的HTML。PUT /v1/projects/{id}/html— 发布新HTML(请求体为原始text/html,请求返回即上线)。GET /v1/projects/{id}/deployments— 部署历史(API部署带有"source": "api"标记)。
没有DELETE。删除网站被有意设计为仅限网页操作,自动化代理永远无法毁掉你的作品。每次API部署都有版本记录——可随时在控制台恢复任意历史版本。
快速上手
export HDPLY_KEY=hdply_sk_…
# create a site and go live in one call
curl -X POST https://api.app.hdply.com/v1/projects \
-H "Authorization: Bearer $HDPLY_KEY" \
-H "Content-Type: application/json" \
-d '{"html": "<!doctype html><title>Hello</title><h1>Hi!</h1>"}'
# → {"project": {"subroute": "k3v9x2m7q1", "url": "https://k3v9x2m7q1.hdply.com", …}}
# read the live HTML
curl https://api.app.hdply.com/v1/projects/k3v9x2m7q1/html \
-H "Authorization: Bearer $HDPLY_KEY"
# publish an update
curl -X PUT https://api.app.hdply.com/v1/projects/k3v9x2m7q1/html \
-H "Authorization: Bearer $HDPLY_KEY" \
-H "Content-Type: text/html" \
--data-binary @index.html
限制与错误
- 每个网站的HTML上限为1 MB(内联CSS/JS的单文件效果最佳)。
- 免费版包含20个网站;Pro不限数量。
- 错误为JSON格式:
{"code": "…", "error": "说明"}。常见代码:unauthorized(401)、project_not_found(404)、project_limit(403)、file_too_large(413)。
Claude与MCP
hdply内置MCP服务器,Claude Code和Claude Desktop可将你的网站作为原生工具使用(list_sites、create_site、get_site_html、deploy_site、get_deploy_history)。Claude Code一条命令即可连接:
claude mcp add --transport http hdply https://api.app.hdply.com/mcp \ --header "Authorization: Bearer hdply_sk_…"
Claude Desktop请在MCP配置文件(claude_desktop_config.json)中添加:
{
"mcpServers": {
"hdply": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://api.app.hdply.com/mcp",
"--header", "Authorization: Bearer hdply_sk_…"]
}
}
}
与AI代理配合使用
将下面的内容连同你的密钥一起粘贴到ChatGPT、Claude或任何能执行shell的代理中。之后只需说"更新我的网站",它就知道怎么做。
You can manage my hdply websites via its REST API.
Base URL: https://api.app.hdply.com
Auth header on every request: "Authorization: Bearer <MY_KEY>"
Endpoints:
- GET /v1/projects -> list my sites
- POST /v1/projects -> create; JSON {"name"?, "html"?}; html goes live instantly
- GET /v1/projects/{id}/html -> current HTML ({id} = numeric id or subdomain)
- PUT /v1/projects/{id}/html -> publish new HTML (raw text/html body)
- GET /v1/projects/{id}/deployments -> version history
Rules: HTML max 1MB, single self-contained file preferred (inline CSS/JS).
There is no delete endpoint. Every deploy is versioned and restorable.
After publishing, the site is live at https://{subroute}.hdply.com immediately.
面向爬虫和代理的机器可读摘要: hdply.com/llms.txt