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,localhostand IP allowed without a dot, other hosts must include at least one dot, IDN → punycode (viaidna).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36d90fb44ac1a642390eeabc5ae249344f3e03ed07a2b6e69853422d282c618c
|
|
| MD5 |
3324e839a1b61463729548d010a9dfeb
|
|
| BLAKE2b-256 |
1c25a5e809095233e4e61febe71d4a8ae0fd18c039d36850978f575babc7d4d6
|
Provenance
The following attestation bundles were made for pthbz-1.0.4.tar.gz:
Publisher:
release.yml on pthbz/pthbz-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pthbz-1.0.4.tar.gz -
Subject digest:
36d90fb44ac1a642390eeabc5ae249344f3e03ed07a2b6e69853422d282c618c - Sigstore transparency entry: 391228356
- Sigstore integration time:
-
Permalink:
pthbz/pthbz-python@0c90985fc70c449c32bce732bd615f480e3a43ca -
Branch / Tag:
refs/tags/v1.0.4 - Owner: https://github.com/pthbz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0c90985fc70c449c32bce732bd615f480e3a43ca -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9bf2453654edf73c1b12d6176c5319b973515dd80aefa6dc42815a1decf1e6d7
|
|
| MD5 |
af5c39ecf4f0db906ec9d8ebe8cce749
|
|
| BLAKE2b-256 |
734fd854eabb9f87fb25e9bdb43b7412a98309d4bf1bea1d15912b082d470691
|
Provenance
The following attestation bundles were made for pthbz-1.0.4-py3-none-any.whl:
Publisher:
release.yml on pthbz/pthbz-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pthbz-1.0.4-py3-none-any.whl -
Subject digest:
9bf2453654edf73c1b12d6176c5319b973515dd80aefa6dc42815a1decf1e6d7 - Sigstore transparency entry: 391228388
- Sigstore integration time:
-
Permalink:
pthbz/pthbz-python@0c90985fc70c449c32bce732bd615f480e3a43ca -
Branch / Tag:
refs/tags/v1.0.4 - Owner: https://github.com/pthbz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0c90985fc70c449c32bce732bd615f480e3a43ca -
Trigger Event:
push
-
Statement type: