Register to get your API key.

Authentication

Pass your API key in one of these ways:

Authorization: Bearer YOUR_API_KEY
X-API-Key: YOUR_API_KEY
?api_key=YOUR_API_KEY
POST https://urlshorten.nanos.ro/api/auth/register Register
Request body (JSON):
{"username":"john","email":"john@example.com","password":"secret123"}
Response:
{"success":true,"message":"Account created.","api_key":"abc123..."}
POST https://urlshorten.nanos.ro/api/auth/login Login
Request body (JSON):
{"email":"john@example.com","password":"secret123"}
Response:
{"success":true,"api_key":"abc123...","user":{...}}
POST https://urlshorten.nanos.ro/api/shorten Shorten URL
Request body (JSON):
{"url":"https://example.com/very-long-url","custom_slug":"my-link","expires_days":30,"title":"My Link","password":"secret"}
Response:
{"success":true,"short_url":"http://...","short_code":"abc123","expires_at":"2025-01-01"}
GET https://urlshorten.nanos.ro/api/me ๐Ÿ”‘ AUTH My Profile & Usage
Response:
{"success":true,"user":{...},"usage":{"total_urls":42,"today_urls":3},"limits":{...}}
POST https://urlshorten.nanos.ro/api/me/regenerate-key ๐Ÿ”‘ AUTH Regenerate API Key
Response:
{"success":true,"api_key":"new_key_here"}
GET https://urlshorten.nanos.ro/api/urls?page=1&per_page=20 ๐Ÿ”‘ AUTH List My URLs
Response:
{"success":true,"urls":[...],"total":42,"page":1}
GET https://urlshorten.nanos.ro/api/urls/{id} ๐Ÿ”‘ AUTH Get URL Info
Response:
{"success":true,"url":{...}}
PUT https://urlshorten.nanos.ro/api/urls/{id} ๐Ÿ”‘ AUTH Edit URL
Request body (JSON):
{"original_url":"https://example.com/new","title":"Updated","expires_days":30,"password":"optional"}
Response:
{"success":true,"message":"URL updated."}
POST https://urlshorten.nanos.ro/api/urls/{id}/toggle ๐Ÿ”‘ AUTH Pause / Resume URL
Response:
{"success":true,"message":"URL status updated."}
DELETE https://urlshorten.nanos.ro/api/urls/{id} ๐Ÿ”‘ AUTH Delete URL
Response:
{"success":true,"message":"URL deleted."}
GET https://urlshorten.nanos.ro/api/urls/{id}/stats ๐Ÿ”‘ AUTH URL Analytics (Pro+)
Response:
{"success":true,"analytics":{"total_clicks":100,"devices":[...],"browsers":[...],"daily":[...]}}
GET https://urlshorten.nanos.ro/api/plans List Plans
Response:
{"success":true,"plans":[{"name":"free","daily_limit":10,...}]}
GET https://urlshorten.nanos.ro/api/admin/users ๐Ÿ”‘ AUTH List All Users (Admin)
Response:
{"success":true,"users":[...],"total":100}
PUT https://urlshorten.nanos.ro/api/admin/users/{id} ๐Ÿ”‘ AUTH Update User (Admin)
Request body (JSON):
{"plan":"pro","role":"user","is_active":1}
Response:
{"success":true,"message":"User updated."}
DELETE https://urlshorten.nanos.ro/api/admin/urls/{id} ๐Ÿ”‘ AUTH Delete Any URL (Admin)
Response:
{"success":true,"message":"URL deleted by admin."}
GET https://urlshorten.nanos.ro/api/admin/stats ๐Ÿ”‘ AUTH System Stats (Admin)
Response:
{"success":true,"stats":{"total_users":100,"total_urls":5000,"total_clicks":50000}}

HTTP Status Codes

CodeStatusMeaning
200 OK Request successful
201 Created Resource created successfully
204 No Content CORS preflight
400 Bad Request Invalid input data
401 Unauthorized Missing or invalid API key
403 Forbidden Insufficient permissions or plan
404 Not Found Resource or endpoint not found
422 Unprocessable Entity Validation failed (limit reached, invalid URL, etc.)
429 Too Many Requests Rate limit exceeded
500 Server Error Internal server error

cURL Examples

# Shorten a URL (no auth)
curl -X POST https://urlshorten.nanos.ro/api/shorten \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com/very-long-page"}'

# Shorten with auth + custom slug (Pro)
curl -X POST https://urlshorten.nanos.ro/api/shorten \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com","custom_slug":"my-brand","expires_days":30}'

# Get your URLs
curl https://urlshorten.nanos.ro/api/urls \
  -H "X-API-Key: YOUR_API_KEY"

# Get analytics
curl https://urlshorten.nanos.ro/api/urls/42/stats \
  -H "Authorization: Bearer YOUR_API_KEY"

# Admin: change user plan
curl -X PUT https://urlshorten.nanos.ro/api/admin/users/5 \
  -H "Authorization: Bearer ADMIN_KEY" \
  -H "Content-Type: application/json" \
  -d '{"plan":"pro"}'