TritLinks API 文件

TritLinks 提供公開的 RESTful API,讓你可以直接在自己的程式、腳本或服務中建立短網址。 免費使用、不需要 API Key、沒有請求次數限制。短網址將使用 fastgo.qufij.cc 網域產生。

總覽

此 API 僅提供單一功能:將一個原始網址縮短為 fastgo.qufij.cc 短連結。支援 GETPOST 兩種方式呼叫,回應格式一律為 JSON。

不需要驗證。 這是公開端點,任何人都可以直接呼叫,無需註冊或攜帶任何 API Key / Token。

Base URL

https://qufij.cc/apis/trit/api-v1/

建立短網址

GET POST /apis/trit/api-v1/

傳入一個 url 參數,回傳對應的短網址。GET 使用 query string,POST 使用 JSON body(也相容一般表單格式)。

# 直接在瀏覽器或 curl 呼叫
curl "https://qufij.cc/apis/trit/api-v1/?url=https://example.com/very-long-link"
curl -X POST https://qufij.cc/apis/trit/api-v1/ \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/very-long-link"}'

參數說明

參數類型必填說明
url string 必填 要縮短的完整原始網址,需包含 http://https://

GET 請求將 url 放在 query string;POST 請求放在 JSON body(或 application/x-www-form-urlencoded 表單欄位)中。

回應格式

成功 200

{
  "success": true,
  "shortUrl": "https://fastgo.qufij.cc/aB3xZ",
  "original": "https://example.com/very-long-link"
}

失敗 4xx / 5xx

{
  "success": false,
  "error": "網址格式不正確"
}

錯誤代碼

狀態碼說明
400缺少 url 參數,或網址格式不正確
405使用了 GET / POST 以外的 HTTP 方法
502連線後端服務失敗
500建立短網址時發生未預期錯誤

程式碼範例

JavaScript (fetch)

const res = await fetch("https://qufij.cc/apis/trit/api-v1/", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ url: "https://example.com/very-long-link" })
});
const data = await res.json();
console.log(data.shortUrl);

Python (requests)

import requests

res = requests.post(
    "https://qufij.cc/apis/trit/api-v1/",
    json={"url": "https://example.com/very-long-link"}
)
print(res.json()["shortUrl"])

PHP

$ch = curl_init("https://qufij.cc/apis/trit/api-v1/?url=" . urlencode("https://example.com/very-long-link"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = json_decode(curl_exec($ch), true);
echo $data['shortUrl'];