Skip to main content

Clishortener

A lightweight, feature-rich CLI tool to shorten links using 12+ services—with zero configuration required.

PyPI version Python Version PyPI version PyPI Total Downloads License: MIT Tested for Termux

Asciinema Showcase

Key Features

  • 🚀 Lightweight & Fast: Works right out of the terminal, all dependencies besides requests are 100% optional.
  • 🔌 12+ Services Pre-configured: TinyURL, Bitly, Short.io, CleanURI, and more.
  • 🛠️ Custom & Self-Hosted: Full support for custom domains and YOURLS instances.
  • 🎨 Colored Output: Optional colorful terminal UI using rich.
  • 🛡️ Privacy Focused: Automatically strips common tracking urls.
  • Pipeline Friendly: Pass raw output directly to stdout or other scripts using bare/silent flags.
  • 🕹 Plug & Play: Start shortening immediately after installation, no setup required.

Requirements 📦

Package Type Purpose
requests Required Handles HTTP calls to shortening APIs
PySocks Optional Allows more types of proxying (SOCKS)
rich Optional Adds terminal colors, menus, and visual styling
argcomplete Optional Provides shell auto-completion for cshorten
keyring / keyrings.alt Optional Allows saving API keys securely for automatic authentication

[!NOTE] If you are using Termux or a terminal that doesn't support keyring use keyrings.alt instead. (pip install keyrings.alt)

Installation Options 📥

Via PyPI (recommended)

pip install clishortener[rich]

This will also install rich. To install necessary files only, use pip install clishortener

From source via git

git clone https://github.com/Ruizennis/Clishortener
cd Clishortener
pip install .

Installing all optional packages

pip install clishortener[full]
activate-global-python-argcomplete # This will setup argcomplete globally

Quick Start

Shorten your first url ✂️

cshorten shorten https://example.com

Set your preferred service as the default 🔧

# Usage: cshorten service default <servicename>
cshorten service default dagd

List all available services 📜

cshorten service list

Pipe data to create a pipeline 🔗

echo "https://example.com" | cshorten shorten >> links.txt

[!IMPORTANT] The Default Shortening Service Is Tinyurl (No Api Key Is Required)


Supported Services 🌐

Service Service Identifier API Key Required? Privacy Policy & Terms
TinyURL tinyurl-noauth / tinyurl-auth Optional Privacy Policy · Terms of Service
is.gd isgd No Terms & Privacy Policy
v.gd vgd No Terms & Privacy Policy
da.gd dagd No Source & Licensing
clck.ru clckru No Privacy Policy · Terms of Use
ulvis.net ulvis No Service Terms
CleanURI cleanuri No Privacy Policy · Terms of Service
Bitly bitly Yes Privacy Policy · Terms of Service
Cuttly cuttly Yes Privacy Policy · Terms of Service
Short.io shortio Yes Privacy Policy · Terms of Service
Rebrandly rebrandly Yes Privacy Policy · Terms & Conditions
YOURLS yourls Optional Self-Hosted (Subject to instance host policies)
Custom Service custom Optional User Defined (Subject to custom endpoint policies)

[!IMPORTANT]
Privacy & Service Usage: Requests routed through third-party shorteners are subject to each provider's independent privacy and logging practices. Self-hosted options (YOURLS, custom) give you total control over data logging.

Disclaimer: These legal policy links are provided for convenience only and do not constitute legal advice. links may change over time and as a solo developer, I can't guarantee every link stays up to date.


Global Flags

Flag Long Flag Purpose
-b --bare Remove rich formatting and write to stdout without formatting
-h --help Shows help menu
-S --silent Silences all logging messages

Shortening Flags

Flag Long Flag Purpose
-s --service Allows specifying service for a command
-k --key Allows setting an api key for services that require it
--no-strip Disables automatic tracker parameter removal

Additional Commands >_

Category Command Description Usage Example
Service default Set default shortening service cshorten service default <service>
Service list List all available services cshorten service list
Security proxy edit Edit proxy configuration cshorten security proxy edit
Security proxy show Show current proxy configuration cshorten security proxy show
Security proxy reset Remove proxy configuration cshorten security proxy reset
Security keys set Add an api key for a service cshorten security keys set bitly
Security keys clear Clears ALL set api keys or just for specified service cshorten security keys clear bitly

