API Documentation

Shorten URLs, generate QR codes, and access click analytics programmatically.

https://u2m.io

Shorten Your First URL in 30 Seconds

  1. Shorten a URL

    Copy and run this curl command:

    curl -X POST https://u2m.io/shorten \
      -H "Content-Type: application/json" \
      -d '{"longUrl": "https://example.com/my-page"}'
  2. Check the response

    You'll get back a short URL and a stats token:

    {
      "shortUrl": "https://u2m.io/aB3kLm9p",
      "statsToken": "abc123def456",
      "statsUrl": "https://u2m.io/stats/abc123def456"
    }
  3. View your analytics

    Open the statsUrl in your browser to see click analytics, geographic data, and more.

Authentication No API key needed. All endpoints are public. Per-URL analytics (detailed stats dashboard) require a statsToken — returned automatically when you shorten a URL. Keep your statsToken private to protect your analytics.
Rate Limits API endpoints are rate-limited to 100 requests per minute per IP address. Exceeding this limit returns a 429 status code.

Status Codes & Errors

StatusMeaningWhen
200OKRequest succeeded
400Bad RequestInvalid URL, missing required field, or malformed JSON
404Not FoundShort code does not exist
429Too Many RequestsRate limit exceeded (100 req/min per IP)
500Internal Server ErrorUnexpected server error
Example Error Response
{
  "status": 400,
  "error": "Bad Request",
  "message": "Invalid URL format"
}

Endpoints

POST /shorten
Shorten a long URL

Creates a short URL that redirects to the provided long URL. Optionally specify a custom short code and expiration date.

Request Body (JSON)
FieldTypeRequiredDescription
longUrl string required The URL to shorten
customCode string optional Custom short code (4-20 alphanumeric chars)
expirationDate string optional Expiration in ISO 8601 format (e.g. 2027-01-01T00:00:00)
Example Request
curl -X POST https://u2m.io/shorten \
  -H "Content-Type: application/json" \
  -d '{
    "longUrl": "https://example.com/very/long/path",
    "customCode": "mylink"
  }'
Response (200 OK)
{
  "shortUrl": "https://u2m.io/mylink",
  "statsToken": "abc123def456",
  "statsUrl": "https://u2m.io/stats/abc123def456"
}
GET /shorten?url={url}
Shorten URL via query parameter

A simpler alternative that accepts the URL as a query parameter. Useful for quick browser-based shortening.

Query Parameters
ParameterTypeRequiredDescription
url string required The URL to shorten (URL-encoded)
Example Request
curl "https://u2m.io/shorten?url=https%3A%2F%2Fexample.com%2Flong-path"
POST /shorten/bulk
Bulk shorten multiple URLs

Shorten up to 100 URLs in a single request. Each URL is processed independently, so partial failures are possible.

Example Request
curl -X POST https://u2m.io/shorten/bulk \
  -H "Content-Type: application/json" \
  -d '[
    { "longUrl": "https://example.com/page-1" },
    { "longUrl": "https://example.com/page-2", "customCode": "pg2" }
  ]'
Response (200 OK)
[
  {
    "longUrl": "https://example.com/page-1",
    "shortUrl": "https://u2m.io/aB3kLm9p",
    "statsToken": "tok123",
    "statsUrl": "https://u2m.io/stats/tok123",
    "status": "success"
  },
  {
    "longUrl": "https://example.com/page-2",
    "shortUrl": "https://u2m.io/pg2",
    "statsToken": "tok456",
    "statsUrl": "https://u2m.io/stats/tok456",
    "status": "success"
  }
]
GET /{shortCode}
Redirect to original URL

Redirects the user to the original long URL. Each visit is counted as a click for analytics. Short codes are 4-20 alphanumeric characters.

Example
curl -L https://u2m.io/mylink
# Redirects to: https://example.com/very/long/path
GET /lookup/{shortCode}
Look up destination URL

Returns the destination URL for a short code without triggering a redirect or recording a click.

Response (200 OK)
{
  "longUrl": "https://example.com/very/long/path",
  "consecutiveFailures": 0,
  "isDynamicDomain": false
}
GET /analytics/{shortCode}
Get click count

Returns the total number of clicks for a given short code.

Example Request
curl https://u2m.io/analytics/mylink
Response (200 OK)
42
GET /qr/{shortCode}
Generate QR code

Generates a QR code image for the given short URL. Supports PNG and SVG output formats with configurable sizes.

Query Parameters
ParameterTypeDefaultDescription
size integer 300 Image dimensions in pixels (100-2048)
format string png png or svg
Example Request
curl -o qr.png "https://u2m.io/qr/mylink?size=500&format=png"

GET /stats/global
Global platform statistics

Returns aggregate statistics across all shortened URLs on the platform, including total URLs, total clicks, top countries, and most popular links.

Response (200 OK)
{
  "totalUrls": 15234,
  "totalClicks": 892451,
  "topCountries": [
    { "name": "United States", "count": 245000 },
    { "name": "Germany", "count": 89000 }
  ],
  "topUrls": [
    {
      "shortCode": "aB3kLm9p",
      "destinationDomain": "example.com",
      "clickCount": 12500
    }
  ]
}
GET /stats/{token}
Detailed URL statistics

Returns detailed click analytics for a specific URL using its stats token (provided when the URL was shortened). Includes time series data, geographic breakdown, browser/device/OS distribution, and referrer sources.

Query Parameters
ParameterTypeDefaultDescription
range string 7d Time range for data (e.g. 7d, 30d, 90d)
Response (200 OK)
{
  "totalClicks": 1250,
  "clicksOverTime": [
    { "timestamp": "2026-03-01", "count": 45 },
    { "timestamp": "2026-03-02", "count": 62 }
  ],
  "countries": [
    { "name": "Turkey", "count": 320 }
  ],
  "browsers": [
    { "name": "Chrome", "count": 890 }
  ],
  "devices": [
    { "name": "Desktop", "count": 750 }
  ],
  "os": [
    { "name": "Windows", "count": 600 }
  ],
  "referrers": [
    { "name": "twitter.com", "count": 200 }
  ]
}
GET /feed/latest
Recently shortened URLs

Returns the most recently shortened URLs across the platform. Useful for displaying a live activity feed.

Response (200 OK)
[
  {
    "shortCode": "aB3kLm9p",
    "destinationDomain": "example.com",
    "createdAt": "2026-03-08T14:30:00"
  }
]