API文档

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

概述

缩短网址

POST /api/v1/shorten

请求参数:

参数必填描述
original_url✅要缩短的原始网址
custom_code❌自定义短代码(如果省略则自动生成)
expire_duration❌有效期:24h, 48h, 1week, 1month

请求示例:

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"
  }
}

错误响应:

{
  "status": "error",
  "message": "This short code is already in use."
}

获取API信息

GET /api/v1/shorten

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