API-Dokumentation
Einfache JSON-API für Kurzlinks mit 301, optionalem Interstitial und PNG-QR.
API-Überblick
Basis-URL: https://pth.bz
Endpunkt
POST https://pth.bz/api/shorten
Content-Type: application/json
Anfrage
Body JSON:
{
"url": "https://example.com/landing?utm_source=newsletter"
}
Antwort
200 OK:
{
"short_url_301": "https://pth.bz/AbC1234",
"short_url_js": "https://pth.bz/i/AbC1234",
"qr_301_png_url": "https://pth.bz/?qr=AbC1234",
"qr_js_png_url": "https://pth.bz/?qi=AbC1234"
}
Weitere Status
- 400 - Ungültiger JSON/URL.
- 405 - POST verwenden.
- 429 - Limit überschritten.
- 500 - Interner Fehler.
Weiterleitung wählen
301 (Standard)
Schnelle permanente Weiterleitung: /CODE
Interstitial (Anti-Bot)
Kurzer JS-Schritt, Referrer verborgen: /i/CODE
QR-Codes (PNG)
- For 301:
/?qr=CODE
- For interstitial:
/?qi=CODE
- Optionale Größe in px: (200–2048)
&px=640
<img src="https://pth.bz/?qr=AbC1234&px=640" alt="QR" />
Fehlerantworten
{
"error": "Too many requests"
}
Grenzen und Regeln
- Limit: 30 Anfragen / 10 Min / IP.
- Nur http:// und https://.
- Maximale URL-Länge: 2000 Zeichen.
- Nur JSON: Content-Type: application/json.
Beispiele
curl
curl -X POST "https://pth.bz/api/shorten" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com"}'
JavaScript (fetch)
const res = await fetch('https://pth.bz/api/shorten', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ url: 'https://example.com' })
});
const data = await res.json();
console.log(data.short_url_301, data.short_url_js);
Python (requests)
import requests
r = requests.post('https://pth.bz/api/shorten', json={'url': 'https://example.com'})
print(r.status_code, r.json())
SDKs
Python SDK
Offizielle Python-Bibliothek für die Arbeit mit Einfacher URL-Kürzer.
Quick start (sync)
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
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())
Die lokale URL-Validierung spiegelt die Serverregeln wider: nur http/https, keine Benutzerinfo, localhost und IP ohne Punkt erlaubt, IDN → Punycode.