Loading...
Loading...
Create and manage short links programmatically with our REST API.
https://shtr.xyz/apiCreate a new short link.
{
"url": "https://example.com/very-long-url",
"customCode": "my-link", // optional, 3-20 chars
"password": "secret123", // optional
"expiresAt": "2024-12-31T23:59:59Z", // optional, ISO 8601
"isOneTime": false // optional, default false
}{
"shortUrl": "https://shtr.xyz/abc1",
"code": "abc1",
"editToken": "tok_a1b2c3d4e5f6...",
"qrCode": "data:image/png;base64,..."
}curl -X POST https://shtr.xyz/api/shorten \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/page"}'Get information about a short link.
token (optional)Edit token for full details
{
"code": "abc1",
"clicks": 42,
"isActive": true
}{
"code": "abc1",
"originalUrl": "https://example.com/page",
"clicks": 42,
"createdAt": "2024-01-15T10:30:00Z",
"expiresAt": null,
"isPasswordProtected": false,
"isOneTime": false,
"isActive": true
}curl https://shtr.xyz/api/links/abc1?token=tok_xxx
Get comprehensive analytics for a short link. Requires edit token.
token (required)Edit token from creation
{
"link": {
"id": 1,
"code": "abc1",
"original_url": "https://example.com/page",
"created_at": "2024-01-15T10:30:00Z",
"expires_at": null,
"password_hash": null,
"is_one_time": false,
"is_active": true,
"clicks": 42
},
"clicksOverTime": [
{ "date": "2024-01-15", "clicks": 10 },
{ "date": "2024-01-16", "clicks": 15 }
],
"topCountries": [
{ "country": "United States", "country_code": "US", "clicks": 25 },
{ "country": "Germany", "country_code": "DE", "clicks": 10 }
],
"deviceBreakdown": [
{ "device_type": "desktop", "clicks": 30 },
{ "device_type": "mobile", "clicks": 12 }
],
"browserBreakdown": [
{ "browser_name": "Chrome", "clicks": 28 },
{ "browser_name": "Safari", "clicks": 14 }
],
"osBreakdown": [
{ "os_name": "Windows", "clicks": 20 },
{ "os_name": "macOS", "clicks": 15 }
],
"topReferers": [
{ "referer": "https://twitter.com", "clicks": 15 },
{ "referer": "Direct", "clicks": 27 }
],
"recentClicks": [...],
"uniqueVisitors": 38,
"totalClickEvents": 42
}curl https://shtr.xyz/api/links/abc1/stats?token=tok_xxx
Get paginated click events for a short link. Requires edit token.
token (required)Edit token from creation
page (optional)Page number, default 1
limit (optional)Results per page, default 20, max 100
{
"clicks": [
{
"id": 1,
"clicked_at": "2024-01-15T14:30:00Z",
"ip_address": "192.168.1.1",
"user_agent": "Mozilla/5.0...",
"referer": "https://twitter.com/...",
"country": "United States",
"country_code": "US",
"city": "New York",
"device_type": "desktop",
"browser_name": "Chrome",
"os_name": "Windows",
"is_bot": false
}
],
"total": 42,
"page": 1,
"limit": 20,
"totalPages": 3
}curl "https://shtr.xyz/api/links/abc1/clicks?token=tok_xxx&page=1&limit=20"
Find a link by its edit token.
token (required)Edit token from creation
{
"code": "abc1",
"originalUrl": "https://example.com/page",
"isActive": true
}curl https://shtr.xyz/api/lookup?token=tok_xxx
Delete a short link. Requires edit token.
token (required)Edit token from creation
{
"success": true
}curl -X DELETE https://shtr.xyz/api/links/abc1?token=tok_xxx
Verify password for a protected link. Sets a cookie for access.
{
"code": "abc1",
"password": "secret123"
}{
"success": true
}All errors return a JSON object with an error message:
{
"error": "Description of what went wrong"
}The API is rate limited to prevent abuse. If you exceed the limit, you'll receive a 429 status code. Please wait before making more requests.