API Dokumentation
Verwenden Sie unsere öffentliche API, um URLs programmatisch zu kürzen.
Endpoint
POST /api/v1/shortenRequest
Headers
Content-Type: application/jsonBody
{
"url": "https://example.com/sehr/lange/url",
"customCode": "mein-link" // optional
}url: Die zu kürzende URL (erforderlich)
customCode: Individueller Short Code (optional, 3-50 Zeichen, nur a-z, 0-9, -, _)
Response
Erfolg (201)
{
"success": true,
"shortUrl": "https://zhort.app/s/abc12345",
"shortCode": "abc12345",
"originalUrl": "https://example.com/sehr/lange/url"
}Fehler (403 - Blockiert)
{
"success": false,
"error": "Domain blockiert",
"message": "Diese Domain steht auf der Blocklist..."
}Beispiele
cURL
# Zufälliger Short Code
curl -X POST https://zhort.app/api/v1/shorten \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/sehr/lange/url"}'
# Mit individuellem Short Code
curl -X POST https://zhort.app/api/v1/shorten \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/sehr/lange/url", "customCode": "mein-link"}'JavaScript (fetch)
const response = await fetch('https://zhort.app/api/v1/shorten', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
url: 'https://example.com/sehr/lange/url'
})
});
const data = await response.json();
console.log(data.shortUrl);Python (requests)
import requests
response = requests.post(
'https://zhort.app/api/v1/shorten',
json={'url': 'https://example.com/sehr/lange/url'}
)
data = response.json()
print(data['shortUrl'])Blocklist-Schutz
Alle URLs werden automatisch gegen die Hagezi DNS Blocklist geprüft. URLs von blockierten Domains werden abgelehnt.
Hinweise
- Die API ist öffentlich und erfordert keine Authentifizierung
- Erstellte Links sind standardmäßig öffentlich
- Links werden nicht automatisch gelöscht
- Nur HTTP und HTTPS URLs sind erlaubt
- Individuelle Short Codes: 3-50 Zeichen, nur Kleinbuchstaben, Zahlen, Bindestriche und Unterstriche
- Short Codes sind eindeutig und können nur einmal vergeben werden