pthbz


Namepthbz JSON
Version 1.0.4 PyPI version JSON
download
home_pageNone
SummaryPython SDK and CLI for creating short links with permanent 301 redirects, interstitial (anti-bot) redirects, and on-demand QR codes via pth.bz.
upload_time2025-08-13 20:25:07
maintainerNone
docs_urlNone
authorAvel Kox
requires_python>=3.8
licenseNone
keywords url shortener link shortener short link short urls 301 redirect permanent redirect interstitial anti-bot referrer hiding privacy no tracking utm campaign tracking marketing links seo redirects qr qr code qr generator python sdk http client requests httpx asyncio cli tiny links branded links biolink social links pth.bz
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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

```bash
pip install pthbz
```

## Quick start

```python
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:

```python
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:

```bash
# 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`).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pthbz",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "url shortener, link shortener, short link, short urls, 301 redirect, permanent redirect, interstitial, anti-bot, referrer hiding, privacy, no tracking, utm, campaign tracking, marketing links, seo redirects, qr, qr code, qr generator, python sdk, http client, requests, httpx, asyncio, cli, tiny links, branded links, biolink, social links, pth.bz",
    "author": "Avel Kox",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/1c/25/a5e809095233e4e61febe71d4a8ae0fd18c039d36850978f575babc7d4d6/pthbz-1.0.4.tar.gz",
    "platform": null,
    "description": "# pthbz \u2014 Python SDK for pth.bz\n\nOfficial Python library for the **pth.bz** short link service.\n\n- **301 redirect** \u2014 permanent redirect for SEO-safe migrations and clean sharing.\n- **Interstitial (anti\u2011bot)** \u2014 an intermediate step to filter bots and hide the referrer.\n- **QR PNG** \u2014 on-demand QR code images.\n- **Sync and Async** clients with server-aligned URL validation.\n\nAuthor: **Avel Kox**  \nLicense: **MIT**\n\n## Installation\n\n```bash\npip install pthbz\n```\n\n## Quick start\n\n```python\nfrom pthbz import PthBzClient\n\nclient = PthBzClient(base_url=\"https://pth.bz\")\nres = client.shorten(\"https://example.com/landing?utm_source=newsletter\")\nprint(res.short_url_301)   # https://pth.bz/AbC1234\nprint(res.short_url_js)    # https://pth.bz/i/AbC1234   (interstitial anti-bot)\nprint(res.qr_301_png_url)  # https://pth.bz/?qr=AbC1234\nprint(res.qr_js_png_url)   # https://pth.bz/?qi=AbC1234\nclient.close()\n```\n\nAsync variant:\n\n```python\nimport asyncio\nfrom pthbz import AsyncPthBzClient\n\nasync def main():\n    async with AsyncPthBzClient(base_url=\"https://pth.bz\") as client:\n        res = await client.shorten(\"https://example.com\")\n        print(res.short_url_301)\n\nasyncio.run(main())\n```\n\nCLI:\n\n```bash\n# 1) Create a short link\npthbz shorten https://example.com\n\n# 2) Build a QR PNG URL from a short link\npthbz --base https://pth.bz qr --url https://pth.bz/AbC1234 --px 640\n\n# 3) Or with CODE directly\npthbz --base https://pth.bz qr --code AbC1234 --interstitial\n```\n\n## Notes\n\n- 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 \u2192 punycode (via `idna`).\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python SDK and CLI for creating short links with permanent 301 redirects, interstitial (anti-bot) redirects, and on-demand QR codes via pth.bz.",
    "version": "1.0.4",
    "project_urls": {
        "Documentation": "https://pth.bz/docs",
        "Homepage": "https://pth.bz/",
        "Issues": "https://github.com/pthbz/pthbz-python/issues",
        "Source": "https://github.com/pthbz/pthbz-python"
    },
    "split_keywords": [
        "url shortener",
        " link shortener",
        " short link",
        " short urls",
        " 301 redirect",
        " permanent redirect",
        " interstitial",
        " anti-bot",
        " referrer hiding",
        " privacy",
        " no tracking",
        " utm",
        " campaign tracking",
        " marketing links",
        " seo redirects",
        " qr",
        " qr code",
        " qr generator",
        " python sdk",
        " http client",
        " requests",
        " httpx",
        " asyncio",
        " cli",
        " tiny links",
        " branded links",
        " biolink",
        " social links",
        " pth.bz"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "734fd854eabb9f87fb25e9bdb43b7412a98309d4bf1bea1d15912b082d470691",
                "md5": "af5c39ecf4f0db906ec9d8ebe8cce749",
                "sha256": "9bf2453654edf73c1b12d6176c5319b973515dd80aefa6dc42815a1decf1e6d7"
            },
            "downloads": -1,
            "filename": "pthbz-1.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "af5c39ecf4f0db906ec9d8ebe8cce749",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 10967,
            "upload_time": "2025-08-13T20:25:05",
            "upload_time_iso_8601": "2025-08-13T20:25:05.819705Z",
            "url": "https://files.pythonhosted.org/packages/73/4f/d854eabb9f87fb25e9bdb43b7412a98309d4bf1bea1d15912b082d470691/pthbz-1.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "1c25a5e809095233e4e61febe71d4a8ae0fd18c039d36850978f575babc7d4d6",
                "md5": "3324e839a1b61463729548d010a9dfeb",
                "sha256": "36d90fb44ac1a642390eeabc5ae249344f3e03ed07a2b6e69853422d282c618c"
            },
            "downloads": -1,
            "filename": "pthbz-1.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "3324e839a1b61463729548d010a9dfeb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 10455,
            "upload_time": "2025-08-13T20:25:07",
            "upload_time_iso_8601": "2025-08-13T20:25:07.074355Z",
            "url": "https://files.pythonhosted.org/packages/1c/25/a5e809095233e4e61febe71d4a8ae0fd18c039d36850978f575babc7d4d6/pthbz-1.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-13 20:25:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pthbz",
    "github_project": "pthbz-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pthbz"
}
        
Elapsed time: 1.41182s