urlink
🔗 Python SDK for Urlink URL Shortener - Shorten URLs with ease!
Installation
pip install urlink
Get an API Key
All requests require an API key. Use the built-in developer portal:
- Go to url.ashin.me to access the portal.
- Create an account or log in.
- Click "API Key" button. this will take you to the developer page.
- Then click "create new key button" to generate your API key.
Quick Start
Configure API Access
import urlink
urlink.configure(api_key="YOUR-API-KEY")
Simple API (Recommended for beginners)
import urlink
# Configure once per process
urlink.configure(api_key="YOUR-API-KEY")
# Set your long URL
urlink.input = "https://example.com/very/long/url/that/needs/shortening"
# Get the shortened URL
print(urlink.output)
# Output: https://639.qzz.io/abc123
With Custom Options
import urlink
# Set the URL to shorten
urlink.input = "https://example.com/my-awesome-page"
# Optional: Set a custom domain
urlink.domain = "mysite.co"
# Optional: Set a custom ending/slug
urlink.ending = "awesome"
# Get the result
print(urlink.output)
# Output: https://mysite.co/awesome
One-liner Method
import urlink
# Configure if you haven't already
urlink.configure(api_key="YOUR-API-KEY")
# Shorten in one call
short_url = urlink.shorten("https://example.com/long-url")
print(short_url)
# With custom ending
short_url = urlink.shorten(
"https://example.com/long-url",
ending="my-custom-link"
)
print(short_url)
Advanced Usage
Using the Client Class
from urlink import UrlinkClient
# Create a client instance
client = UrlinkClient(api_key="YOUR-API-KEY")
# Shorten a URL
result = client.shorten("https://example.com/long-url")
print(result['short']) # https://639.qzz.io/abc123
print(result['code']) # abc123
# With custom code
result = client.shorten(
url="https://example.com/product",
code="my-product"
)
# With custom domain
result = client.shorten(
url="https://example.com/page",
domain="mybrand.co",
code="landing"
)
Check Code Availability
from urlink import UrlinkClient
client = UrlinkClient(api_key="YOUR-API-KEY")
# Check if a code is available
if client.check_availability("my-link"):
print("Code is available!")
result = client.shorten(
"https://example.com/page",
code="my-link"
)
else:
print("Code is taken, try another one")
Bulk URL Shortening
from urlink import UrlinkClient
client = UrlinkClient(api_key="YOUR-API-KEY")
urls = [
"https://example.com/page1",
"https://example.com/page2",
"https://example.com/page3",
]
results = client.bulk_shorten(urls)
for result in results:
if result['success']:
print(f"{result['original']} -> {result['short']}")
else:
print(f"Failed: {result['original']} - {result['error']}")
Configuration
import urlink
# Configure with API key (required)
urlink.configure(
api_key="your-api-key",
base_url="https://639.qzz.io" # optional, defaults to https://639.qzz.io
)
# Self-hosted example
urlink.configure(
api_key="your-self-hosted-key",
base_url="https://your-domain.com"
)
Error Handling
from urlink import UrlinkClient
from urlink.client import (
UrlinkError,
UrlinkAPIError,
UrlinkValidationError,
UrlinkConnectionError
)
client = UrlinkClient(api_key="YOUR-API-KEY")
try:
result = client.shorten("https://example.com", code="taken-code")
except UrlinkValidationError as e:
print(f"Invalid input: {e}")
except UrlinkAPIError as e:
print(f"API error: {e}")
print(f"Status code: {e.status_code}")
except UrlinkConnectionError as e:
print(f"Connection failed: {e}")
except UrlinkError as e:
print(f"General error: {e}")
API Reference
Module-Level API
| Property/Method | Description |
|---|---|
urlink.input |
Set the URL to shorten |
urlink.domain |
Set custom domain (optional) |
urlink.ending |
Set custom slug/code (optional) |
urlink.output |
Get the shortened URL |
urlink.shorten(url, domain, ending) |
Shortcut method |
urlink.check(code, domain) |
Check code availability |
urlink.reset() |
Reset all settings |
urlink.configure(api_key, base_url) |
Configure the client |
UrlinkClient Methods
| Method | Description |
|---|---|
shorten(url, domain, code, user_id) |
Shorten a URL |
check_availability(code, domain) |
Check if code is available |
bulk_shorten(urls, domain) |
Shorten multiple URLs |
Response Format
{
"code": "abc123", # The short code
"original": "https://...", # Original URL
"short": "https://...", # Full shortened URL
"domain": "639.qzz.io", # Domain used
"timestamp": 1700000000000 # Creation timestamp
}
Requirements
- Python 3.7+
- No external dependencies (uses only Python standard library)
License
MIT License - see LICENSE for details.
Links
Metadata
Release files for urlink 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| urlink-1.0.2.tar.gz | 12.1 kB | Without provenance | Details for urlink-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| urlink-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for urlink-1.0.2-py3-none-any.whl |
Total release size: 22.8 kB
Release files / urlink-1.0.2.tar.gz
| Download URL | urlink-1.0.2.tar.gz |
|---|---|
| Size | 12.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fffeccf30fea1f0f0e3c78cb851530d7f20e6c1d70032054e44887d70fe5560f
|
|
BLAKE2b-256 checksum How to use checksums |
533ef3e60a5317befa1b0ff6b1256642f6e6515a983cc00323d12a79205b7e7f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Release files / urlink-1.0.2-py3-none-any.whl
| Download URL | urlink-1.0.2-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4447f1454f6c57065ff68cf6358d0ed4ee60fd89313613e76b621372479b44ea
|
|
BLAKE2b-256 checksum How to use checksums |
e26173e35bf3ab6e972200c7b166d4ca018ce8db1a10b51eeae52045b75d9e6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Security for urlink 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.