X.gd Developers
我們提供可從外部應用程式呼叫的URL縮短API。使用API需要API金鑰。
URL短連結API
Shorten API v1.0
GET https://xgd.io/V1/shorten
請求
| * | Parameter | Type | Format | Description | Example |
|---|---|---|---|---|---|
| * | url | String | http(s):// | 要縮短的URL | https://example.com |
| shortid | String | [0-9a-zA-Z_]{6,15} | 自定义短鏈接。省略時將随机分配 | example | |
| analytics | String | true / false | 啟用访问分析。省略時默認啟用 | true | |
| filterbots | String | true / false | 啟用分析時的机器人過滤。省略時默認關闭 | false | |
| * | key | String | [0-9a-f]{32} | 已發行的API金鑰 | 0af50e06255c7004f9ad71338f5ad56e |
請求範例(URL)
https://xgd.io/V1/shorten?url=https://example.com&key={Your API Key}請求範例(cURL)
curl -X GET 'https://xgd.io/V1/shorten?url=https://example.com&key={Your API Key}'回應(成功)
| * | Parameter | Type | Format | Description | Example |
|---|---|---|---|---|---|
| * | status | Number | 200 | 狀態碼 | 200 |
| * | shorturl | String | https://x.gd/[0-9a-zA-Z_]+ | 短連結 | https://x.gd/example |
| * | analytics | Boolean | true / false | 存取分析 | true |
| * | filterbots | Boolean | true / false | 機器人過濾 | false |
| * | originalurl | String | http(s):// | 原始URL | https://example.com |
回應範例
status: 200
content-type: application/json
{
"status": 200,
"shorturl": "https://x.gd/example",
"analytics": true,
"filterbots": false,
"originalurl": "https://example.com/"
}回應(失敗)
| * | Parameter | Type | Format | Description | Example |
|---|---|---|---|---|---|
| * | status | Number | 400 / 401 / 403 / 409 / 429 / 500 / 503 | 狀態碼 | 429 |
| * | message | String | - | 錯誤訊息 | Too many requests. |
回應範例
status: 200
content-type: application/json
{
"status": 429,
"message": "Too many requests."
}狀態碼
| Status | Description |
|---|---|
| 200 | 响應正常。 |
| 400 | 請求發生错误。消息中包含详细信息。 |
| 401 | 權杖無效。請檢查API金鑰。 |
| 403 | 暫時或永久不可用。 |
| 409 | 無法按請求条件發行短鏈接。消息中包含详细信息。 |
| 429 | 已达到API使用限制。請等待限制解除后重试。 |
| 500 | 暫時發生系統错误。請稍后再试。 |
| 503 | 服務暫時不可用。請稍后再试。 |
API金鑰
我们会向您输入的邮箱發送用于發行API密钥的URL。
發送后請在24小時内完成手续。