Live
Free tier included
Shorten URLs with Analytics
Create short links with custom slugs, expiration dates, and click analytics. Track engagement for marketing campaigns, social media, and email marketing.
Custom Slugs
Click Analytics
Expiring Links
301 Redirects
Interactive Playground
Try it Free
Shorten any URL and track clicks in real-time. No signup required.
Shorten a URL
Link Stats
Enter a short code to view click analytics
API Documentation
Shorten any URL with optional custom slugs, expiration times, and click analytics. Perfect for marketing campaigns, social sharing, and link tracking.
Endpoints
POST
https://www.mahmoudalhabash.com/api/v1/shorten
Create a short URL.
GET
https://www.mahmoudalhabash.com/api/v1/shorten/{code}/stats
Retrieve click statistics for a short URL.
Request Parameters (POST)
Response Fields
short_url The full short URL ready to sharecode The unique code or custom slugoriginal_url The original long URLclicks Total number of clicks (stats endpoint)expires_at ISO 8601 expiration date (null if never)Code Examples
cURL — Shorten
curl -X POST https://www.mahmoudalhabash.com/api/v1/shorten \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/very/long/page",
"custom_slug": "my-link",
"expires_in": 10080
}'
Response 200JSON
{
"status": "success",
"short_url": "https://www.mahmoudalhabash.com/s/my-link",
"code": "my-link",
"original_url": "https://example.com/very/long/page",
"expires_at": "2026-03-18T08:00:00+00:00",
"clicks": 0
}
JavaScript (fetch)
const res = await fetch('https://www.mahmoudalhabash.com/api/v1/shorten', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
url: 'https://example.com/campaign?utm_source=twitter',
custom_slug: 'twitter-promo'
})
});
const { short_url } = await res.json();
console.log('Share this:', short_url);
// Check stats later
const stats = await fetch(
'https://www.mahmoudalhabash.com/api/v1/shorten/twitter-promo/stats'
).then(r => r.json());
console.log(`Clicks: ${stats.clicks}`);
Python (requests)
import requests
# Shorten
resp = requests.post(
'https://www.mahmoudalhabash.com/api/v1/shorten',
json={
'url': 'https://example.com/long-url',
'expires_in': 1440 # 24 hours
}
)
data = resp.json()
print(f"Short URL: {data['short_url']}")
# Get stats
stats = requests.get(
f"https://www.mahmoudalhabash.com/api/v1/shorten/{data['code']}/stats"
).json()
print(f"Clicks: {stats['clicks']}")
Error Codes
422 Validation failed — URL required, invalid slug format or slug already taken
404 Short URL not found (stats endpoint)
410 Short URL has expired
429 Rate limit exceeded
500 Internal server error
Rate Limits
Unlimited — Free during beta
No API key required. Short URLs redirect with 301 status. Click counts update in real-time. Links without expiration persist indefinitely.