w.fugui.us 短网址服务 API 接口说明
Base URL: https://w.fugui.us
生成短网址。无需登录即可使用,传入 token 可关联到用户。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| url | string | 必填 | 目标长链接,可省略协议 |
| slug | string | 可选 | 自定义后缀,留空自动生成 |
# 基础用法(匿名) curl -X POST https://w.fugui.us/api/shorten \ -H "Content-Type: application/json" \ -d '{"url": "https://www.example.com"}' # 自定义后缀 curl -X POST https://w.fugui.us/api/shorten \ -H "Content-Type: application/json" \ -d '{"url": "https://www.example.com", "slug": "my.link"}' # 关联到用户(需先登录获取 token) curl -X POST https://w.fugui.us/api/shorten \ -H "Content-Type: application/json" \ -H "Authorization: Bearer <token>" \ -d '{"url": "https://www.example.com"}'
{
"short_url": "https://w.fugui.us/my.link",
"original_url": "https://www.example.com/",
"slug": "my.link"
}
登录获取 token,用于后续 API 鉴权。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| username | string | 必填 | 用户名 |
| password | string | 必填 | 密码 |
curl -X POST https://w.fugui.us/api/auth/login \
-H "Content-Type: application/json" \
-d '{"username": "xxx", "password": "xxx"}'
{
"token": "eyJhbGciOiJIUzI1NiIs...",
"username": "xxx"
}
注册新用户。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| username | string | 必填 | 2-20位,支持字母数字中文下划线 |
| password | string | 必填 | 至少4位 |
curl -X POST https://w.fugui.us/api/auth/register \
-H "Content-Type: application/json" \
-d '{"username": "xxx", "password": "xxx"}'
{"message": "注册成功"}
获取当前用户的短链接列表。需 Authorization 头
| 参数 | 类型 | 说明 |
|---|---|---|
| page | number | 页码,默认 1 |
| limit | number | 每页条数,默认 20,最大 100 |
| q | string | 搜索关键词(匹配后缀或目标网址) |
curl "https://w.fugui.us/api/links?page=1&limit=20" \ -H "Authorization: Bearer <token>"
{
"links": [
{
"slug": "my.link",
"original_url": "https://www.example.com/",
"clicks": 42,
"created_at": "2026-06-29 19:11:50"
}
],
"total": 1,
"page": 1,
"total_pages": 1
}
删除指定的短链接。需 Authorization 头
curl -X DELETE "https://w.fugui.us/api/links/my.link" \ -H "Authorization: Bearer <token>"
{"message": "已删除"}
全站统计(公开)。
curl https://w.fugui.us/api/stats
{
"total_links": 100,
"total_clicks": 5000,
"active_links": 30
}
当前用户的统计。需 Authorization 头
curl https://w.fugui.us/api/user/stats \ -H "Authorization: Bearer <token>"
{
"total_links": 5,
"total_clicks": 120,
"active_links": 3
}