API 文档

使用 REST API 将 QuickLink 集成到你的应用中

注册账号 后可获取 API Key

认证方式

所有请求需在 Header 中携带 API Key:

Authorization: Bearer YOUR_API_KEY

或通过 URL 参数:?api_key=YOUR_API_KEY

POST /api/shorten

创建短链接

请求体(JSON)

{
  "url": "https://example.com/very/long/url",
  "slug": "my-link",   // 可选:自定义别名
  "title": "我的链接"  // 可选:备注
}

响应示例

{
  "id": 42,
  "short_code": "my-link",
  "short_url": "https://test.hkchy.com/my-link",
  "original_url": "https://example.com/very/long/url",
  "created_at": "2026-05-20T14:00:00+08:00"
}
GET /api/links

获取你的所有短链接(最多 50 条)

GET /api/stats/{code}

获取指定短链接的点击统计

示例代码

cURL

curl -X POST https://test.hkchy.com/api/shorten \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com"}'

Python

import requests
r = requests.post(
    "https://test.hkchy.com/api/shorten",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={"url": "https://example.com"}
)
print(r.json()["short_url"])