API 介接文件

最後更新:2026/08/05

8la.tw 短網址 API

Business 方案(含以上)解鎖。請先到後台「API Keys」申請一組 API key。

認證

所有 API 請求需要帶 Authorization: Bearer <API_KEY> header。

端點

建立短網址

POST /api/v1/shorten
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY

{
  "url": "https://example.com/very-long-url",
  "code": "my-link",
  "title": "我的活動連結",
  "expires_at": "2026-12-31T23:59:59+08:00"
}

Response 200:

{
  "ok": true,
  "data": {
    "id": 12345,
    "code": "my-link",
    "short_url": "https://8la.tw/my-link",
    "target_url": "https://example.com/very-long-url",
    "expires_at": "2026-12-31T23:59:59+08:00"
  }
}

取得短網址資訊

GET /api/v1/shorten/{code}
Authorization: Bearer YOUR_API_KEY

Response 200:

{
  "ok": true,
  "data": {
    "code": "my-link",
    "target_url": "https://example.com/very-long-url",
    "title": "我的活動連結",
    "click_count": 1234,
    "created_at": "2026-08-05T10:00:00+08:00"
  }
}

取得分析

GET /api/v1/shorten/{code}/stats?range=7d
Authorization: Bearer YOUR_API_KEY

Response 200:

{
  "ok": true,
  "data": {
    "range": "7d",
    "clicks": 1234,
    "unique_clicks": 856,
    "by_day": [
      {"date": "2026-07-30", "clicks": 100},
      ...
    ],
    "by_country": [
      {"country": "TW", "clicks": 800},
      ...
    ]
  }
}

刪除短網址

DELETE /api/v1/shorten/{code}
Authorization: Bearer YOUR_API_KEY

Response 200:

{"ok": true}

錯誤碼

速率限制

Webhook

狀態碼意義
400請求格式錯誤(缺 url、url 格式不對)
401缺 / 錯 API key
403API key 已被撤銷 / 額度用完
404短網址不存在
409短碼已被使用
429速率限制(預設 60 req/min)
500伺服器錯誤

可以在後台設定 webhook URL,當短網址被建立 / 達到點擊里程碑時主動推播。

SDK

聯絡

API 相關問題:api@0800945.com