两种认证方式,灵活选择
在请求头中携带 Authorization: Bearer YOUR_API_KEY,适合服务端集成与自动化脚本。
通过用户登录接口获取会话 Cookie,后续请求自动携带。适合前端应用与用户中心相关接口。
覆盖短链全生命周期管理(标注"开发中"的接口尚未开放)
/api.php?action=create
🔒 API Key
创建短链接
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| url | string | 必填 | 原始长链接 URL,需包含协议(http/https) |
| custom_code | string | 可选 | 自定义短码,3-16 位字母数字,不填则自动生成 |
| password | string | 可选 | 访问密码,为空则不设密码 |
| expire_hours | int | 可选 | 过期时间(小时),为空则永久有效 |
| template_id | int | 可选 | 跳转模板 ID,默认使用系统默认模板 |
| folder_id | int | 可选 | 所属文件夹 ID |
/api.php?action=get_stats
🔒 API Key
获取链接统计
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| code | string | 必填 | 短码 |
/api.php?action=batch_create
⚠ 开发中
🔒 API Key
批量创建短链接(开发中)
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| urls | array | 必填 | URL 数组,每项可包含 url/custom_code/password 等字段 |
| common_settings | object | 可选 | 通用设置(密码、有效期、模板等) |
/api.php?action=list
🔒 API Key
获取链接列表
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| page | int | 可选 | 页码,默认 1 |
| limit | int | 可选 | 每页数量,默认 20,最大 100 |
| folder_id | int | 可选 | 按文件夹筛选 |
| status | string | 可选 | 状态筛选:enabled/disabled/expired |
/api.php?action=update
🔒 API Key
更新链接信息
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| code | string | 必填 | 要更新的短码 |
| password | string | 可选 | 新密码(为空则移除密码) |
| expire_hours | int | 可选 | 新的过期时间 |
| status | string | 可选 | enabled/disabled |
/api.php?action=delete
🔒 API Key
删除短链接
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| code | string | 必填 | 要删除的短码 |
/api.php?action=points_signin
🔒 登录态 / API Key
积分签到
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| 无参数 | |||
/api.php?action=ai_chat
🔒 API Key
AI 对话生成短链
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| message | string | 必填 | 自然语言指令,如"生成 example.com 的短链" |
| session_id | string | 可选 | 会话 ID 以保持上下文 |
复制即用,5 分钟完成集成
# 创建短链接 curl -X POST 'https://duan.hshen.eu.cc/api.php?action=create' \ -H 'Authorization: Bearer YOUR_API_KEY' \ -H 'Content-Type: application/x-www-form-urlencoded' \ -d 'url=https://example.com&custom_code=mylink' # 获取统计 curl 'https://duan.hshen.eu.cc/api.php?action=get_stats&code=mylink' \ -H 'Authorization: Bearer YOUR_API_KEY'
// 创建短链接
const response = await fetch('https://duan.hshen.eu.cc/api.php?action=create', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
url: 'https://example.com',
custom_code: 'mylink'
})
});
const data = await response.json();
console.log(data.short_url);
<?php
$ch = curl_init('https://duan.hshen.eu.cc/api.php?action=create');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
'url' => 'https://example.com',
'custom_code' => 'mylink'
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_API_KEY'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$data = json_decode($response, true);
echo $data['data']['short_url'];
import requests
# 创建短链接
response = requests.post(
'https://duan.hshen.eu.cc/api.php?action=create',
headers={'Authorization': 'Bearer YOUR_API_KEY'},
data={
'url': 'https://example.com',
'custom_code': 'mylink'
}
)
data = response.json()
print(data['data']['short_url'])
统一格式的错误响应,便于调试与处理
速率限制与套餐配额体系正在开发中,当前 API 免费开放,暂不限制调用频率
X-RateLimit-Remaining 与 X-RateLimit-Reset 便于客户端限流控制(开发中)
实时事件推送正在开发中,上线后无需轮询即可获得链接动态
上线后可在用户中心 > 开发者设置中配置 Webhook URL,选择需要订阅的事件类型,并支持自定义签名密钥验证请求来源。