HTML 网页静态托管 API 接口文档(可集成到智能体Agent)
接口概述
本接口用于将HTML代码转换为可访问的网页,支持通过API密钥进行身份验证。
API 密钥申请地址:
https://www.cuobiezi.net/user/api_keys/apply
API接口信息
接口地址
https://www.cuobiezi.net/showshow/api/v1/html_to_web
请求参数
请求体格式
{
"api_key": "your_api_key_here",
"html": "your_html_code_here"
}
参数说明
参数名 |
类型 |
必填 |
说明 |
api_key |
string |
是 |
用户的API密钥,用于身份验证 |
html |
string |
是 |
要转换为网页的HTML代码 |
请求示例
{
"api_key": "jc-1234567890abcdef",
"html": "<!DOCTYPE html><html><head><title>我的网页</title></head><body><h1>欢迎访问我的网页</h1></body></html>"
}
响应格式
成功响应
{
"is_ok": true,
"message": "HTML page created successfully",
"url": "https://a7bbe4ce-5d8d-11f0-9693-fa163ed36b8d.wangye.domolo.cn/p/4dg4l1qpx0.html"
}
失败响应
{
"is_ok": false,
"message": "错误信息描述",
"url": ""
}
响应参数说明
参数名 |
类型 |
说明 |
is_ok |
boolean |
请求是否成功,true表示成功,false表示失败 |
message |
string |
响应消息,成功时显示成功信息,失败时显示错误原因 |
url |
string |
成功时返回生成的网页访问地址,失败时为空字符串 |
错误码说明
HTTP状态码 |
说明 |
可能原因 |
200 |
成功 |
请求处理成功 |
400 |
请求错误 |
JSON格式错误、HTML代码无效 |
401 |
未授权 |
API密钥无效、过期或未激活 |
500 |
服务器错误 |
服务器内部错误、用户创建失败 |
使用说明
- 获取API密钥:首先需要在用户中心申请API密钥
- 准备HTML代码:确保HTML代码格式正确,大小不超过10MB
- 发送请求:使用POST方法发送JSON格式的请求
- 处理响应:根据返回的
is_ok
字段判断请求是否成功
注意事项
- HTML代码中不能包含
<iframe>
标签
- HTML代码大小限制为10MB以内
- API密钥必须有效且未过期
- 生成的网页默认为公开访问
- 生成的网页为永久页面(非临时页面)
示例代码
JavaScript示例
const response = await fetch('https://www.cuobiezi.net/showshow/api/v1/html_to_web', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
api_key: 'your_api_key_here',
html: '<!DOCTYPE html><html><head><title>测试页面</title></head><body><h1>Hello World!</h1></body></html>'
})
});
const result = await response.json();
if (result.is_ok) {
console.log('网页创建成功,访问地址:', result.url);
} else {
console.error('创建失败:', result.message);
}
Python示例
import requests
import json
url = 'https://www.cuobiezi.net/showshow/api/v1/html_to_web'
data = {
'api_key': 'your_api_key_here',
'html': '<!DOCTYPE html><html><head><title>测试页面</title></head><body><h1>Hello World!</h1></body></html>'
}
response = requests.post(url, json=data)
result = response.json()
if result['is_ok']:
print('网页创建成功,访问地址:', result['url'])
else:
print('创建失败:', result['message'])
HTML 静态网页托管服务字根秀秀的介绍
HTML 静态网页托管服务
