Skip to main content

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).

Metadata

Release files for pthbz 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pthbz 1.0.4
File Size Uploaded
pthbz-1.0.4.tar.gz 10.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pthbz 1.0.4
File Interpreter ABI Platform
pthbz-1.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 21.4 kB

Release files / pthbz-1.0.4.tar.gz

Download URL pthbz-1.0.4.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
36d90fb44ac1a642390eeabc5ae249344f3e03ed07a2b6e69853422d282c618c
BLAKE2b-256 checksum
How to use checksums
1c25a5e809095233e4e61febe71d4a8ae0fd18c039d36850978f575babc7d4d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 13, 2025.

Transparency log

Release files / pthbz-1.0.4-py3-none-any.whl

Download URL pthbz-1.0.4-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9bf2453654edf73c1b12d6176c5319b973515dd80aefa6dc42815a1decf1e6d7
BLAKE2b-256 checksum
How to use checksums
734fd854eabb9f87fb25e9bdb43b7412a98309d4bf1bea1d15912b082d470691
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 13, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.4 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page