URL Shortener API

Powerful API to shorten URLs with no authentication required

Lightning Fast

Sub-100ms response times with our optimized infrastructure

No Authentication

Start using immediately without API keys or signups

Reliable

99.9% uptime with automatic failover

Introduction

Welcome to the URLsmush API documentation. This open API allows you to programmatically shorten long URLs without any authentication required.

All API endpoints return JSON responses. Simply send a POST request with your URL to get started.

Try It Out

Shorten a URL

Create a new short URL from a long URL. The response will include the shortened URL that you can share.

POST https://urlsmush.com/api.php
Request Body
JSON
cURL
JavaScript
PHP
Python
{
    "url": "https://example.com/very/long/url/to/be/shortened"
}
curl -X POST https://urlsmush.com/api.php \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/very/long/url/to/be/shortened"
  }'
fetch('https://urlsmush.com/api.php', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
        url: 'https://example.com/very/long/url/to/be/shortened'
    })
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
$url = 'https://urlsmush.com/api.php';
$data = ['url' => 'https://example.com/very/long/url/to/be/shortened'];

$options = [
    'http' => [
        'header'  => "Content-type: application/json\r\n",
        'method'  => 'POST',
        'content' => json_encode($data),
    ],
];

$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
$response = json_decode($result, true);

print_r($response);
import requests
import json

url = "https://urlsmush.com/api.php"
payload = {"url": "https://example.com/very/long/url/to/be/shortened"}
headers = {"Content-Type": "application/json"}

response = requests.post(url, data=json.dumps(payload), headers=headers)
print(response.json())
Response
200 OK
{
    "status": "success",
    "message": "URL shortened successfully",
    "data": {
        "long_url": "https://example.com/very/long/url/to/be/shortened",
        "short_url": "https://urlsmush.com/abc123",
        "short_code": "abc123"
    }
}
400 Bad Request
{
    "status": "error",
    "message": "URL parameter is required",
    "data": null
}

Redirect Flow

When a user visits your shortened URL, they will be automatically redirected to the original long URL.

GET https://urlsmush.com/{short_code}
Usage

Simply construct the URL with your 6-character code:

https://urlsmush.com/abc123

Visiting this URL will:

301 Moved Permanently

Redirects to the original URL with headers:

HTTP/1.1 301 Moved Permanently
Location: https://example.com/very/long/url/to/be/shortened
Cache-Control: max-age=31536000
404 Not Found
HTTP/1.1 404 Not Found
Content-Type: application/json

{
    "status": "error",
    "message": "Short URL not found",
    "data": null
}