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小时内完成手续。