shorturlx-cli
v1.1.1
Published
Command-line tool for shortening URLs with the ShortURLX service
Readme
ShortURLX CLI
A command-line tool for shortening URLs using the ShortURLX service.
Installation
npm install -g shorturlx-cliUsage
shorturlx --url "https://example.com/very-long-url" --api-key "YOUR_API_KEY"Options
--url, -u: The URL to shorten (required)--custom, -c: Custom slug (optional)--api-key, -k: Your API key (can also be set via environment variable)--endpoint, -e: API endpoint (defaults to https://www.shorturlx.xyz/api/shorten)--copy, -cp: Copy shortened URL to clipboard (defaults to true)--help: Show help
API Key Configuration
You can provide your API key in two ways:
- Command line argument:
--api-keyor-k - Environment variable:
SHORTURL_API_KEY
Setting up the environment variable:
Windows:
setx SHORTURL_API_KEY "YOUR_API_KEY"macOS/Linux:
echo 'export SHORTURL_API_KEY="YOUR_API_KEY"' >> ~/.bash_profile
# or for zsh users:
echo 'export SHORTURL_API_KEY="YOUR_API_KEY"' >> ~/.zshrcUsing the environment variable allows you to avoid exposing your API key in command history or process listings.
Getting an API Key
To get an API key:
- Sign in to ShortURLX
- Click on the "API Keys" button in the navigation
- Create a new API key
- Copy and use it with the CLI
Examples
Basic usage:
shorturlx --url "https://example.com/very-long-url" --api-key "YOUR_API_KEY"With custom slug:
shorturlx --url "https://example.com/very-long-url" --custom "my-custom-slug" --api-key "YOUR_API_KEY"Using a different endpoint:
shorturlx --url "https://example.com/very-long-url" --endpoint "https://your-custom-instance.com/api/shorten"Features
- Shorten URLs with a simple command
- Support for custom slugs
- Automatic clipboard copying
- Colorized output
- API key authentication
License
MIT
