资讯动态

Chhoto URL CLI完全指南:用命令行管理短链接的10个实用技巧

发布时间:2026/8/10 19:28:14 来源:尧图企业网站定制
Chhoto URL CLI完全指南用命令行管理短链接的10个实用技巧【免费下载链接】chhoto-urlA simple, blazingly fast, selfhosted URL shortener with no unnecessary features; written in Rust.项目地址: https://gitcode.com/gh_mirrors/ch/chhoto-urlChhoto URL是一款简单、极速且自托管的短链接工具采用Rust编写无冗余功能。本文将详细介绍如何通过命令行高效管理短链接从基础安装到高级操作助你轻松掌握10个实用技巧。1. 快速获取项目与基础配置首先通过以下命令克隆项目仓库git clone https://gitcode.com/gh_mirrors/ch/chhoto-url进入项目目录后可通过curl命令快速获取服务器版本和站点URL无需认证# 查看版本 curl http://localhost:4567/api/version # 查看站点URL curl http://localhost:4567/api/siteurl2. 生成安全的API密钥API密钥是CLI操作的核心凭证。在Linux系统中可通过以下命令生成高强度密钥tr -dc A-Za-z0-9 /dev/urandom | head -c 128将生成的密钥设置为环境变量CHHOTO_API_KEY确保后续操作权限。3. 一键创建短链接使用/api/new接口创建短链接支持自定义短码、过期时间和备注curl -X POST \ -H X-API-Key: YOUR_API_KEY \ -d { shortlink: my-link, longlink: https://example.com, expiry_delay: 86400, notes: 测试链接 } \ http://localhost:4567/api/new若省略shortlink系统将自动生成随机短码。4. 批量创建短链接通过发送JSON数组实现批量创建一次请求可添加多个链接curl -X POST \ -H X-API-Key: YOUR_API_KEY \ -d [ {shortlink: link1, longlink: https://url1.com}, {shortlink: link2, longlink: https://url2.com} ] \ http://localhost:4567/api/new5. 查看短链接详情使用/api/expand接口查询短链接的目标地址、访问量和过期时间curl -H X-API-Key: YOUR_API_KEY \ -d my-link http://localhost:4567/api/expand返回结果包含longurl原始链接、hits访问次数等关键信息。6. 分页获取所有链接通过/api/all接口配合分页参数高效管理大量短链接# 获取第1页每页10条 curl -H X-API-Key: YOUR_API_KEY \ http://localhost:4567/api/all?page_size10page_no1 # 按短码过滤 curl -H X-API-Key: YOUR_API_KEY \ http://localhost:4567/api/all?filtermy-link7. 编辑现有短链接使用/api/edit接口更新短链接的目标地址、过期时间或备注curl -X PUT \ -H X-API-Key: YOUR_API_KEY \ -d { shortlink: my-link, longlink: https://new-example.com, reset_hits: true } \ http://localhost:4567/api/edit8. 删除无用短链接通过/api/del/{shortlink}接口删除指定短链接curl -X DELETE \ -H X-API-Key: YOUR_API_KEY \ http://localhost:4567/api/del/my-link9. 使用Cookie认证替代API密钥若未设置API密钥可通过Cookie进行认证# 登录并保存Cookie curl -X POST -d your-password -c cookie.txt http://localhost:4567/api/login # 使用Cookie执行操作 curl -b cookie.txt http://localhost:4567/api/all10. 获取服务器配置信息通过/api/getconfig接口查看系统参数如允许大写字母、短码长度等curl -H X-API-Key: YOUR_API_KEY \ http://localhost:4567/api/getconfig注意事项API响应中shorturl与shortlink、longurl与longlink可能混用需注意字段一致性。公共模式下无需认证但存在安全风险建议生产环境启用密码保护。所有CLI操作细节可参考官方文档docs/CLI.md通过以上10个技巧你可以充分发挥Chhoto URL的CLI功能高效管理短链接。无论是个人使用还是团队协作命令行操作都能为你带来极速、灵活的体验 【免费下载链接】chhoto-urlA simple, blazingly fast, selfhosted URL shortener with no unnecessary features; written in Rust.项目地址: https://gitcode.com/gh_mirrors/ch/chhoto-url创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

读完文章,也想定制专属网站?

尧图设计师 24 小时内与您沟通定制方案

免费获取报价