API 文档

短链接 API

POST /api/shorten
创建短链接

请求体 (JSON):

{
  "url": "https://example.com/very-long-url",
  "custom_code": "my-link"    // 可选,自定义短码
}

响应:

{
  "short_code": "my-link",
  "short_url": "https://n.af/my-link",
  "target_url": "https://example.com/very-long-url"
}

示例:

curl -X POST https://n.af/api/shorten \
  -H "Content-Type: application/json" \
  -d '{"url": "https://github.com"}'
GET /api/stats/{short_code}
查询短链统计信息

响应:

{
  "short_code": "abc123",
  "short_url": "https://n.af/abc123",
  "target_url": "https://example.com",
  "clicks": 42,
  "created_at": 1712419200.0
}

示例:

curl https://n.af/api/stats/abc123
GET /{short_code}
访问短链 → 302 跳转到目标 URL

开发者工具

直接用浏览器或 curl 访问,返回纯文本结果。

GET /ip
返回你的公网 IP 地址
$ curl n.af/ip
203.0.113.45
GET /uuid
生成随机 UUID v4
$ curl n.af/uuid
550e8400-e29b-41d4-a716-446655440000
GET /ts
返回当前 Unix 时间戳
$ curl n.af/ts
1712419200
GET /ua
返回你的 User-Agent
$ curl n.af/ua
curl/8.5.0
GET /headers
返回你的请求头 (JSON)
$ curl n.af/headers
{"host": "n.af", "user-agent": "curl/8.5.0", ...}

使用限制

为防止滥用,以下限制生效: