shorturlx-cli is an official npm package that lets you create shortened URLs directly from your terminal without opening a browser.
Installation and first use
Install the CLI globally
Run the following command to install
shorturlx-cli globally on your machine:Get your API key
Sign in to your ShortURLx account and generate an API key from the API Key Management section of your dashboard.
An API key is required to use custom slugs. You can shorten URLs without one, but you will be subject to lower rate limits.
Options
| Option | Alias | Description |
|---|---|---|
--url | -u | URL to shorten (required) |
--custom | -c | Custom slug (optional, requires API key) |
--api-key | -k | API key (or use SHORTURL_API_KEY env var) |
--endpoint | -e | Custom API endpoint (defaults to www.shorturlx.xyz) |
--copy | -cp | Copy result to clipboard (defaults to true) |
--help | Show help |
API key configuration
You can provide your API key in two ways:- Flag: pass
--api-keyor-kwith each command - Environment variable: set
SHORTURL_API_KEYonce and omit the flag entirely
--api-key flag:
Examples
Basic usage:Custom slugs require a valid API key. If you omit
--api-key and SHORTURL_API_KEY is not set, the --custom flag will be ignored.