API文档
使用 ZIPN API 以编程方式缩短 URL。
概述
访客每24小时可免费创建最多3个链接。
- Base URL:
https://zipn.app/api/v1/shorten - 格式: JSON
- 认证: 可选(无密钥时为临时链接,使用 API 密钥时为个人代码链接)
认证(API 密钥)
登录后在个人资料中创建 API 密钥,并放在请求头中发送。链接将在你的个人代码下创建且永不过期,你可以在控制台中编辑并查看统计。
Authorization: Bearer sk_short_...- 密钥仅在创建时显示一次。如果丢失,请撤销并重新创建。
- 每个账户最多 5 个密钥,每个密钥每分钟 30 次、每天 1,000 次请求。超出时返回 429 及 Retry-After 头。
- 如果密钥错误或已撤销,将返回 401,而不会改为创建临时链接。
缩短网址
POST /api/v1/shorten
请求参数:
| 参数 | 必填 | 描述 |
|---|---|---|
original_url | ✅ | 要缩短的原始网址 |
custom_code | ❌ | 自定义短代码(如果省略则自动生成) |
expire_duration | ❌ | 有效期:24h, 48h, 1week, 1month |
code_id | ❌ | 使用 API 密钥时:要使用的个人代码 ID(默认使用主代码)。传入 temp 会创建临时链接,并在控制台中管理。 |
请求示例:
curl -X POST https://zipn.app/api/v1/shorten \
-H "Content-Type: application/json" \
-d '{
"original_url": "https://example.com/very-long-url",
"custom_code": "example",
"expire_duration": "1week"
}'成功响应(201):
{
"status": "success",
"message": "URL shortened successfully.",
"data": {
"short_url": "https://zipn.app/example/",
"original_url": "https://example.com/very-long-url",
"code": "example",
"expiration_date": "2026-04-21T10:00:00.000Z"
}
}使用 API 密钥请求:
curl -X POST https://zipn.app/api/v1/shorten \
-H "Authorization: Bearer sk_short_..." \
-H "Content-Type: application/json" \
-d '{
"original_url": "https://example.com/very-long-url",
"custom_code": "example"
}'使用 API 密钥的成功响应 (201):
{
"status": "success",
"message": "URL shortened successfully.",
"data": {
"short_url": "https://zipn.app/mycode/example/",
"original_url": "https://example.com/very-long-url",
"code": "example",
"expiration_date": "2126-03-28T10:00:00.000Z",
"username": "mycode",
"user_code_id": 12,
"is_temp": false
}
}错误响应:
{
"status": "error",
"message": "This short code is already in use."
}获取API信息
GET /api/v1/shorten
返回端点信息和可用参数。