Para acceder a los endpoints autenticados, necesitas una API Key. Se genera automáticamente al registrarte y la encuentras en tu Dashboard.
Authorization: Bearer tu-api-key
/api/shorten
Público
Acorta un link sin necesidad de autenticación.
Request:
POST /api/shorten
Content-Type: application/json
{ "url": "https://ejemplo.com/muy/larga" }
Response:
{
"short_code": "aB3xK7z",
"short_url": "https://link.spacehowen.com/aB3xK7z"
}
/api/shorten
Autenticado
Acorta un link con autenticación. Obtienes estadísticas y tracking de clicks.
Request:
POST /api/shorten
Content-Type: application/json
Authorization: Bearer tu-api-key
{ "url": "https://ejemplo.com/muy/larga", "expires_in": "30d" }
Response:
{
"short_code": "xYz9876",
"short_url": "https://link.spacehowen.com/xYz9876",
"stats_url": "https://link.spacehowen.com/dashboard/stats/xYz9876"
}
expires_in opcional: 1d, 7d, 30d, permanent
slug opcional: string de 3-20 caracteres (letras, números, guiones). Ej: "slug": "mi-link"
/api/shorten
Autenticado + Slug
Acorta con slug personalizado.
Request:
POST /api/shorten
Content-Type: application/json
Authorization: Bearer tu-api-key
{ "url": "https://ejemplo.com", "slug": "mi-enlace", "expires_in": "permanent" }
Response:
{
"short_code": "mi-enlace",
"short_url": "https://link.spacehowen.com/mi-enlace",
"stats_url": "https://link.spacehowen.com/dashboard/stats/mi-enlace"
}
Todos los errores devuelven un objeto JSON con el campo error.
Ejemplo:
{ "error": "Link inválido" }
422 — Link inválido o slug inválido
401 — API Key inválida o faltante
409 — Slug ya en uso
404 — Link no encontrado
/api/stats/{code}
Autenticado
Obtén estadísticas de un link.
Response:
{
"url": "https://ejemplo.com",
"clicks": 42,
"unique_clicks": 35,
"countries": [{ "country": "Mexico", "total": 20 }],
"referers": [{ "referer": "twitter.com", "total": 15 }],
"timeline": [{ "date": "2026-06-01", "total": 5 }],
"created_at": "2026-06-01 12:00:00",
"expires_at": "2026-07-01 12:00:00"
}
/api/links
Autenticado
Lista todos tus links.
[
{
"id": 1,
"short_code": "aB3xK7z",
"long_link": "https://ejemplo.com",
"clicks_total": 42,
"expires_at": "2026-07-01 12:00:00",
"created_at": "2026-06-01 12:00:00"
}
]
/api/links/{id}
Autenticado
Elimina uno de tus links.
Response:
{ "deleted": true }
cURL
curl -X POST https://link.spacehowen.com/api/shorten \
-H "Content-Type: application/json" \
-d '{"url":"https://ejemplo.com"}'
JavaScript (fetch)
fetch('https://link.spacehowen.com/api/shorten', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ url: 'https://ejemplo.com' })
}).then(r => r.json()).then(console.log);
PHP
$ch = curl_init('https://link.spacehowen.com/api/shorten');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode(['url' => 'https://ejemplo.com']),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_RETURNTRANSFER => true,
]);
$res = curl_exec($ch);
curl_close($ch);
$data = json_decode($res, true);
echo $data['short_url'];
Python
import requests
r = requests.post('https://link.spacehowen.com/api/shorten', json={
'url': 'https://ejemplo.com'
})
print(r.json()['short_url'])
cURL
curl -X POST https://link.spacehowen.com/api/shorten \
-H "Content-Type: application/json" \
-H "Authorization: Bearer tu-api-key" \
-d '{"url":"https://ejemplo.com","slug":"mi-link","expires_in":"permanent"}'
JavaScript (fetch)
fetch('https://link.spacehowen.com/api/shorten', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer tu-api-key'
},
body: JSON.stringify({
url: 'https://ejemplo.com',
slug: 'mi-link',
expires_in: 'permanent'
})
}).then(r => r.json()).then(console.log);
PHP
$ch = curl_init('https://link.spacehowen.com/api/shorten');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode([
'url' => 'https://ejemplo.com',
'slug' => 'mi-link',
'expires_in' => 'permanent'
]),
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Authorization: Bearer tu-api-key'
],
CURLOPT_RETURNTRANSFER => true,
]);
$res = curl_exec($ch);
curl_close($ch);
$data = json_decode($res, true);
echo $data['short_url'];
Python
import requests
r = requests.post('https://link.spacehowen.com/api/shorten', json={
'url': 'https://ejemplo.com',
'slug': 'mi-link',
'expires_in': 'permanent'
}, headers={
'Authorization': 'Bearer tu-api-key'
})
print(r.json()['short_url'])