鉴权方式
所有 API 请求需要 Header: Authorization: Bearer <API_KEY>
在控制台 → API 密钥管理创建和管理你的密钥。
提交截图
POST
/api/v1/screenshot
请求参数
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| url | string | 必填 | 网页地址,含 http(s):// |
| width | int | 1280 | 视口宽度(像素) |
| height | int | 720 | 视口高度(像素) |
| fullPage | bool | false | 全页截图(长图) |
| mobile | bool | false | 移动端模拟(375宽) |
| waitMs | int | 0 | 页面加载后额外等待(毫秒) |
| format | string | png | 输出格式:png / jpeg / webp / pdf |
| quality | int | 90 | 图片质量 1-100(jpeg/webp) |
| adBlock | bool | true | 广告拦截 |
| watermark.text | string | - | 水印文字 |
| watermark.position | string | bottom-right | 水印位置 |
| watermark.opacity | int | 50 | 水印透明度 0-100 |
cURL 示例
curl -X POST https://api.songzhiyun.com/api/v1/screenshot \ -H "Authorization: Bearer <API_KEY>" \ -H "Content-Type: application/json" \ -d '{ "url": "https://example.com", "width": 1280, "height": 720, "format": "png" }'
Node.js 示例
const resp = await fetch('https://api.songzhiyun.com/api/v1/screenshot', { method: 'POST', headers: { 'Authorization': 'Bearer <API_KEY>', 'Content-Type': 'application/json' }, body: JSON.stringify({ url: 'https://example.com', width: 1280 }) }); const data = await resp.json();
Python 示例
import requests resp = requests.post( 'https://api.songzhiyun.com/api/v1/screenshot', headers={'Authorization': 'Bearer <API_KEY>'}, json={'url': 'https://example.com', 'width': 1280} ) data = resp.json()
Java 示例
var client = HttpClient.newHttpClient(); var req = HttpRequest.newBuilder() .uri(URI.create("https://api.songzhiyun.com/api/v1/screenshot")) .header("Authorization", "Bearer <API_KEY>") .header("Content-Type", "application/json") .POST(HttpRequest.BodyPublishers.ofString("{\"url\":\"https://example.com\"}")) .build(); var resp = client.send(req, HttpResponse.BodyHandlers.ofString());
响应
{
"code": 0,
"msg": "ok",
"data": {
"taskId": "d55c14cac3da46deba9edfdf2d0f670e",
"status": "pending",
"estimatedSeconds": 8
}
}
查询结果
GET
/api/v1/screenshot/{taskId}
cURL 示例
curl https://api.songzhiyun.com/api/v1/screenshot/{task_id} \ -H "Authorization: Bearer <API_KEY>"
响应(完成时)
{
"code": 0,
"data": {
"taskId": "d55c14cac3da46deba9edfdf2d0f670e",
"status": "done",
"imageUrl": "/screenshots/d55c14cac3da46deba9edfdf2d0f670e.png",
"durationMs": 1317,
"imageSize": 15542
}
}
像素对比
POST
/api/v1/screenshot/compare
curl -X POST https://api.songzhiyun.com/api/v1/screenshot/compare \ -H "Authorization: Bearer <API_KEY>" \ -H "Content-Type: application/json" \ -d '{"imageUrl1":"/screenshots/aaa.png","imageUrl2":"/screenshots/bbb.png"}'
错误码
| code | 说明 |
|---|---|
| 0 | 成功 |
| 1001 | 参数错误或资源不存在 |
| 1002 | 缺少认证信息 |
| 1003 | 配额超限 |
| 1004 | 并发超限 |
| 1006 | 速率限制 |
| 5000 | 服务器内部错误 |