Notes & Usage Tips 💡

  • Self-Hosted & Custom Domains: Use the full URL and set the --domain flag when using yourls or custom providers.
  • API Keys: API keys can be provided via the -k / --key flag for services requiring authentication.
  • Service Identifiers: When specifying or setting a default service, always use the service's Identifier (e.g., dagd, tinyurl-auth) rather than its display name or URL.
⚙️ Advanced Configuration
  • Custom / YOURLS: Requires full URL endpoint and the --domain flag.
  • Custom Headers: Sent in key: value format.
  • Config Parameters: auth_param specifies key requirements; url_param sets the request payload variable (defaults to "url").
  • NO COLOR: We proudly support the NO_COLOR initiative. Add NO_COLOR=1 to os.environ to disable output styling
  • FORCE_COLOR: Add FORCE_COLOR=1 to your env variables to force color for use in asciinema or vhs recordings.
  • Pipes: We support piping data, when piping bare is automatically appiled ensuring no color and only url is sent allowing for more complex pipelines.
  • Advanced Proxy Networks: SOCKS proxies and TOR routing is fully supported if you install the required add-on for requests, simply add your socks proxy URL to the proxy list.

[!WARNING] Using SOCKS proxies requires pysocks, install PySocks with pip install "requests[socks]"


Adding Additional Services Examples 🔨

[!IMPORTANT] Additional services can be added By editing services.json (/.config/clishortener/usr/usrconfig.json) and adding new entries.

[!NOTE] Httpbin is not a legitimate URL shortening service and is instead intended for development purposes. (e.g seeing public IP address to confirm requests are proxied.)

Adding httpbin as a service example

"httpbin": {
    "serviceurl": "https://httpbin.org/post",
    "method": "POST",
    "auth_header": "apikey",
    "url_param": "destination",
    "params": {
        "destination": ""
    }
}

Testing httpbin example

cshorten shorten https://example.com -s httpbin -k ApiKey

No Key Service JSON Example 🔓

"0x0": {
        "serviceurl": "https://0x0.st",
        "method": "POST",
        "multifile": true,
        "url_param": "shorten",
        "json_body": false,
        "params": {}
     },

Testing 0x0 example

cshorten shorten https://example.com -s 0x0

[!WARNING] As of 2026-08-01 file hosting on the public 0x0.st instance is temporarily paused with no ETA for its return, self hosting is recommended. Self-host The Null Pointer (0x0) from The Official Git Repository.

Authenticated API JSON Example 🔐

"shortio": {
    "serviceurl": "https://api.short.io/links/public",
    "auth_header": "authorization",
    "url_param": "originalURL",
    "method": "POST",
    "json_key": "shortURL",
    "json_body": true,
    "params": {}
}

Planned Features 📌

  • Saving api keys with Keyring & automatically loading saved api keys
  • Saving links created to a file (Off by default)

Additional Links & Credits 🔗

Credits to Pyshorteners made by ellisonleao for inspiring this tool


License

This project is licensed under the MIT license, see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clishortener-0.2.2.tar.gz (17.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clishortener-0.2.2-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file clishortener-0.2.2.tar.gz.

File metadata

  • Download URL: clishortener-0.2.2.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for clishortener-0.2.2.tar.gz
Algorithm Hash digest
SHA256 8fb22ffd01900271cdebd819ffcfdeee3e6057c349ecd9a8ef48f02963b081e6
MD5 17f277f95d9d11416f252691d469c2b9
BLAKE2b-256 a5f2607c74086fcbdb4797a61642a466f7c2c9777640e2cf3b58f482b23436e0

See more details on using hashes here.

File details

Details for the file clishortener-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: clishortener-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for clishortener-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 05c528b6e9b904325d0bf8141a7ba5a3fc06c137207e5c3e22c009e87e0ad765
MD5 a21a5a5dac8e668278263e869f38eb2f
BLAKE2b-256 b558bb890f610b5ed562e09522300cdf1b7916c617571b24af87d08ee6f7f324

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page