Free URL Shortener API — Mock REST API for Testing & Development
The URL Shortener API provides a comprehensive suite of endpoints to simulate high-performance link management platforms like Bitly or TinyURL. Developers can test short URL generation (POST /api/shorten), lookup click analytics and visit metrics (GET /api/stats/{shortCode}), and manage stored links with live JSON responses.
Interactive Live API Explorer
/api/shorten
Create a new shortened URL. Custom alias (shortCode) and expiration are optional.
/api/stats/{shortCode}
Get statistics for a shortened URL. Replace {shortCode} with an actual short code.
Replace placeholders (e.g., {userId}) with actual values in the path above. You can also add/edit query parameters (e.g., ?key=value).
/api/links
List all shortened URLs. Supports optional `userId` query parameter for filtering.
You can add or change query parameters in the path above (e.g., ?name=User).
/api/links/{linkId}
Get details for a specific short link by its internal ID. Replace {linkId} with an actual link ID.
Replace placeholders (e.g., {userId}) with actual values in the path above. You can also add/edit query parameters (e.g., ?key=value).
/api/links/{linkId}
Delete a specific short link by its internal ID. Replace {linkId} with an actual link ID.
Replace placeholders (e.g., {userId}) with actual values in the path above.
/s/{shortCode}
Redirector endpoint. Accessing this path with a valid shortCode redirects to the original URL and increments the click count. This is not a JSON API but the core functionality.
Replace placeholders (e.g., {userId}) with actual values in the path above. You can also add/edit query parameters (e.g., ?key=value).
Code Integration Examples
// Free URL Shortener API - JavaScript Fetch Example
async function fetchURLShortenerAPI() {
try {
const response = await fetch('https://gen-endpoint.com/api/shorten', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
"originalUrl": "https://www.verylongurl.com/path/to/something/interesting?query=param",
"customAlias": "my-custom-link",
"description": "Link to an interesting article",
"expiresAt": "2025-12-31T23:59:59Z",
"userId": "user_abc_123"
}),
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
console.log('Success:', data);
return data;
} catch (error) {
console.error('Fetch error:', error);
}
}
fetchURLShortenerAPI();Sample JSON Response
{
"id": "link_nanoid10",
"shortUrl": "http://localhost:3000/s/my-custom-link",
"originalUrl": "https://www.verylongurl.com/path/to/something/interesting?query=param",
"shortCode": "my-custom-link",
"createdAt": "2024-08-20T10:00:00.000Z",
"expiresAt": "2025-12-31T23:59:59Z",
"description": "Link to an interesting article",
"clickCount": 0
}Common Developer Use Cases
Prototyping social sharing widgets and marketing link generators.
Testing asynchronous redirect handling and URL slug validation in web apps.
Building dashboard analytics charts for clicks, referrers, and timestamps.
Simulating link lifecycle management including creation, lookup, and deletion.
Related Free REST APIs
QR Code Generator API
Generate QR codes for text, URLs, and structured data with customizable styling.
Analytics & Metrics API
Track events, generate reports, and provide dashboard data with real-time metrics.
File Upload & Management API
Handle file uploads, downloads, metadata, and bulk operations with validation.
Data Export API
Export data in various formats (CSV, JSON, XML) with filtering and field selection.
Frequently Asked Questions
Does the short URL really redirect?
Yes! Requesting /s/{shortCode} performs a simulated redirect to the original destination URL provided during creation.
Can I retrieve click statistics for shortened links?
Yes, call GET /api/stats/{shortCode} to receive click counts, creation timestamps, and recent visit telemetry formatted in clean JSON.
What format should the destination URL be in?
Send a JSON body containing {"url": "https://example.com"}. Both HTTP and HTTPS protocols are accepted and validated.
Can I delete shortened links created during a test session?
Yes, call DELETE /api/links/{linkId} to remove the mock short link and test your application's deletion feedback states.