🤖 Ai回答: 短链接(URL Shortener)API 允许你将长网址转换为短链接,方便分享和跟踪点击数据。以下是一些常见的短链接 API 及其使用方法:
1、免费公共短链接 API
Bit.ly
API 文档: [https://dev.bitly.com/](https://dev.bitly.com/)
特点:
提供免费的短链接生成(需注册账号)。
支持自定义短链后缀(需付费计划)。
提供点击数据分析。
示例请求:
bash
curl X POST H Authorization: Bearer YOUR_ACCESS_TOKEN \
H ContentType: application/json \
d '{long_url: https://example.com/very/long/url}' \
https://apissl.bitly.com/v4/shorten
Rebrandly (自定义域名短链)
API 文档: [https://developers.rebrandly.com/](https://developers.rebrandly.com/)
特点:
支持自定义域名(如 `yourdomain.co/xyz`)。
提供免费额度(需注册)。
示例请求:
bash
curl X POST H apikey: YOUR_API_KEY \
H ContentType: application/json \
d '{destination: https://example.com/very/long/url}' \
https://api.rebrandly.com/v1/links
2、自建短链接服务 API
如果你想完全控制数据,可以自建短链接服务:
使用开源项目
Shlink: [https://shlink.io/](https://shlink.io/)
支持 Docker 部署,提供 REST API 和统计分析。
YOURLS: [https://yourls.org/](https://yourls.org/)
PHP 编写,支持插件扩展。