Skip to main content

Python SDK for the T.LY URL Shortener API.

Project description

tly-url-shortener-api

Python SDK for the T.LY URL Shortener API.

Features

  • Typed Python client with sensible defaults.
  • Built-in bearer auth handling.
  • Binary or JSON responses for QR endpoints.
  • CLI entry point (tly) for quick scripts and terminal usage.
  • PyPI-ready packaging (pyproject.toml) and tests.

Installation

pip install tly-url-shortener-api

For local development:

python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

Quick Start

from tly_url_shortener import TlyClient

client = TlyClient(api_token="YOUR_TLY_API_TOKEN")

created = client.create_short_link(
    long_url="https://example.com/landing-page",
    description="Campaign link",
    public_stats=True,
)
print(created["short_url"])

expanded = client.expand_short_link(short_url=created["short_url"])
print(expanded["long_url"])

Endpoint Coverage

OneLink Stats Management

  • get_onelink_stats
  • delete_onelink_stats

ShortLink Management

  • create_short_link
  • get_short_link
  • update_short_link
  • delete_short_link
  • expand_short_link
  • list_short_links
  • bulk_shorten_links
  • bulk_update_links

ShortLink Stats

  • get_link_stats

UTM Preset Management

  • create_utm_preset
  • list_utm_presets
  • get_utm_preset
  • update_utm_preset
  • delete_utm_preset

OneLink Management

  • list_onelinks

Pixel Management

  • create_pixel
  • list_pixels
  • get_pixel
  • update_pixel
  • delete_pixel

QR Code Management

  • get_qr_code
  • update_qr_code

Tag Management

  • list_tags
  • create_tag
  • get_tag
  • update_tag
  • delete_tag

CLI Usage

Set token once:

export TLY_API_TOKEN="YOUR_TLY_API_TOKEN"

Create short link:

tly shorten --long-url "https://example.com"

Expand short link:

tly expand --short-url "https://t.ly/abc123"

Call any client method:

tly call create_tag --data '{"tag":"fall2026"}'

Retrieve QR image:

tly qr --short-url "https://t.ly/abc123" --out qr.png

Development

pytest
ruff check .
python -m build
twine check dist/*

Publish to PyPI

python -m build
twine check dist/*
twine upload dist/*

If you use trusted publishing in GitHub Actions, replace the final twine upload with your CI release workflow.

License

MIT

Project details


Download files

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

Source Distribution

tly_url_shortener_api-0.1.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

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

tly_url_shortener_api-0.1.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file tly_url_shortener_api-0.1.0.tar.gz.

File metadata

  • Download URL: tly_url_shortener_api-0.1.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for tly_url_shortener_api-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dfa072d1dfb724f933208885601335bbd71a499829a1f421d7bcfb88828d4bcb
MD5 504c85ffc3dd1de95269a40ad7cf25ee
BLAKE2b-256 7772978e7baf53e563a62ec1a7d6161be5449a927c171c9b08ddaa0ac78302b5

See more details on using hashes here.

File details

Details for the file tly_url_shortener_api-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tly_url_shortener_api-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 27e39755afc7447dcf471f6960472614cb4f2a9e4a21ca0733899e276a1f3fa6
MD5 6be9961a8c3e9fdc5c701e3095f6212f
BLAKE2b-256 2c6fc3683ba5bdd25ccc4c68a87ab0c5f21ffb1ebe4ffc0997de0ee15f49dde0

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