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}
錯誤碼
| 狀態碼 | 意義 |
|---|---|
| 400 | 請求格式錯誤(缺 url、url 格式不對) |
| 401 | 缺 / 錯 API key |
| 403 | API key 已被撤銷 / 額度用完 |
| 404 | 短網址不存在 |
| 409 | 短碼已被使用 |
| 429 | 速率限制(預設 60 req/min) |
| 500 | 伺服器錯誤 |
可以在後台設定 webhook URL,當短網址被建立 / 達到點擊里程碑時主動推播。
SDK
- Node.js:
npm install @8la/api-client(coming soon) - Python:
pip install 8la-api(coming soon) - PHP: 直接用 cURL 即可
聯絡
API 相關問題:api@0800945.com