Skip to main content

Python SDK and CLI for creating short links with permanent 301 redirects, interstitial (anti-bot) redirects, and on-demand QR codes via pth.bz.

Project description

pthbz — Python SDK for pth.bz

Official Python library for the pth.bz short link service.

  • 301 redirect — permanent redirect for SEO-safe migrations and clean sharing.
  • Interstitial (anti‑bot) — an intermediate step to filter bots and hide the referrer.
  • QR PNG — on-demand QR code images.
  • Sync and Async clients with server-aligned URL validation.

Author: Avel Kox
License: MIT

Installation

pip install pthbz

Quick start

from pthbz import PthBzClient

client = PthBzClient(base_url="https://pth.bz")
res = client.shorten("https://example.com/landing?utm_source=newsletter")
print(res.short_url_301)   # https://pth.bz/AbC1234
print(res.short_url_js)    # https://pth.bz/i/AbC1234   (interstitial anti-bot)
print(res.qr_301_png_url)  # https://pth.bz/?qr=AbC1234
print(res.qr_js_png_url)   # https://pth.bz/?qi=AbC1234
client.close()

Async variant:

import asyncio
from pthbz import AsyncPthBzClient

async def main():
    async with AsyncPthBzClient(base_url="https://pth.bz") as client:
        res = await client.shorten("https://example.com")
        print(res.short_url_301)

asyncio.run(main())

CLI:

# 1) Create a short link
pthbz shorten https://example.com

# 2) Build a QR PNG URL from a short link
pthbz --base https://pth.bz qr --url https://pth.bz/AbC1234 --px 640

# 3) Or with CODE directly
pthbz --base https://pth.bz qr --code AbC1234 --interstitial

Notes

  • Local URL validation mirrors server rules: only http/https, userinfo forbidden, localhost and IP allowed without a dot, other hosts must include at least one dot, IDN → punycode (via idna).

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

pthbz-1.0.4.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

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

pthbz-1.0.4-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file pthbz-1.0.4.tar.gz.

File metadata

  • Download URL: pthbz-1.0.4.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pthbz-1.0.4.tar.gz
Algorithm Hash digest
SHA256 36d90fb44ac1a642390eeabc5ae249344f3e03ed07a2b6e69853422d282c618c
MD5 3324e839a1b61463729548d010a9dfeb
BLAKE2b-256 1c25a5e809095233e4e61febe71d4a8ae0fd18c039d36850978f575babc7d4d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pthbz-1.0.4.tar.gz:

Publisher: release.yml on pthbz/pthbz-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pthbz-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: pthbz-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pthbz-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9bf2453654edf73c1b12d6176c5319b973515dd80aefa6dc42815a1decf1e6d7
MD5 af5c39ecf4f0db906ec9d8ebe8cce749
BLAKE2b-256 734fd854eabb9f87fb25e9bdb43b7412a98309d4bf1bea1d15912b082d470691

See more details on using hashes here.

Provenance

The following attestation bundles were made for pthbz-1.0.4-py3-none-any.whl:

Publisher: release.yml on pthbz/pthbz-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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