API文档

使用 ZIPN API 以编程方式缩短 URL。

概述

访客每24小时可免费创建最多3个链接。

认证(API 密钥)

登录后在个人资料中创建 API 密钥,并放在请求头中发送。链接将在你的个人代码下创建且永不过期,你可以在控制台中编辑并查看统计。

Authorization: Bearer sk_short_...

缩短网址

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

返回端点信息和可用参数。