Gen-Endpoint

Free URL Shortener API — Mock REST API for Testing & Development

Utilities
6 Endpoints
Live & Active

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.

Internal API - Hosted by Gen-Endpoint

Interactive Live API Explorer

Explore, configure parameters, and execute live HTTP requests directly in your browser. All routes are active!
POST

/api/shorten

Create a new shortened URL. Custom alias (shortCode) and expiration are optional.

Try it live in browser
GET

/api/stats/{shortCode}

Get statistics for a shortened URL. Replace {shortCode} with an actual short code.

Try it live in browser

Replace placeholders (e.g., {userId}) with actual values in the path above. You can also add/edit query parameters (e.g., ?key=value).

GET

/api/links

List all shortened URLs. Supports optional `userId` query parameter for filtering.

Try it live in browser

You can add or change query parameters in the path above (e.g., ?name=User).

GET

/api/links/{linkId}

Get details for a specific short link by its internal ID. Replace {linkId} with an actual link ID.

Try it live in browser

Replace placeholders (e.g., {userId}) with actual values in the path above. You can also add/edit query parameters (e.g., ?key=value).

DELETE

/api/links/{linkId}

Delete a specific short link by its internal ID. Replace {linkId} with an actual link ID.

Try it live in browser

Replace placeholders (e.g., {userId}) with actual values in the path above.

GET

/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.

Try it live in browser

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

Copy ready-to-use cURL commands and JavaScript Fetch snippets directly into your projects or testing tools.
Standard Fetch API (Browser & Node.js 18+)
// 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

How developers integrate the URL Shortener API during rapid frontend prototyping and automated testing.

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

Explore complementary mock endpoints to chain and test full application workflows.

QR Code Generator API

Utilities

Generate QR codes for text, URLs, and structured data with customizable styling.

View API

Analytics & Metrics API

Analytics

Track events, generate reports, and provide dashboard data with real-time metrics.

View API

File Upload & Management API

Utilities

Handle file uploads, downloads, metadata, and bulk operations with validation.

View API

Data Export API

Data

Export data in various formats (CSV, JSON, XML) with filtering and field selection.

View API

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.