LinkShrink API Documentation

Welcome to LinkShrink, the free URL shortener that respects your privacy. This API allows you to shorten URLs, create custom aliases, generate QR codes, and track basic analytics—all without requiring an API key or user account.

No Authentication Required: LinkShrink is completely free and open. All endpoints are publicly accessible with no API key needed.

Authentication

None required. All endpoints are publicly accessible. There are no API keys, no OAuth flows, no JWT tokens. Just call the endpoints directly.

Rate Limits

To ensure fair usage and prevent abuse, LinkShrink enforces the following rate limits:

429 Too Many Requests: If you exceed rate limits, you'll receive a 429 response. Wait for the time indicated in Retry-After header before retrying.

Shorten a URL

Create a short link from a long URL. Optionally specify a custom alias.

POST /api/v1/shorten

Request Body

Parameter Type Required Description
url string Required The long URL to shorten. Must be a valid HTTP/HTTPS URL.
alias string Optional Custom short code (alphanumeric, hyphens, underscores). 3-30 characters. Must be unique.

Example Request

request.sh
curl -X POST "https://linkshrink.dev/api/v1/shorten" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://github.com/softvoyagers/linkshrink-api",
    "alias": "gh-linkshrink"
  }'

Example Response

response.json
{
  "status": "success",
  "data": {
    "shortUrl": "https://linkshrink.dev/gh-linkshrink",
    "originalUrl": "https://github.com/softvoyagers/linkshrink-api",
    "alias": "gh-linkshrink",
    "qrCode": "https://linkshrink.dev/gh-linkshrink/qr",
    "analytics": "https://linkshrink.dev/gh-linkshrink/stats",
    "createdAt": "2026-02-13T12:00:00.000Z"
  }
}

Redirect to Target URL

Access a short link to be redirected to the original URL. This increments the click count.

GET /:alias

Path Parameters

Parameter Type Description
alias string The short code / alias of the link.

Example

browser
https://linkshrink.dev/gh-linkshrink

→ Redirects to: https://github.com/softvoyagers/linkshrink-api

Get Analytics

Retrieve click statistics for a shortened link. No authentication required—analytics are public.

GET /:alias/stats

Path Parameters

Parameter Type Description
alias string The short code / alias of the link.

Example Request

request.sh
curl "https://linkshrink.dev/gh-linkshrink/stats"

Example Response

response.json
{
  "status": "success",
  "data": {
    "alias": "gh-linkshrink",
    "originalUrl": "https://github.com/softvoyagers/linkshrink-api",
    "shortUrl": "https://linkshrink.dev/gh-linkshrink",
    "clicks": 1247,
    "createdAt": "2026-02-13T12:00:00.000Z",
    "lastClickedAt": "2026-02-13T14:32:15.000Z",
    "topCountries": [
      { "country": "US", "clicks": 542 },
      { "country": "DE", "clicks": 318 },
      { "country": "GB", "clicks": 201 }
    ],
    "topReferrers": [
      { "referrer": "twitter.com", "clicks": 423 },
      { "referrer": "reddit.com", "clicks": 298 },
      { "referrer": "direct", "clicks": 526 }
    ]
  }
}

Get QR Code

Retrieve a QR code image for a shortened link. Returns a PNG image that can be embedded or downloaded.

GET /:alias/qr

Path Parameters

Parameter Type Description
alias string The short code / alias of the link.

Query Parameters (Optional)

Parameter Type Default Description
size integer 300 QR code size in pixels (100-1000).
format string png Image format: png or svg.

Example

browser
https://linkshrink.dev/gh-linkshrink/qr

→ Returns PNG image of QR code

https://linkshrink.dev/gh-linkshrink/qr?size=500&format=svg

→ Returns SVG image of QR code at 500x500px

Custom Aliases

When creating a short link, you can specify a custom alias to make your link more memorable and brandable. If no alias is provided, LinkShrink will generate a random 6-character code.

Alias Rules

Error Codes

LinkShrink uses standard HTTP status codes to indicate success or failure.

Status Code Meaning Description
200 OK Request succeeded.
201 Created Short link created successfully.
400 Bad Request Invalid input (e.g., malformed URL, invalid alias format).
404 Not Found Short link alias does not exist.
409 Conflict Custom alias is already taken.
429 Too Many Requests Rate limit exceeded. Check Retry-After header.
500 Internal Server Error Something went wrong on our end. Please try again.

Error Response Format

error.json
{
  "status": "error",
  "message": "Alias 'gh-linkshrink' is already taken",
  "code": "ALIAS_TAKEN"
}

Full Examples

Example 1: Shorten a URL with Auto-Generated Alias

auto-alias.sh
curl -X POST "https://linkshrink.dev/api/v1/shorten" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/very-long-url-with-many-parameters"}'

# Response:
{
  "shortUrl": "https://linkshrink.dev/a3f8Kp",
  "qrCode": "https://linkshrink.dev/a3f8Kp/qr",
  ...
}

Example 2: Shorten with Custom Alias

custom-alias.sh
curl -X POST "https://linkshrink.dev/api/v1/shorten" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://softvoyagers.com/blog/best-practices",
    "alias": "sv-blog-best"
  }'

Example 3: Fetch Analytics

analytics.sh
curl "https://linkshrink.dev/sv-blog-best/stats"

# Response includes click count, countries, referrers
Need Help? If you encounter issues or have questions, open an issue on our GitHub repository.
Part of the SoftVoyagers Ecosystem