REST-API-Referenz
Basis-URL: https://urlw.fr
Alle Anfragen geben JSON zurück. Die Authentifizierung verwendet API-Keys (Bearer).
Endpunkte
Authentifizierung
Die URLW-API verwendet API-Keys zur Authentifizierung. Jede Anfrage muss Ihren Schlüssel im Authorization-Header enthalten.
Comment obtenir une clé API
- Connectez-vous à votre compte URLW et accédez à la page Clés API
- Donnez un nom à votre clé et cliquez sur Créer
- Copiez la clé affichée — elle ne sera plus visible ensuite
Erforderliche Header
Authorization: Bearer uw_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
POST/api/links
Neuen Kurzlink erstellen. Erfordert einen gültigen API-Key.
Erforderliche Header
Authorization: Bearer uw_votre_cle_api
Content-Type: application/json
Anfrage-Body
{
"url": "https://example.com/une-url-tres-longue"
}
Antwort (201 Created)
{
"id": 42,
"short_code": "aB3xYz",
"short_url": "https://urlw.fr/aB3xYz",
"original_url": "https://example.com/une-url-tres-longue",
"clicks": 0,
"created_at": "2026-04-18T12:00:00+00:00"
}
curl-Beispiel
curl -s -X POST https://urlw.fr/api/links \
-H "Authorization: Bearer uw_votre_cle_api" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com/page-longue?utm_source=api"}'
GET/api/links
Alle Ihre Kurzlinks auflisten. Erfordert einen gültigen API-Key.
curl-Beispiel
curl -s https://urlw.fr/api/links \
-H "Authorization: Bearer uw_votre_cle_api" | jq .
Antwort (200 OK)
[
{
"id": 42,
"short_code": "aB3xYz",
"short_url": "https://urlw.fr/aB3xYz",
"original_url": "https://example.com/page-longue",
"clicks": 14,
"created_at": "2026-04-18T12:00:00+00:00"
}
]
GET/api/links/{id}
Details eines bestimmten Links abrufen, einschließlich des Klickzählers.
curl-Beispiel
curl -s https://urlw.fr/api/links/42 \
-H "Authorization: Bearer uw_votre_cle_api" | jq .
Antwort (200 OK)
{
"id": 42,
"short_code": "aB3xYz",
"short_url": "https://urlw.fr/aB3xYz",
"original_url": "https://example.com/page-longue",
"clicks": 14,
"created_at": "2026-04-18T12:00:00+00:00"
}
DELETE/api/links/{id}
Link dauerhaft löschen. Die Weiterleitung wird sofort inaktiv. Diese Aktion ist irreversibel.
curl-Beispiel
curl -s -X DELETE https://urlw.fr/api/links/42 \
-H "Authorization: Bearer uw_votre_cle_api"
# → 204 No Content (Erfolg, kein Body)
6. Fehlercodes
| HTTP-Code | Bedeutung | Häufige Ursache |
|---|---|---|
400 | Bad Request | Fehlende oder ungültige URL im Anfrage-Body |
401 | Unauthorized | API-Key fehlt, ist abgelaufen oder ungültig |
403 | Forbidden | Zugriff auf einen Link eines anderen Benutzers |
404 | Not Found | Link-ID existiert nicht |
429 | Too Many Requests | Monatliches Link-Kontingent erreicht |
500 | Server Error | Interner Fehler — Kontaktieren Sie den Support über /contact |
Fehlerformat
{
"error": "authentication_failed",
"message": "Invalid or expired API key."
}
PHP- & JavaScript-Beispiele
Sie benötigen kein SDK: Die API ist eine einfache JSON-REST-API. Hier sind Kopier-Einfügen-Beispiele für die gängigsten Sprachen.
PHP
<?php
// URLW API — PHP example (no SDK needed)
$apiKey = 'uw_votre_cle_api';
$url = 'https://example.com/une-url-tres-longue';
$ch = curl_init('https://urlw.fr/api/links');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['url' => $url]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
echo $response['shortUrl'];
// => https://urlw.fr/aB3xYz
JavaScript (Node.js / fetch)
const API_KEY = 'uw_votre_cle_api';
const res = await fetch('https://urlw.fr/api/links', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ url: 'https://example.com/une-url-tres-longue' }),
});
const link = await res.json();
console.log(link.shortUrl);
// => https://urlw.fr/aB3xYz
Link mit benutzerdefiniertem Slug (Pro+)
curl -s -X POST https://urlw.fr/api/links \
-H "Authorization: Bearer uw_votre_cle_api" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com/promo","customSlug":"ma-promo"}'
{
"id": 43,
"short": "rT9kWm",
"customSlug": "ma-promo",
"shortUrl": "https://urlw.fr/ma-promo",
"url": "https://example.com/promo",
"clickCount": 0,
"createdAt": "2026-04-25T14:00:00+00:00"
}
Benutzerdefinierte Slugs erfordern einen Pro-Plan oder höher. 3 bis 60 Zeichen, Buchstaben, Ziffern und Bindestriche.
Fragen zur API? Kontaktieren Sie uns. Siehe auch die allgemeine Dokumentation.